Skip to content

ScrollArea

A themed scrollable region, built on Reka UI's ScrollArea primitive.

Usage

Scrollable line 1

Scrollable line 2

Scrollable line 3

Scrollable line 4

Scrollable line 5

Scrollable line 6

Scrollable line 7

Scrollable line 8

Scrollable line 9

Scrollable line 10

Scrollable line 11

Scrollable line 12

Scrollable line 13

Scrollable line 14

Scrollable line 15

vue-html
<SScrollArea class="h-32">
  <div class="flex flex-col gap-2 p-3">
    <p v-for="i in 15" :key="i">Line {{ i }}</p>
  </div>
</SScrollArea>

Give it a height via class (fallthrough) - SScrollArea fills whatever box it's placed in. PageAside uses this internally for its scrollable body.

Programmatic scrolling

The component ref exposes viewport, the HTML element that scrolls. Use it after mount, for example from a click handler.

vue
<script setup lang="ts">
const area = useTemplateRef('area')

function scrollToBottom() {
  const viewport = area.value?.viewport
  viewport?.scrollTo({ top: viewport.scrollHeight })
}
</script>

<template>
  <SScrollArea ref="area" class="h-32">
    <p v-for="i in 15" :key="i">
      Line {{ i }}
    </p>
  </SScrollArea>
  <SButton @click="scrollToBottom">
    Jump to bottom
  </SButton>
</template>

Custom :ui

To see exactly what you'd be overriding - the current default classes for every slot - here's ScrollArea's own theme file:

Global and scoped theme recipes use ui.scrollArea.

Theme source "scroll-area" not found

Props

PropTypeDefault
orientation'vertical' | 'horizontal' | 'both''vertical'
type'auto' | 'always' | 'scroll' | 'hover' | 'glimpse''hover'
scrollHideDelaynumber600 ms
dir'ltr' | 'rtl'Inherited
uiPartial<Record<ScrollAreaSlot, string | object>>-

Set app-wide defaults for type, scrollHideDelay, and dir in app.config.selaras.defaults.scrollArea.

Slots

SlotDescription
defaultScrollable content