Skip to main content
Copy for LLM

Scrollbar

The .wk-scrollbar CSS class applies a slim, themed scrollbar to any scrollable element. It uses WireKit's design tokens so the scrollbar automatically matches your theme — including dark mode.

When to Use

Use .wk-scrollbar when a scrollable region is part of your UI design — a sidebar nav, a fixed-height panel, a chat history, a code block, a comment thread. The styled scrollbar reinforces the component's boundaries and stays consistent across OS chrome (macOS hides scrollbars by default, Windows shows thick ones — .wk-scrollbar equalizes both).

Don't use .wk-scrollbar on the page-level <html> or <body> scroll unless you're building a hard-scoped embedded widget — the browser's native scrollbar carries OS-level accessibility affordances (touch handles, high-contrast modes) that users expect to be untouched.

Don't use it as a general reset. The class is opt-in per element. If you want project-wide styled scrollbars, apply it to a specific layout container (e.g. your app's <main>), not globally.

Usage

Add the wk-scrollbar class to any element with overflow scrolling:

<div class="wk-scrollbar overflow-auto max-h-64">
    <!-- long content here -->
</div>

Works on any scrollable container — overflow-auto, overflow-x-auto, overflow-y-auto, or overflow-scroll.

API Surface

Scrollbar is a CSS-only utility class, not a Blade component — there are no props to pass, no PHP class, and no Blade tag. You apply .wk-scrollbar to any HTML element that scrolls. All customization happens via the CSS variables listed under "Design Tokens" below.

What you configure How
Width / color / hover color Design tokens (CSS variables)
Which element gets styled Add class="wk-scrollbar" to the element
Orientation (horizontal / vertical) Standard overflow-x-* / overflow-y-* Tailwind utilities
Conditional styling Combine with any other Tailwind class, responsive variants, etc.

Examples

Vertical Scroll

Vertical scrollable container
Mon 08:12 — Order received Mon 08:40 — Payment confirmed Mon 11:05 — Packed at the warehouse in Leipzig Mon 16:30 — Handed to the carrier Mon 21:15 — Arrived at the sorting center Tue 04:50 — Left the sorting center Tue 07:20 — Arrived at the delivery depot Tue 08:05 — Out for delivery Tue 10:42 — Delivery attempted, nobody at home Tue 10:45 — Left at the parcel shop on Main Street Wed 09:10 — Reminder sent by email Wed 17:32 — Collected at the parcel shop

Horizontal Scroll

Horizontal scrollable container
php artisan wirekit:csp-audit --path=resources/views/livewire --path=resources/views/components --path=resources/views/layouts --vendor

Textarea

<x-wirekit::textarea label="Notes" class="wk-scrollbar" rows="4">
    Long content that overflows vertically...
</x-wirekit::textarea>

How It Works

The class provides cross-browser scrollbar styling:

Browser Mechanism What the tokens set
Firefox, Chrome / Edge 121+, Safari 26.2+ scrollbar-width: thin + scrollbar-color A thin scrollbar in the thumb and track colors
Chrome / Edge 111–120, Safari 16.4–26.1 ::-webkit-scrollbar pseudo-elements Width, thumb and track colors, a rounded thumb and the hover color

A browser that supports scrollbar-color lets the two standard properties override the ::-webkit-scrollbar pseudo-elements, so --size-wk-scrollbar and --color-wk-scrollbar-thumb-hover apply only in the browsers of the second row. The thin scrollbar keeps the platform's own behavior, an overlay scrollbar on macOS among it.

Without the Class

The .wk-scrollbar class is opt-in. Elements without it use the browser's default scrollbar. WireKit does not override scrollbars globally — you choose where to apply the styling.

The WireKit docs site does apply .wk-scrollbar at the document level, on <html> and <body>. That is a showcase decision — a styled scrollbar is part of what the site exists to demonstrate — and it is deliberately the opposite of the guidance at the top of this page, which stands for your application: the OS scrollbar carries affordances your readers rely on.

It has a second effect worth knowing about before you copy it. WireKit's reduced-motion rule is scoped to [class^="wk-"] *, so putting a wk- class on a root element makes every element in the document a descendant of one — and the clamp then reaches your own animations too, not just WireKit's. Under a reduce preference, a plain <div> of your own carrying animation: spin 2s anywhere in <body> runs for the stylesheet's 1ms.

If you want the look without the reach, use the CSS variables directly in your own scrollbar styles, or put the class on the scroll containers that need it rather than on a root.

Accessibility

  • Custom scrollbars do not alter keyboard behavior — Tab focuses the scrollable element if it is keyboard-focusable, and the browser handles Arrow, PageUp/Down, Home/End, Space scrolling natively
  • No ARIA attributes are added — scrollbars are browser chrome; announcing them via ARIA would be redundant
  • When a scrollable region contains important content that is off-screen on load, wrap it in a landmark so screen readers can locate it: <section aria-label="Changelog" class="wk-scrollbar overflow-y-auto">…</section>
  • Firefox's scrollbar-width: thin respects OS-level "always show scrollbars" accessibility settings — this component does not force-hide scrollbars
  • At high zoom a container capped with a fixed max-height can hold only a line or two of what the reader scrolls through. WCAG 1.4.10: Reflow asks for content that works at 320 CSS pixels wide, 400% zoom on a 1280px screen: cap such a container relative to the viewport, or not at all

Keyboard Interaction

This component is purely presentational and does not respond to keyboard input.

Design Tokens

All scrollbar properties are customizable via CSS variables:

Variable Light Default Dark Default Description
--color-wk-scrollbar-thumb neutral-300 neutral-600 Thumb (draggable part) color
--color-wk-scrollbar-thumb-hover neutral-400 neutral-500 Thumb color on hover, where the ::-webkit-scrollbar pseudo-elements apply
--color-wk-scrollbar-track transparent transparent Track (background) color
--size-wk-scrollbar 6px 6px Width and height of the scrollbar, where the ::-webkit-scrollbar pseudo-elements apply; elsewhere the scrollbar is the browser's thin one

Customization

Override the tokens in your app.css to match your brand:

:root {
    /* Wider scrollbar with visible track */
    --size-wk-scrollbar: 8px;
    --color-wk-scrollbar-track: var(--color-wk-bg-subtle);

    /* Accent-colored thumb */
    --color-wk-scrollbar-thumb: var(--color-wk-accent);
    --color-wk-scrollbar-thumb-hover: var(--color-wk-accent-hover);
}

Updated in WireKit v2.58.0 (2026-09-28)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store