Most scrolling areas need no component: the native scrollbar CSS on the Code tab styles them. Use the Scroll area when you need the bar drawn by Vue, for example to keep it the same on every system. Install it with npx shadcn-vue@latest add https://beehexa.design/r/scroll-area.json.
A long list
ScrollAreaList.vue
<script setup lang="ts">
import { ScrollArea } from '@/components/ui/scroll-area'
import { Separator } from '@/components/ui/separator'
const skus = Array.from({ length: 40 }, (_, i) => `SKU-${String(1000 + i * 7)}`)
</script>
<template>
<!-- A bounded height; the bar appears while the pointer is over the area. Nothing in the list can take focus,
so the list itself does (tabindex, for scrolling with the arrow keys) and has a name. -->
<ScrollArea class="h-56 w-full max-w-60 rounded-(--bh-radius-card) border-(length:--bh-border-width-default) border-(--bh-color-border) bg-(--bh-color-surface)">
<div tabindex="0" role="region" aria-label="Products to sync" class="p-(--bh-space-150) [font:var(--bh-font-body-default)] text-(--bh-color-text)">
<div class="mb-(--bh-space-100) [font:var(--bh-font-heading-xsmall)]">Products to sync (40)</div>
<template v-for="(sku, index) in skus" :key="sku">
<Separator v-if="index > 0" class="my-(--bh-space-100)" />
<div class="[font:var(--bh-font-code-default)]">{{ sku }}</div>
</template>
</div>
</ScrollArea>
</template>Scrolling sideways
ScrollAreaHorizontal.vue
<script setup lang="ts">
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area'
const channels = ['Online store', 'Point of sale', 'Marketplace', 'ERP', 'CRM', 'Warehouse']
</script>
<template>
<!-- A horizontal bar: add <ScrollBar orientation="horizontal" />. The cards are links, so keyboard users reach them with Tab. -->
<ScrollArea class="w-full max-w-120 whitespace-nowrap rounded-(--bh-radius-card) border-(length:--bh-border-width-default) border-(--bh-color-border) bg-(--bh-color-surface)">
<div class="flex w-max gap-(--bh-space-150) p-(--bh-space-150)">
<a
v-for="channel in channels"
:key="channel"
href="#channel"
class="flex h-(--bh-space-1000) w-40 shrink-0 items-end rounded-(--bh-radius-card) bg-(--bh-color-surface-subtle) p-(--bh-space-150) text-(--bh-color-text) [font:var(--bh-font-label-default)] no-underline outline-none focus-visible:outline-solid focus-visible:outline-(length:--bh-border-width-focused) focus-visible:outline-(color:--bh-color-border-focus) focus-visible:-outline-offset-(--bh-border-width-focused)"
>{{ channel }}</a>
</div>
<ScrollBar orientation="horizontal" />
</ScrollArea>
</template>