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

@squirgle/tailwind-radix-colors

v0.0.2

Published

The Radix colour scales available in TailwindCSS

Downloads

8

Readme

Tailwind Radix Colors

This is a Tailwind CSS plugin that generates a set of CSS custom properties and tailwind classes for colours on the Radix Colour Palette.

Installation

npm install --dev @squirgle/tailwind-radix-colors

Usage

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

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@squirgle/tailwind-radix-colors'),
  ],
}

This will produce:

:root {
  --amber-1: #fefdfb;
  /* ...and the rest */
}

@media (prefers-color-scheme: dark) {
  :root {
    --amber-1: #16120c;
    /* ...and the rest */
  }
}

.bg-amber-1 {
  background-color: var(--amber-1, #fefdfb);
}

Limiting the colours

By default the plugin will include ALL of the colours from the Radix Colour Palette. If you only want to include a subset of the colours, you can specify them in the plugin options:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@squirgle/tailwind-radix-colors')({
      colors: ['red', 'blue', 'green'],
    }),
  ],
}

Renaming the colours

If you prefer, you can also specify the colours as an object with the colour name as the key and the colour value as the value:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@squirgle/tailwind-radix-colors')({
      colors: {
        base: 'slate',
        accent: 'iris',
      },
    }),
  ],
}

Providing a dark mode selector

By default the plugin will switch between the light and dark scales based on the prefers-color-scheme media query.

If you want to provide a dark mode selector, to switch between the light and dark scalesyou can specify it in the plugin options:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@squirgle/tailwind-radix-colors')({
      darkModeSelector: '.dark' // any valid CSS selector should work,
      // darkModeSelector: '[data-theme="dark"]',
      respectMediaQuery: false // If you don't want to respect the media query
    }),
  ],
}

This will produce:

:root {
  --amber-1: #fefdfb;
  /* ...and the rest */
}

@media (prefers-color-scheme: dark) {
  :root {
    --amber-1: #16120c;
    /* ...and the rest */
  }
}

.dark {
  --amber-1: #16120c;
  /* ...and the rest */
}

Providing a prefix

If you are worried about the custom properties clashing with other custom properties or class names in your project, you can specify a prefix seprately for both the class names and css variables in the plugin options. They don't need to match:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@squirgle/tailwind-radix-colors')({
      classPrefix: 'rdx' // This will be prefixed to the tailwind classes.
      variablePrefix: 'radix' // This will be prefixed to the CSS custom properties.
    }),
  ],
}

This will produce:

:root {
  --radix-amber-1: #fefdfb;
  /* ...and the rest */
}

@media (prefers-color-scheme: dark) {
  :root {
    --radix-amber-1: #16120c;
    /* ...and the rest */
  }
}

.bg-rdx-amber-1 {
  background-color: var(--radix-amber-1, #fefdfb);
}

Configuration Options

type Options = {
  classPrefix?: string; // Defaults to no prefix.
  colors?: Color[] | Record<string, Color>; // Defaults to all radix colours.
  darkModeSelector?: string; // Defaults to no dark mode selector.
  respectMediaQuery?: boolean; // Defaults to true.
  variablePrefix?: string; // Defaults to no prefix.
};