sdxc

[ @sdxc/u/overflow ]

thinScrollbar

Requests a thin scrollbar that reserves its gutter up front, so layout stays put whether or not the scrollbar is showing.

import { thinScrollbar } from "@sdxc/u/overflow";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.thinScrollbar()css({ scrollbarWidth: "thin", scrollbarGutter: "stable" })

Examples

Basic example

Use thinScrollbar() with scroll("y") to ask for a thin scrollbar whose gutter is reserved up front. Compare it with the default one beside it:

This paragraph is taller than its box, so the last lines of it do not fit. Scroll to read the rest, while the page around the box stays exactly where it is.

This paragraph is taller than its box, so the last lines of it do not fit. Scroll to read the rest, while the page around the box stays exactly where it is.

<div mix={[...]}>
	<div mix={[scroll("y"), thinScrollbar(), bs(32), is(56), ...]}>
		<p mix={[...]}>
			This paragraph is taller than its box, so the last lines of it do not fit. Scroll to read
			the rest, while the page around the box stays exactly where it is.
		</p>
	</div>
	<div mix={[scroll("y"), bs(32), is(56), ...]}>
		<p mix={[...]}>
			This paragraph is taller than its box, so the last lines of it do not fit. Scroll to read
			the rest, while the page around the box stays exactly where it is.
		</p>
	</div>
</div>

Applying on a state

Wrap the call in a state utility to scope it to one selector.

u.hover(u.thinScrollbar())

Responsive design

Wrap the call in a container query to scope it to one width.

u.at("md", u.thinScrollbar())

Signature

u.thinScrollbar()

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.