Scroll Area

View as Markdown

A box that scrolls with a thin themed scrollbar and edges that fade where there's more.

60 members

When to use

A box that scrolls with a thin themed scrollbar and edges that fade where there's more. Use Resizable Panels instead when people should choose how much room the content gets.

Usage

import { ScrollArea } from "./ui/uicontext/components/ScrollArea.ts"
const styles = stylex.create({ box: { maxBlockSize: 240 } })export const Channels = <M>(h: Html.H<M>, names: ReadonlyArray<string>) =>	ScrollArea(h, { label: "Channels", style: styles.box, children: [h.ul.children(names.map((n) => h.li.key(n).children(n)))] })

Examples

Sideways

orientation: "horizontal" scrolls a wide table inside a narrow card; the edge fades where there's more.

API reference

Options

ScrollArea options
NameTypeDefaultDescription
keystring—Names the area among others in the same view; needed for more than one.
labelstring—What the area holds, for screen readers when it takes focus: "Members".
orientation"vertical" | "horizontal" | "both"verticalWhich way it scrolls; vertical by default.
fadebooleanonFade the edges where there's more to scroll to; on by default.
childrenrequiredView.Children——
styleStyle—StyleX styles for the box: its height or max height, a border, a radius.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/scroll-area

Source