On this page

Scrollbar

Live examples of the shadcn-vue Scroll area, whose bars use the scrollbar tokens.

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

Products to sync (40)
SKU-1000
SKU-1007
SKU-1014
SKU-1021
SKU-1028
SKU-1035
SKU-1042
SKU-1049
SKU-1056
SKU-1063
SKU-1070
SKU-1077
SKU-1084
SKU-1091
SKU-1098
SKU-1105
SKU-1112
SKU-1119
SKU-1126
SKU-1133
SKU-1140
SKU-1147
SKU-1154
SKU-1161
SKU-1168
SKU-1175
SKU-1182
SKU-1189
SKU-1196
SKU-1203
SKU-1210
SKU-1217
SKU-1224
SKU-1231
SKU-1238
SKU-1245
SKU-1252
SKU-1259
SKU-1266
SKU-1273
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>