Scroll Area
Kontainer bergulir dengan scrollbar tipis berwarna token yang bisa difokus dan digulir lewat keyboard. Tanpa 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`,
);
}Contoh
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",
];
}Dua arah
@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`,
);
}Dalam kartu
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",
},
];
}Instalasi
npx markasui@latest add scroll-areapnpm dlx markasui@latest add scroll-areayarn dlx markasui@latest add scroll-areabunx --bun markasui@latest add scroll-area- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
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>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
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}
/>
);
}- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
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>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
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>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
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>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
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()]}`,
);
}Pemakaian
<x-markas.scroll-area label="Rilis" class="max-h-56 border border-line">
<div class="p-4">...</div>
</x-markas.scroll-area>import { ScrollArea } from "@/components/markas/ScrollArea";
<ScrollArea label="Rilis" className="max-h-56 border border-line">
<div className="p-4">...</div>
</ScrollArea>;<template>
<ScrollArea label="Rilis" 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 memakai attribute selector pada div native, jadi class ukuran tetap di region.
- Atur batas ukuran dengan class seperti
max-h-56ataumax-w-sm. Tanpa itu tidak ada yang tergulir. - Pakai
orientation="horizontal"untuk deretan kartu danorientation="both"untuk grid yang lebar. - Label default “Scrollable content”. Isi
labeldalam Bahasa Indonesia sesuai isi area. - Scrollbar tetap native, hanya lebih tipis dan berwarna token, jadi tidak butuh JavaScript.
Props
| Nama | Tipe | Default | Keterangan |
|---|---|---|---|
orientation | "vertical" | "horizontal" | "both" | "vertical" | Arah konten bisa digulir. Arah lainnya dipotong kecuali memilih both. |
label | string | Scrollable content | Nama aksesibel region. Jelaskan isinya, misalnya Rilis. |
class | string | - | Atur batas ukuran di sini, misalnya max-h-64 atau max-w-sm, beserta border atau latar. |
Aksesibilitas
- Memakai role=region dengan aria-label sehingga pengguna pembaca layar bisa menemukan dan mengenali area bergulir.
- Punya tabindex=0, jadi pengguna keyboard bisa memfokusnya lalu menggulir dengan panah, Page Up, dan Page Down.
- Menampilkan outline fokus yang jelas dan tetap memakai scrollbar native, hanya lebih tipis dan berwarna token.
Komponen terkait
Komponen data lain dengan class yang sama di setiap framework.
- AvatarFoto profil bulat dengan tiga ukuran dan inisial nama sebagai fallback saat gambar kosong atau gagal dimuat.
- CardKartu untuk mengelompokkan konten dengan judul, deskripsi, isi, dan footer opsional.
- CarouselDeretan slide berbasis CSS scroll snap dengan tombol sebelumnya dan berikutnya, titik opsional, dan navigasi panah. Tanpa autoplay.
- Code BlockBlok kode monospace dengan nama file opsional, nomor baris, dan tombol salin. Teks polos tanpa pewarnaan sintaks.
- KbdKeycap untuk shortcut keyboard memakai elemen kbd native, dua ukuran, dengan kombinasi tombol dirender sebagai keycap terpisah.
- SeparatorGaris pemisah horizontal atau vertikal, dekoratif secara default, dengan label opsional di tengah garis seperti "atau".