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

@raulscoelho/tailwind-scrollbar

v1.1.3

Published

A Tailwind CSS plugin to customize the appearance of scrollbars with utility classes. Easily style scrollbar colors, widths, and track properties to enhance the user experience.

Downloads

10

Readme

@raulscoelho/tailwind-scrollbar

Installation

yarn add @raulscoelho/tailwind-scrollbar
# or
npm i @raulscoelho/tailwind-scrollbar

Usage

To use the @raulscoelho/tailwind-scrollbar plugin, you need to add it to your Tailwind CSS configuration file.

Step 1: Configure Tailwind CSS

Add the plugin to your tailwind.config.ts file:

import type { Config } from 'tailwindcss'
import { tailwindScrollbar } from '@raulscoelho/tailwind-scrollbar'

const config: Config = {
  // other configurations...
  plugins: [
    tailwindScrollbar()
  ]
}

export default config

Step 2: Customize the Configuration (Optional)

You can customize the scrollbar by passing a configuration object to the plugin. The configuration object can contain colors and layout properties to define the appearance of the scrollbar.

Colors Configuration

The colors property allows you to define custom colors for the scrollbar thumb and track.

const colors = {
  thumb: '#e4e4e7', // color for the scrollbar thumb
  thumbHover: '#d4d4d8', // color for the scrollbar thumb on hover
  thumbActive: '#a1a1aa', // color for the scrollbar thumb on active
  track: '#f4f4f5' // color for the scrollbar track
}

Layout Configuration

The layout property allows you to define custom dimensions and border radius for the scrollbar components.

const layout = {
  width: '0.5rem', // width of the scrollbar
  thumbRadius: '9999px' // border radius of the scrollbar thumb
}

Complete Example

Here is a complete example of configuring the @raulscoelho/tailwind-scrollbar plugin:

// tailwind.config.ts
import type { Config } from 'tailwindcss'
import { tailwindScrollbar } from '@raulscoelho/tailwind-scrollbar'

const config: Config = {
  // other configurations...
  plugins: [
    tailwindScrollbar({
      colors: {
        thumb: '#e4e4e7',
        thumbHover: '#d4d4d8',
        thumbActive: '#a1a1aa',
        track: '#f4f4f5'
      },
      layout: {
        width: '0.5rem',
        thumbRadius: '9999px'
      }
    })
  ]
}

export default config

Next.js Integration

Below is an example showcasing how to integrate the @raulscoelho/tailwind-scrollbar plugin into a Next.js project:

import './globals.css'

import type { Metadata, Viewport } from 'next'
import { Inter } from 'next/font/google'

const inter = Inter({ subsets: ['latin'] })

export const metadata: Metadata = {
  title: {
    default: 'Scrollbar Application - Home',
    template: 'Scrollbar Application - %s'
  }
}

export const viewport: Viewport = {
  width: 'device-width',
  initialScale: 1,
  maximumScale: 1
}

interface RootLayoutProps {
  children: React.ReactNode
}

export default function RootLayout({ children }: RootLayoutProps) {
  return (
    <html lang="en" className={`${inter.className} antialiased`}>
      <body className="flex min-h-[100dvh] flex-col overflow-auto scroll-smooth bg-indigo-50 scrollbar-thumb-active-indigo-400 scrollbar-thumb-hover-indigo-300 scrollbar-thumb-indigo-200 scrollbar-track-indigo-50">
        {children}
      </body>
    </html>
  )
}

CSS Variables

The plugin creates CSS variables to apply the custom styles to the scrollbar:

  • --scrollbar-width
  • --scrollbar-height
  • --scrollbar-thumb
  • --scrollbar-thumb-hover
  • --scrollbar-thumb-active
  • --scrollbar-track
  • --scrollbar-thumb-radius
  • --scrollbar-track-radius

You can use these variables in your custom CSS if needed:

/* custom.css */
.custom-scrollbar {
  --scrollbar-width: 10px;
  --scrollbar-height: 10px;
  --scrollbar-thumb: #4A5568;
  --scrollbar-track: #EDF2F7;
  --scrollbar-thumb-radius: 5px;
  --scrollbar-track-radius: 5px;
}