techniq / svelte-ux

Collection of Svelte components, actions, stores, and utilities to build highly interactive applications.
https://svelte-ux.techniq.dev/
MIT License
822 stars 46 forks source link

Scrollbar styling (globally or util class) #122

Open techniq opened 1 year ago

techniq commented 1 year ago

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:

on Chrome/Safari, and

on Firefox.

See docs for reference and additional properties

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 commented 1 year ago

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).