svelte-ux icon indicating copy to clipboard operation
svelte-ux copied to clipboard

Scrollbar styling (globally or util class)

Open techniq opened this issue 1 year ago • 1 comments

We currently have (.scrollbar-none) to completely hide the scrollbar, but it would be nice to also have some better styling (possibly globally, but at least opt-in).

Styling the scrollbar is setting:

  • ::-webkit-scrollbar
  • ::-webkit-scrollbar-thumb
  • ::-webkit-scrollbar-track

on Chrome/Safari, and

  • scrollbar-color
  • scrollbar-width

on Firefox.

See docs for reference and additional properties

  • https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_scrollbars_styling
  • https://css-tricks.com/almanac/properties/s/scrollbar/

I have an old REPL that can also be used as reference.

.scrollContainer {
	scrollbar-color: var(--scrollcolor) var(--scrollbackground);
}
.scrollContainer::-webkit-scrollbar {
	height: 0.5rem;
	width: 0.5rem;
	border-radius: 1rem;
	background: var(--scrollbackground);
}

.scrollContainer::-webkit-scrollbar-thumb {
	border-radius: 1rem;
	background: var(--scrollcolor);
}

.scrollContainer::-webkit-scrollbar-track {
	border-radius: 1rem;
	background: var(--scrollbackground);
}

See also:

techniq avatar Nov 11 '23 17:11 techniq

Appears Skeleton sets this globally with CSS variables (and I've been working on #66 and determining which variables to expose), so this will be helpful for reference.

image

Would like to see if others do this globally (it didn't appear shadcn/ui does, but that's not surprising based on how they implement things).

techniq avatar Nov 11 '23 17:11 techniq