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

m3-tailwind-colors

v0.1.5

Published

Generate Material 3 colors for Tailwind and NativeWind.

Downloads

10

Readme

M3 Tailwind Colors

M3 Tailwind Colors is a utility package that generates Material 3 colors for use with Tailwind CSS, specifically designed to integrate seamlessly with Tailwind and NativeWind (React Native).

Features

  • Generate a full palette of Material 3 colors based on a primary color.
  • Easily integrate with Tailwind CSS or NativeWind projects.
  • Supports both light and dark color schemes.

Read more about how it works text

Installation

First, install the package via npm:

npm install m3-tailwind-colors

This will automatically install the necessary dependencies, including @material/material-color-utilities.

Usage

To use the generated colors in your Tailwind CSS configuration, follow these steps:

  • Import and Generate Colors: Use the M3TailwindColor function to generate your Material 3 color palette based on a primary color.

  • Extend Tailwind's Colors: Add the generated colors to the extend.colors section of your Tailwind configuration.

Example Tailwind Configuration

Here's an example of how to set up your tailwind.config.js file:

/** @type {import('tailwindcss').Config} */

const { M3TailwindConfigColors } = require("m3-tailwind-colors");

const generatedColors = M3TailwindConfigColors({
  primary: "#CE7E00", // Replace with your primary color
  otherCustomColor: "#65ff34", //optional
});

module.exports = {
  content: ["./app/**/*.{js,jsx,ts,tsx}", "./components/**/*.{js,jsx,ts,tsx}"],
  presets: [require("nativewind/preset")],
  theme: {
    extend: {
      colors: {
        ...generatedColors,
      },
    },
  },
  plugins: [],
};

Usage with React Native Styling

The package exports a function that can be used to generate colors for react native

  • Example usage
/**
 * Below are the colors that are used in the app. The colors are defined in the light and dark mode.
 * There are many other ways to style your app. For example, [Nativewind](https://www.nativewind.dev/),
 * [Tamagui](https://tamagui.dev/), [unistyles](https://reactnativeunistyles.vercel.app), etc.
 */

import { M3TailwindRNColors } from "m3-tailwind-colors";

const M3colors = M3TailwindRNColors(
  { primary: "#CE7E00" },
  {
    scheme: "content", // Replace with your desired scheme
    contrast: 0, // Adjust the contrast as needed
  }
);

export const Colors = M3colors;

Then it can be used as style values in your react native files like so

      <View
        style={{
          backgroundColor:
            colorScheme === "dark" ? Colors.dark.surface : Colors.light.surface,
        }}
      >
      {children}
      <View>

Generated Colors

The generated color palette will include various shades and tones derived from the primary color, ready to be used in both light and dark modes.

Parameters

The M3TailwindConfigColors and M3TailwindRNColors functions accepts an object with the following parameters:

const M3colors = M3TailwindRNColors(

 {
   primary: '#ff0000', //The base color in hexadecimal format. This will be used to generate the Material 3 color scheme.
   // secondary and/or tertiary are optional, if not given, they will be generated automatically
   secondary: '#ffff00',
   tertiary: '#0000ff',
   // add any other colors you need, it can be named anything
   customname: '#00ff00',
   },
   {
   scheme: 'content',   //optional. options are 'content', 'expressive', 'fidelity', 'monochrome', 'neutral', 'tonalSpot' or 'vibrant'
   contrast: 0, // contrast is optional, any number between -1 (less contrast) to 1 (more contrast).
 }
 true // class names with kebab case, this is optional, the default is false. This will output the class name as 'on-surface' instead of 'onSurface'
)