Scrollbar
The browser's own scrollbars in your style's look — every scrollbar of the page: the page's, a list, a textarea, a code block, a widget you didn't write. One CSS file, no directive; tuned by variables, your classes win.
Usage
Import the rules and your style's variables in your global stylesheet, after Tailwind: @import '@semantic-components/styles/scrollbar.css'; and @import '@semantic-components/styles/nova/scrollbar-variables.css'; (your style's). Then any box that scrolls has the look — no class, no directive.
import { Component, ViewEncapsulation } from '@angular/core';import { ScFrame } from '@semantic-components/ui';
/** * A plain box that scrolls: no directive. With scrollbar.css imported, its * scrollbar is the style's — as every scrollbar of the page. */@Component({ selector: 'app-scrollbar-usage-demo', imports: [ScFrame], template: ` <div tabindex="0" role="region" aria-label="Tags" scFrame class="h-72 w-48 overflow-auto p-4" > <p class="mb-4 text-sm leading-none font-medium">Tags</p> @for (tag of tags; track tag) { <div class="border-b py-2 text-sm">{{ tag }}</div> } </div> `, host: { class: 'flex w-full justify-center' }, encapsulation: ViewEncapsulation.None,})export class ScrollbarUsageDemo { private readonly tags = Array.from( { length: 50 }, (_, i) => `v1.2.0-beta.${50 - i}`, );}The Scroll Area, or this file?
- This file: every scrollbar, with nothing to write. The browser draws them, so they have its limits: Firefox takes a thin bar in your colours only (no exact size, no corners), and where the system's scrollbars take room (Windows, Linux) the bar sits beside the content, not over it.
- The Scroll Area (
scScrollArea): a box whose scrollbars are drawn — shadcn's look in every browser, over the content.
Examples
Tuning
import { Component, ViewEncapsulation } from '@angular/core';import { ScFrame } from '@semantic-components/ui';
/** * The variables on a box: its scrollbars, and those inside it. On :root, * the whole page's. */@Component({ selector: 'app-tuning-scrollbar-demo', imports: [ScFrame],Opting out
import { Component, ViewEncapsulation } from '@angular/core';import { ScFrame } from '@semantic-components/ui';
/** * Utilities on a box: no scrollbar, its room kept, or the browser's own bar * back (scrollbar-thin, or any scrollbar-color, does that in Chromium). */@Component({ selector: 'app-opting-out-scrollbar-demo', imports: [ScFrame],Accessibility
- Only the look changes: the scrollbars are the browser's, and so is scrolling — the wheel, touch, the keyboard, a screen reader's.
- A box that scrolls is reached by the keyboard when it can take focus: give it
tabindex="0", a role and a name, as these demos do.
API reference
Variables
On :root for the whole page, or on a box for its scrollbars and those inside it. The style's file sets the thumb and its corners.
| Variable | Default | Description |
|---|---|---|
--sc-scrollbar-size | 0.625rem | The bar's thickness (not in Firefox: its thin bar). |
--sc-scrollbar-inset | 1px | Room around the thumb, inside the bar. |
--sc-scrollbar-thumb | var(--color-muted-foreground) | The thumb's colour: 3:1 on the page, as WCAG asks of a scrollbar the page styles (shadcn's border colour is 1.3:1). |
--sc-scrollbar-track | color-mix(in oklab, var(--color-foreground) 12%, transparent) | The track's colour, and the corner's: Base UI's, the foreground at 12% — the area the thumb moves in (shadcn draws none). |
--sc-scrollbar-radius | round (lyra, sera: 0) | The thumb's corners (not in Firefox). |
Classes
Tailwind's and shadcn's utilities, not ours: the file is in the base layer, so they win.
| Class | Description |
|---|---|
no-scrollbar, scrollbar-none | No scrollbar: the box still scrolls (the wheel, touch, the keyboard). |
scrollbar-gutter-stable | The scrollbar's room kept, so the content doesn't shift when it comes and goes. |
scrollbar-thin, scrollbar-thumb-* | The browser's own scrollbar back: in Chromium, a box whose scrollbar-width or scrollbar-color isn't auto isn't drawn by this file (scrollbar-auto is auto: it changes nothing). |