Scroll Area
Scrollable container with a thin token-styled scrollbar that keyboard users can focus and scroll. No JavaScript.
Releases
v2.12.0
v2.11.0
v2.10.0
v2.9.0
v2.8.0
v2.7.0
v2.6.0
v2.5.0
v2.4.0
v2.3.0
v2.2.0
v2.1.0
Releases
v2.12.0
v2.11.0
v2.10.0
v2.9.0
v2.8.0
v2.7.0
v2.6.0
v2.5.0
v2.4.0
v2.3.0
v2.2.0
v2.1.0
Releases
v2.12.0
v2.11.0
v2.10.0
v2.9.0
v2.8.0
v2.7.0
v2.6.0
v2.5.0
v2.4.0
v2.3.0
v2.2.0
v2.1.0
Releases
v2.12.0
v2.11.0
v2.10.0
v2.9.0
v2.8.0
v2.7.0
v2.6.0
v2.5.0
v2.4.0
v2.3.0
v2.2.0
v2.1.0
Releases
v2.12.0
v2.11.0
v2.10.0
v2.9.0
v2.8.0
v2.7.0
v2.6.0
v2.5.0
v2.4.0
v2.3.0
v2.2.0
v2.1.0
<x-markas.scroll-area label="Releases" class="max-h-56 border border-line bg-surface">
<div class="p-4">
<p class="mb-2 text-sm font-medium text-ink">Releases</p>
@foreach (range(12, 1) as $minor)
<p class="border-t border-line py-2 text-sm text-muted">v2.{{ $minor }}.0</p>
@endforeach
</div>
</x-markas.scroll-area>import { ScrollArea } from "@/components/markas/ScrollArea";
const releases = Array.from({ length: 12 }, (_, i) => `v2.${12 - i}.0`);
export default function ScrollAreaExample() {
return (
<ScrollArea
label="Releases"
className="max-h-56 border border-line bg-surface"
>
<div className="p-4">
<p className="mb-2 text-sm font-medium text-ink">Releases</p>
{releases.map((release) => (
<p
key={release}
className="border-t border-line py-2 text-sm text-muted"
>
{release}
</p>
))}
</div>
</ScrollArea>
);
}<script setup lang="ts">
import ScrollArea from "@/components/markas/ScrollArea.vue";
const releases = Array.from({ length: 12 }, (_, i) => `v2.${12 - i}.0`);
</script>
<template>
<ScrollArea label="Releases" class="max-h-56 border border-line bg-surface">
<div class="p-4">
<p class="mb-2 text-sm font-medium text-ink">Releases</p>
<p
v-for="release in releases"
:key="release"
class="border-t border-line py-2 text-sm text-muted"
>
{{ release }}
</p>
</div>
</ScrollArea>
</template><script lang="ts">
import ScrollArea from "$lib/components/markas/ScrollArea.svelte";
const releases = Array.from({ length: 12 }, (_, i) => `v2.${12 - i}.0`);
</script>
<ScrollArea label="Releases" class="max-h-56 border border-line bg-surface">
<div class="p-4">
<p class="mb-2 text-sm font-medium text-ink">Releases</p>
{#each releases as release (release)}
<p class="border-t border-line py-2 text-sm text-muted">{release}</p>
{/each}
</div>
</ScrollArea>---
import ScrollArea from "@/components/markas/ScrollArea.astro";
const releases = Array.from({ length: 12 }, (_, i) => `v2.${12 - i}.0`);
---
<ScrollArea label="Releases" class="max-h-56 border border-line bg-surface">
<div class="p-4">
<p class="mb-2 text-sm font-medium text-ink">Releases</p>
{
releases.map((release) => (
<p class="border-t border-line py-2 text-sm text-muted">{release}</p>
))
}
</div>
</ScrollArea>import { Component } from "@angular/core";
import { ScrollArea } from "./markas/scroll-area.component";
@Component({
selector: "markas-example",
imports: [ScrollArea],
template: `
<div
markas-scroll-area
label="Releases"
class="max-h-56 border border-line bg-surface"
>
<div class="p-4">
<p class="mb-2 text-sm font-medium text-ink">Releases</p>
@for (release of releases; track release) {
<p class="border-t border-line py-2 text-sm text-muted">
{{ release }}
</p>
}
</div>
</div>
`,
})
export default class ScrollAreaExample {
protected readonly releases = Array.from(
{ length: 12 },
(_, i) => `v2.${12 - i}.0`,
);
}Examples
Horizontal
Morning light
City nights
Slow mornings
Coastline
Weekend drive
Rain sounds
Morning light
City nights
Slow mornings
Coastline
Weekend drive
Rain sounds
Morning light
City nights
Slow mornings
Coastline
Weekend drive
Rain sounds
Morning light
City nights
Slow mornings
Coastline
Weekend drive
Rain sounds
Morning light
City nights
Slow mornings
Coastline
Weekend drive
Rain sounds
<x-markas.scroll-area label="Recently played" orientation="horizontal">
<div class="flex gap-3 pb-3">
@foreach (['Morning light', 'City nights', 'Slow mornings', 'Coastline', 'Weekend drive', 'Rain sounds'] as $album)
<div class="w-32 shrink-0">
<div class="h-32 rounded-lg bg-subtle"></div>
<p class="mt-2 truncate text-sm font-medium text-ink">{{ $album }}</p>
</div>
@endforeach
</div>
</x-markas.scroll-area>import { ScrollArea } from "@/components/markas/ScrollArea";
const albums = [
"Morning light",
"City nights",
"Slow mornings",
"Coastline",
"Weekend drive",
"Rain sounds",
];
export default function Example() {
return (
<ScrollArea label="Recently played" orientation="horizontal">
<div className="flex gap-3 pb-3">
{albums.map((album) => (
<div key={album} className="w-32 shrink-0">
<div className="h-32 rounded-lg bg-subtle" />
<p className="mt-2 truncate text-sm font-medium text-ink">
{album}
</p>
</div>
))}
</div>
</ScrollArea>
);
}<script setup lang="ts">
import ScrollArea from "@/components/markas/ScrollArea.vue";
const albums = [
"Morning light",
"City nights",
"Slow mornings",
"Coastline",
"Weekend drive",
"Rain sounds",
];
</script>
<template>
<ScrollArea label="Recently played" orientation="horizontal">
<div class="flex gap-3 pb-3">
<div v-for="album in albums" :key="album" class="w-32 shrink-0">
<div class="h-32 rounded-lg bg-subtle" />
<p class="mt-2 truncate text-sm font-medium text-ink">
{{ album }}
</p>
</div>
</div>
</ScrollArea>
</template><script lang="ts">
import ScrollArea from "$lib/components/markas/ScrollArea.svelte";
const albums = [
"Morning light",
"City nights",
"Slow mornings",
"Coastline",
"Weekend drive",
"Rain sounds",
];
</script>
<ScrollArea label="Recently played" orientation="horizontal">
<div class="flex gap-3 pb-3">
{#each albums as album (album)}
<div class="w-32 shrink-0">
<div class="h-32 rounded-lg bg-subtle"></div>
<p class="mt-2 truncate text-sm font-medium text-ink">{album}</p>
</div>
{/each}
</div>
</ScrollArea>---
import ScrollArea from "@/components/markas/ScrollArea.astro";
const albums = [
"Morning light",
"City nights",
"Slow mornings",
"Coastline",
"Weekend drive",
"Rain sounds",
];
---
<ScrollArea label="Recently played" orientation="horizontal">
<div class="flex gap-3 pb-3">
{
albums.map((album) => (
<div class="w-32 shrink-0">
<div class="h-32 rounded-lg bg-subtle" />
<p class="mt-2 truncate text-sm font-medium text-ink">{album}</p>
</div>
))
}
</div>
</ScrollArea>import { Component } from "@angular/core";
import { ScrollArea } from "./markas/scroll-area.component";
@Component({
selector: "markas-example",
imports: [ScrollArea],
template: `
<div markas-scroll-area label="Recently played" orientation="horizontal">
<div class="flex gap-3 pb-3">
@for (album of albums; track album) {
<div class="w-32 shrink-0">
<div class="h-32 rounded-lg bg-subtle"></div>
<p class="mt-2 truncate text-sm font-medium text-ink">
{{ album }}
</p>
</div>
}
</div>
</div>
`,
})
export default class ScrollAreaHorizontalExample {
protected readonly albums = [
"Morning light",
"City nights",
"Slow mornings",
"Coastline",
"Weekend drive",
"Rain sounds",
];
}Both directions
@php
$days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
@endphp
<x-markas.scroll-area label="Weekly schedule" orientation="both" class="max-h-60 border border-line bg-surface">
<div class="grid w-[640px] grid-cols-[4rem_repeat(7,1fr)] text-sm">
<div class="border-b border-line p-2"></div>
@foreach ($days as $day)
<div class="border-b border-line p-2 font-medium text-ink">{{ $day }}</div>
@endforeach
@foreach (range(8, 17) as $hour)
<div class="contents">
<div class="p-2 text-muted">{{ str_pad((string) $hour, 2, '0', STR_PAD_LEFT) }}:00</div>
@foreach ($days as $day)
<div class="m-1 h-8 rounded-md bg-subtle"></div>
@endforeach
</div>
@endforeach
</div>
</x-markas.scroll-area>import { ScrollArea } from "@/components/markas/ScrollArea";
const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
const hours = Array.from(
{ length: 10 },
(_, i) => `${String(i + 8).padStart(2, "0")}:00`,
);
export default function Example() {
return (
<ScrollArea
label="Weekly schedule"
orientation="both"
className="max-h-60 border border-line bg-surface"
>
<div className="grid w-[640px] grid-cols-[4rem_repeat(7,1fr)] text-sm">
<div className="border-b border-line p-2" />
{days.map((day) => (
<div
key={day}
className="border-b border-line p-2 font-medium text-ink"
>
{day}
</div>
))}
{hours.map((hour) => (
<div key={hour} className="contents">
<div className="p-2 text-muted">{hour}</div>
{days.map((day) => (
<div key={day} className="m-1 h-8 rounded-md bg-subtle" />
))}
</div>
))}
</div>
</ScrollArea>
);
}<script setup lang="ts">
import ScrollArea from "@/components/markas/ScrollArea.vue";
const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
const hours = Array.from(
{ length: 10 },
(_, i) => `${String(i + 8).padStart(2, "0")}:00`,
);
</script>
<template>
<ScrollArea
label="Weekly schedule"
orientation="both"
class="max-h-60 border border-line bg-surface"
>
<div class="grid w-[640px] grid-cols-[4rem_repeat(7,1fr)] text-sm">
<div class="border-b border-line p-2" />
<div
v-for="day in days"
:key="day"
class="border-b border-line p-2 font-medium text-ink"
>
{{ day }}
</div>
<div v-for="hour in hours" :key="hour" class="contents">
<div class="p-2 text-muted">{{ hour }}</div>
<div
v-for="day in days"
:key="day"
class="m-1 h-8 rounded-md bg-subtle"
/>
</div>
</div>
</ScrollArea>
</template><script lang="ts">
import ScrollArea from "$lib/components/markas/ScrollArea.svelte";
const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
const hours = Array.from(
{ length: 10 },
(_, i) => `${String(i + 8).padStart(2, "0")}:00`,
);
</script>
<ScrollArea
label="Weekly schedule"
orientation="both"
class="max-h-60 border border-line bg-surface"
>
<div class="grid w-[640px] grid-cols-[4rem_repeat(7,1fr)] text-sm">
<div class="border-b border-line p-2"></div>
{#each days as day (day)}
<div class="border-b border-line p-2 font-medium text-ink">{day}</div>
{/each}
{#each hours as hour (hour)}
<div class="contents">
<div class="p-2 text-muted">{hour}</div>
{#each days as day (day)}
<div class="m-1 h-8 rounded-md bg-subtle"></div>
{/each}
</div>
{/each}
</div>
</ScrollArea>---
import ScrollArea from "@/components/markas/ScrollArea.astro";
const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
const hours = Array.from(
{ length: 10 },
(_, i) => `${String(i + 8).padStart(2, "0")}:00`,
);
---
<ScrollArea
label="Weekly schedule"
orientation="both"
class="max-h-60 border border-line bg-surface"
>
<div class="grid w-[640px] grid-cols-[4rem_repeat(7,1fr)] text-sm">
<div class="border-b border-line p-2"></div>
{
days.map((day) => (
<div class="border-b border-line p-2 font-medium text-ink">{day}</div>
))
}
{
hours.map((hour) => (
<div class="contents">
<div class="p-2 text-muted">{hour}</div>
{days.map(() => (
<div class="m-1 h-8 rounded-md bg-subtle" />
))}
</div>
))
}
</div>
</ScrollArea>import { Component } from "@angular/core";
import { ScrollArea } from "./markas/scroll-area.component";
@Component({
selector: "markas-example",
imports: [ScrollArea],
template: `
<div
markas-scroll-area
label="Weekly schedule"
orientation="both"
class="max-h-60 border border-line bg-surface"
>
<div class="grid w-[640px] grid-cols-[4rem_repeat(7,1fr)] text-sm">
<div class="border-b border-line p-2"></div>
@for (day of days; track day) {
<div class="border-b border-line p-2 font-medium text-ink">
{{ day }}
</div>
}
@for (hour of hours; track hour) {
<div class="contents">
<div class="p-2 text-muted">{{ hour }}</div>
@for (day of days; track day) {
<div class="m-1 h-8 rounded-md bg-subtle"></div>
}
</div>
}
</div>
</div>
`,
})
export default class ScrollAreaBothExample {
protected readonly days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
protected readonly hours = Array.from(
{ length: 10 },
(_, i) => `${String(i + 8).padStart(2, "0")}:00`,
);
}In a card
Notifications
-
Dewi Lestari commented on Q3 roadmap
2m ago
-
Budi Santoso assigned you to Invoice export
15m ago
-
Siti Aminah shared Brand guidelines
1h ago
-
Rizky Pratama closed Login timeout bug
3h ago
-
Ayu Wulandari mentioned you in Weekly sync
Yesterday
-
Fajar Nugroho uploaded Pricing v2.pdf
2 days ago
Notifications
Dewi Lestari commented on Q3 roadmap
2m ago
Budi Santoso assigned you to Invoice export
15m ago
Siti Aminah shared Brand guidelines
1h ago
Rizky Pratama closed Login timeout bug
3h ago
Ayu Wulandari mentioned you in Weekly sync
Yesterday
Fajar Nugroho uploaded Pricing v2.pdf
2 days ago
Notifications
Dewi Lestari commented on Q3 roadmap
2m ago
Budi Santoso assigned you to Invoice export
15m ago
Siti Aminah shared Brand guidelines
1h ago
Rizky Pratama closed Login timeout bug
3h ago
Ayu Wulandari mentioned you in Weekly sync
Yesterday
Fajar Nugroho uploaded Pricing v2.pdf
2 days ago
Notifications
Dewi Lestari commented on Q3 roadmap
2m ago
Budi Santoso assigned you to Invoice export
15m ago
Siti Aminah shared Brand guidelines
1h ago
Rizky Pratama closed Login timeout bug
3h ago
Ayu Wulandari mentioned you in Weekly sync
Yesterday
Fajar Nugroho uploaded Pricing v2.pdf
2 days ago
Notifications
Dewi Lestari commented on Q3 roadmap
2m ago
Budi Santoso assigned you to Invoice export
15m ago
Siti Aminah shared Brand guidelines
1h ago
Rizky Pratama closed Login timeout bug
3h ago
Ayu Wulandari mentioned you in Weekly sync
Yesterday
Fajar Nugroho uploaded Pricing v2.pdf
2 days ago
@php
$notifications = [
['who' => 'Dewi Lestari', 'what' => 'commented on Q3 roadmap', 'when' => '2m ago'],
['who' => 'Budi Santoso', 'what' => 'assigned you to Invoice export', 'when' => '15m ago'],
['who' => 'Siti Aminah', 'what' => 'shared Brand guidelines', 'when' => '1h ago'],
['who' => 'Rizky Pratama', 'what' => 'closed Login timeout bug', 'when' => '3h ago'],
['who' => 'Ayu Wulandari', 'what' => 'mentioned you in Weekly sync', 'when' => 'Yesterday'],
['who' => 'Fajar Nugroho', 'what' => 'uploaded Pricing v2.pdf', 'when' => '2 days ago'],
];
@endphp
<div class="rounded-xl border border-line bg-surface">
<p class="border-b border-line px-4 py-3 text-sm font-medium text-ink">Notifications</p>
<x-markas.scroll-area label="Notifications" class="max-h-52 rounded-t-none">
<ul>
@foreach ($notifications as $item)
<li class="border-b border-line px-4 py-3 text-sm last:border-b-0">
<p class="text-ink"><span class="font-medium">{{ $item['who'] }}</span> {{ $item['what'] }}</p>
<p class="text-muted">{{ $item['when'] }}</p>
</li>
@endforeach
</ul>
</x-markas.scroll-area>
</div>import { ScrollArea } from "@/components/markas/ScrollArea";
const notifications = [
{ who: "Dewi Lestari", what: "commented on Q3 roadmap", when: "2m ago" },
{
who: "Budi Santoso",
what: "assigned you to Invoice export",
when: "15m ago",
},
{ who: "Siti Aminah", what: "shared Brand guidelines", when: "1h ago" },
{ who: "Rizky Pratama", what: "closed Login timeout bug", when: "3h ago" },
{
who: "Ayu Wulandari",
what: "mentioned you in Weekly sync",
when: "Yesterday",
},
{ who: "Fajar Nugroho", what: "uploaded Pricing v2.pdf", when: "2 days ago" },
];
export default function Example() {
return (
<div className="rounded-xl border border-line bg-surface">
<p className="border-b border-line px-4 py-3 text-sm font-medium text-ink">
Notifications
</p>
<ScrollArea label="Notifications" className="max-h-52 rounded-t-none">
<ul>
{notifications.map((item) => (
<li
key={item.who}
className="border-b border-line px-4 py-3 text-sm last:border-b-0"
>
<p className="text-ink">
<span className="font-medium">{item.who}</span> {item.what}
</p>
<p className="text-muted">{item.when}</p>
</li>
))}
</ul>
</ScrollArea>
</div>
);
}<script setup lang="ts">
import ScrollArea from "@/components/markas/ScrollArea.vue";
const notifications = [
{ who: "Dewi Lestari", what: "commented on Q3 roadmap", when: "2m ago" },
{
who: "Budi Santoso",
what: "assigned you to Invoice export",
when: "15m ago",
},
{ who: "Siti Aminah", what: "shared Brand guidelines", when: "1h ago" },
{ who: "Rizky Pratama", what: "closed Login timeout bug", when: "3h ago" },
{
who: "Ayu Wulandari",
what: "mentioned you in Weekly sync",
when: "Yesterday",
},
{ who: "Fajar Nugroho", what: "uploaded Pricing v2.pdf", when: "2 days ago" },
];
</script>
<template>
<div class="rounded-xl border border-line bg-surface">
<p class="border-b border-line px-4 py-3 text-sm font-medium text-ink">
Notifications
</p>
<ScrollArea label="Notifications" class="max-h-52 rounded-t-none">
<ul>
<li
v-for="item in notifications"
:key="item.who"
class="border-b border-line px-4 py-3 text-sm last:border-b-0"
>
<p class="text-ink">
<span class="font-medium">{{ item.who }}</span> {{ item.what }}
</p>
<p class="text-muted">{{ item.when }}</p>
</li>
</ul>
</ScrollArea>
</div>
</template><script lang="ts">
import ScrollArea from "$lib/components/markas/ScrollArea.svelte";
const notifications = [
{ who: "Dewi Lestari", what: "commented on Q3 roadmap", when: "2m ago" },
{
who: "Budi Santoso",
what: "assigned you to Invoice export",
when: "15m ago",
},
{ who: "Siti Aminah", what: "shared Brand guidelines", when: "1h ago" },
{ who: "Rizky Pratama", what: "closed Login timeout bug", when: "3h ago" },
{
who: "Ayu Wulandari",
what: "mentioned you in Weekly sync",
when: "Yesterday",
},
{
who: "Fajar Nugroho",
what: "uploaded Pricing v2.pdf",
when: "2 days ago",
},
];
</script>
<div class="rounded-xl border border-line bg-surface">
<p class="border-b border-line px-4 py-3 text-sm font-medium text-ink">
Notifications
</p>
<ScrollArea label="Notifications" class="max-h-52 rounded-t-none">
<ul>
{#each notifications as item (item.who)}
<li class="border-b border-line px-4 py-3 text-sm last:border-b-0">
<p class="text-ink">
<span class="font-medium">{item.who}</span>
{item.what}
</p>
<p class="text-muted">{item.when}</p>
</li>
{/each}
</ul>
</ScrollArea>
</div>---
import ScrollArea from "@/components/markas/ScrollArea.astro";
const notifications = [
{ who: "Dewi Lestari", what: "commented on Q3 roadmap", when: "2m ago" },
{
who: "Budi Santoso",
what: "assigned you to Invoice export",
when: "15m ago",
},
{ who: "Siti Aminah", what: "shared Brand guidelines", when: "1h ago" },
{ who: "Rizky Pratama", what: "closed Login timeout bug", when: "3h ago" },
{
who: "Ayu Wulandari",
what: "mentioned you in Weekly sync",
when: "Yesterday",
},
{ who: "Fajar Nugroho", what: "uploaded Pricing v2.pdf", when: "2 days ago" },
];
---
<div class="rounded-xl border border-line bg-surface">
<p class="border-b border-line px-4 py-3 text-sm font-medium text-ink">
Notifications
</p>
<ScrollArea label="Notifications" class="max-h-52 rounded-t-none">
<ul>
{
notifications.map((item) => (
<li class="border-b border-line px-4 py-3 text-sm last:border-b-0">
<p class="text-ink">
<span class="font-medium">{item.who}</span> {item.what}
</p>
<p class="text-muted">{item.when}</p>
</li>
))
}
</ul>
</ScrollArea>
</div>import { Component } from "@angular/core";
import { ScrollArea } from "./markas/scroll-area.component";
@Component({
selector: "markas-example",
imports: [ScrollArea],
template: `
<div class="rounded-xl border border-line bg-surface">
<p class="border-b border-line px-4 py-3 text-sm font-medium text-ink">
Notifications
</p>
<div
markas-scroll-area
label="Notifications"
class="max-h-52 rounded-t-none"
>
<ul>
@for (item of notifications; track item.who) {
<li class="border-b border-line px-4 py-3 text-sm last:border-b-0">
<p class="text-ink">
<span class="font-medium">{{ item.who }}</span> {{ item.what }}
</p>
<p class="text-muted">{{ item.when }}</p>
</li>
}
</ul>
</div>
</div>
`,
})
export default class ScrollAreaInCardExample {
protected readonly notifications = [
{ who: "Dewi Lestari", what: "commented on Q3 roadmap", when: "2m ago" },
{
who: "Budi Santoso",
what: "assigned you to Invoice export",
when: "15m ago",
},
{ who: "Siti Aminah", what: "shared Brand guidelines", when: "1h ago" },
{ who: "Rizky Pratama", what: "closed Login timeout bug", when: "3h ago" },
{
who: "Ayu Wulandari",
what: "mentioned you in Weekly sync",
when: "Yesterday",
},
{
who: "Fajar Nugroho",
what: "uploaded Pricing v2.pdf",
when: "2 days ago",
},
];
}Installation
npx markasui@latest add scroll-areapnpm dlx markasui@latest add scroll-areayarn dlx markasui@latest add scroll-areabunx --bun markasui@latest add scroll-area- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
resources/views/components/markas/scroll-area.blade.php.
@props([
'orientation' => 'vertical',
'label' => 'Scrollable content',
])
@php
$base = 'rounded-lg [scrollbar-color:var(--markas-line)_transparent] [scrollbar-width:thin] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-scrollbar]:size-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-line [&::-webkit-scrollbar-track]:bg-transparent';
$orientations = [
'vertical' => 'overflow-x-hidden overflow-y-auto',
'horizontal' => 'overflow-x-auto overflow-y-hidden',
'both' => 'overflow-auto',
];
@endphp
<div {{ $attributes->merge(['role' => 'region', 'aria-label' => $label, 'tabindex' => '0', 'data-orientation' => $orientation])->class([$base, $orientations[$orientation] ?? $orientations['vertical']]) }}>{{ $slot }}</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/ScrollArea.tsx.
import type { ComponentProps } from "react";
const base =
"rounded-lg [scrollbar-color:var(--markas-line)_transparent] [scrollbar-width:thin] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-scrollbar]:size-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-line [&::-webkit-scrollbar-track]:bg-transparent";
const orientations = {
vertical: "overflow-x-hidden overflow-y-auto",
horizontal: "overflow-x-auto overflow-y-hidden",
both: "overflow-auto",
};
const cx = (...c: (string | false | null | undefined)[]) =>
c.filter(Boolean).join(" ");
export type ScrollAreaProps = ComponentProps<"div"> & {
orientation?: keyof typeof orientations;
label?: string;
};
export function ScrollArea({
orientation = "vertical",
label = "Scrollable content",
className,
...props
}: ScrollAreaProps) {
return (
<div
role="region"
aria-label={label}
tabIndex={0}
data-orientation={orientation}
className={cx(base, orientations[orientation], className)}
{...props}
/>
);
}- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/ScrollArea.vue.
<script setup lang="ts">
const props = withDefaults(
defineProps<{
orientation?: "vertical" | "horizontal" | "both";
label?: string;
}>(),
{ orientation: "vertical", label: "Scrollable content" },
);
const base =
"rounded-lg [scrollbar-color:var(--markas-line)_transparent] [scrollbar-width:thin] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-scrollbar]:size-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-line [&::-webkit-scrollbar-track]:bg-transparent";
const orientations = {
vertical: "overflow-x-hidden overflow-y-auto",
horizontal: "overflow-x-auto overflow-y-hidden",
both: "overflow-auto",
};
</script>
<template>
<div
role="region"
:aria-label="props.label"
tabindex="0"
:data-orientation="props.orientation"
:class="[base, orientations[props.orientation]]"
>
<slot />
</div>
</template>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/ScrollArea.svelte.
<script lang="ts">
import type { Snippet } from "svelte";
import type { HTMLAttributes } from "svelte/elements";
const base =
"rounded-lg [scrollbar-color:var(--markas-line)_transparent] [scrollbar-width:thin] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-scrollbar]:size-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-line [&::-webkit-scrollbar-track]:bg-transparent";
const orientations = {
vertical: "overflow-x-hidden overflow-y-auto",
horizontal: "overflow-x-auto overflow-y-hidden",
both: "overflow-auto",
};
type Props = HTMLAttributes<HTMLDivElement> & {
orientation?: keyof typeof orientations;
/** Accessible name of the scrollable region. */
label?: string;
children?: Snippet;
};
let {
orientation = "vertical",
label = "Scrollable content",
class: className,
children,
...rest
}: Props = $props();
</script>
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<div
role="region"
aria-label={label}
tabindex="0"
data-orientation={orientation}
class={[base, orientations[orientation], className]}
{...rest}
>
{@render children?.()}
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/ScrollArea.astro.
---
import type { HTMLAttributes } from "astro/types";
const base =
"rounded-lg [scrollbar-color:var(--markas-line)_transparent] [scrollbar-width:thin] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-scrollbar]:size-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-line [&::-webkit-scrollbar-track]:bg-transparent";
const orientations = {
vertical: "overflow-x-hidden overflow-y-auto",
horizontal: "overflow-x-auto overflow-y-hidden",
both: "overflow-auto",
};
type Props = HTMLAttributes<"div"> & {
orientation?: keyof typeof orientations;
/** Accessible name of the scrollable region. */
label?: string;
};
const {
orientation = "vertical",
label = "Scrollable content",
class: className,
...rest
} = Astro.props;
---
<div
role="region"
aria-label={label}
tabindex="0"
data-orientation={orientation}
class:list={[base, orientations[orientation], className]}
{...rest}
>
<slot />
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/scroll-area.component.ts.
import {
ChangeDetectionStrategy,
Component,
computed,
input,
} from "@angular/core";
const base =
"rounded-lg [scrollbar-color:var(--markas-line)_transparent] [scrollbar-width:thin] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-scrollbar]:size-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-line [&::-webkit-scrollbar-track]:bg-transparent";
const orientations = {
vertical: "overflow-x-hidden overflow-y-auto",
horizontal: "overflow-x-auto overflow-y-hidden",
both: "overflow-auto",
};
export type ScrollAreaOrientation = keyof typeof orientations;
/**
* Attribute selector on a native div, so the user's class and attributes stay on the region.
* Usage: `<div markas-scroll-area label="Releases">...</div>`.
*/
@Component({
selector: "div[markas-scroll-area]",
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
role: "region",
tabindex: "0",
"[attr.aria-label]": "label()",
"[attr.data-orientation]": "orientation()",
"[class]": "classes()",
},
template: `<ng-content />`,
})
export class ScrollArea {
readonly orientation = input<ScrollAreaOrientation>("vertical");
/** Accessible name of the scrollable region. */
readonly label = input("Scrollable content");
protected readonly classes = computed(
() => `${base} ${orientations[this.orientation()]}`,
);
}Usage
<x-markas.scroll-area label="Releases" class="max-h-56 border border-line">
<div class="p-4">...</div>
</x-markas.scroll-area>import { ScrollArea } from "@/components/markas/ScrollArea";
<ScrollArea label="Releases" className="max-h-56 border border-line">
<div className="p-4">...</div>
</ScrollArea>;<template>
<ScrollArea label="Releases" class="max-h-56 border border-line">
<div class="p-4">...</div>
</ScrollArea>
</template><script lang="ts">
import ScrollArea from "$lib/components/markas/ScrollArea.svelte";
</script>
<ScrollArea label="Releases" class="max-h-56 border border-line">
<div class="p-4">...</div>
</ScrollArea>---
import ScrollArea from "@/components/markas/ScrollArea.astro";
---
<ScrollArea label="Releases" class="max-h-56 border border-line">
<div class="p-4">...</div>
</ScrollArea>import { Component } from "@angular/core";
import { ScrollArea } from "./markas/scroll-area.component";
@Component({
selector: "app-example",
imports: [ScrollArea],
template: `
<div
markas-scroll-area
label="Releases"
class="max-h-56 border border-line"
>
<div class="p-4">...</div>
</div>
`,
})
export class Example {}Angular uses an attribute selector on a native div, so the size classes stay on the region.
- Set the size limit with a class such as
max-h-56ormax-w-sm. Without it nothing scrolls. - Use
orientation="horizontal"for a row of cards andorientation="both"for wide grids. - The scrollbar is native, only thinner and in token colors, so no JavaScript is needed.
Props
| Name | Type | Default | Description |
|---|---|---|---|
orientation | "vertical" | "horizontal" | "both" | "vertical" | Direction the content can scroll. The other direction is clipped unless you pick both. |
label | string | Scrollable content | Accessible name of the region. Describe the content, for example Releases. |
class | string | - | Set the size limit here, for example max-h-64 or max-w-sm, plus any border or background. |
Accessibility
- Uses role=region with aria-label so screen reader users can find and identify the scrollable area.
- Has tabindex=0, so keyboard users can focus it and scroll with the arrow keys, Page Up, and Page Down.
- Shows a visible focus outline and keeps the native scrollbar, only thinner and in token colors.
Related components
More data components with the same classes in every framework.
- AvatarRound profile photo in three sizes, with name initials as a fallback when the image is empty or fails to load.
- CardCard that groups content with an optional title, description, body, and footer.
- CarouselRow of slides built on CSS scroll snap, with previous and next buttons, optional dots, and arrow key navigation. No autoplay.
- Code BlockMonospace code block with an optional file name, line numbers, and a copy button. Plain text, no syntax highlighting.
- KbdKeycap for keyboard shortcuts using the native kbd element, in two sizes, with key combinations rendered as separate keys.
- SeparatorHorizontal or vertical dividing line, decorative by default, with an optional label in the middle such as "or".