npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unocss-scrollbar-variant

v0.58.0

Published

scrollbar preset for UnoCSS

Downloads

1,530

Readme

unocss-scrollbar-variant

Scrollbar Preset for UnoCSS. Allows unocss utility classes to be used on scrollbars using variants. This also adds rules to level 1 CSS scrollbar styling (for firefox compatibility).

Installation

pnpm add unocss-scrollbar-variant -D

Usage

// unocss.config.js
import { defineConfig, presetUno } from 'unocss'
import { presetScrollbar } from 'unocss-scrollbar-variant'

export default defineConfig({
  presets: [
    presetUno(), // required
    presetScrollbar(),
  ],
})
<div class="overflow-auto
  scrollbar:w-2
  scrollbar:h-2
  scrollbar-thin
  scrollbar-thumb:rounded
  scrollbar-track:bg-gray-200
  scrollbar-thumb:bg-gray-400
  scrollbar-track-gray-200
  scrollbar-thumb-gray-400
  hover:scrollbar-thumb:bg-gray-600
  hover:scrollbar-thumb-gray-600">
</div>

Utility | Webkit (Chrome) | CSS Level 1 (Firefox) -------------------- | ---------------------------- | --------------------- w-2 | scrollbar:w-2 | scrollbar-thin h-2 | scrollbar:h-2 | scrollbar-thin bg-{color} (thumb) | scrollbar-thumb:bg-{color} | scrollbar-thumb-{color} bg-{color} (track) | scrollbar-track:bg-{color} | scrollbar-track-{color} rounded (thumb) | scrollbar-thumb:rounded | N/A border (thumb) | scrollbar-thumb:border-1 | N/A rounded left (thumb) | scrollbar-thumb:rounded-l | N/A any unocss utility | scrollbar-{part}:{utility} | N/A

Due to CSS limitations firefox can only adjust the thumb and track color and their widths.

Variants

These variants allow adjustment of any scrollbar element in a webkit browser.

Variant | Element ------------------------ | ------------------- scrollbar: | the whole scrollbar resizer: | resizer handle scrollbar-track: | scrollbar track scrollbar-track-piece: | scrollbar track piece scrollbar-thumb: | scrollbar thumb scrollbar-corner: | scrollbar corner scrollbar-button: | scrollbar button

Rules

The rules adjust scrollbars in CSS level 1 compliant browsers (firefox). They are severly limited compared to webkit's implementation.

Rule | Application ------------------------- | --------------- scrollbar-thin | scrollbar width scrollbar-none | scrollbar width scrollbar-auto | scrollbar width scrollbar-thumb-{color} | unocss color applied to the thumb scrollbar-track-{color} | unocss color applied to the track

Cross Browser Shortcut Examples

[
  { 'scrollbar-thin-all': `scrollbar:w-2 scrollbar:h-2 scrollbar-thin` },
  [
    /^scrollbar-bg-(track|thumb)-(.*)$/,
    ([, section, color]) => `scrollbar-${section}:bg-${color} scrollbar-${section}-${color}`
  ],
]

Shortcut | Application ---------------------------- | ----------- scrollbar-thin-all | scrollbar:w-2 scrollbar:h-2 scrollbar-thin scrollbar-bg-track-{color} | scrollbar-track:bg-{color} scrollbar-track-{color} scrollbar-bg-thumb-{color} | scrollbar-thumb:bg-{color} scrollbar-thumb-{color}

These shortcuts allows the initial 10 class example to be changed to the following 5 classes

<div class="overflow-auto
  scrollbar-thumb:rounded
  scrollbar-thin-all
  scrollbar-bg-track-gray-200
  scrollbar-bg-thumb-gray-400
  hover:scrollbar-bg-thumb-gray-600">
</div>

Note: The rounded thumb part only applies to webkit based browsers

Useful Standard Variants

It is likely you wish to style every scrollbar on your site the same. To accomplish this easily you can chain standard variants similar to the hover variant in the example. Of specific note, the all variant E.G.

all:scrollbar-track:bg-gray-200