@bobthered/tailwindcss-palette-generator
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

Tailwindcss Palette Generator

Quickly generate tailwindcss color palettes from a base color or colors.

DemoKey FeaturesInstallationUsageExamples

Demo

Interactive demo generating tailwindcss palettes

Key Features

  • Generate color palette with as little as a hex value ( See Example )
  • Generate multiple color palettes ( See Example )
  • Customize the palette shade names & lightnesses ( See Example )
  • Default color naming applied automatically or can be overwritten ( See Example )
  • Zero (0) dependencies
  • Typescript support
  • Preserve Supplied Color

Installation

npm i @bobthered/tailwindcss-palette-generator

Options

The tailwindcssPaletteGenerator() function receives only one parameter.

Option Type Type
String string
Array of Strings string[]
Object {
  colors?: string[],
  names?: string[],
  preserve?: boolean,
  shades?: Record<string | number, number>[],
}

Usage

Example - Basic

// tailwind.config.js
import { tailwindcssPaletteGenerator } from '@bobthered/tailwindcssPaletteGenerator';

export default {
	content: ['./src/**/*.{html,js,svelte,ts}'],
	theme: {
		extend: {
			colors: tailwindcssPaletteGenerator('#FF0040')
		}
	},
	plugins: []
};

Example - Multiple Colors

// tailwind.config.js
import { tailwindcssPaletteGenerator } from '@bobthered/tailwindcssPaletteGenerator';

export default {
	content: ['./src/**/*.{html,js,svelte,ts}'],
	theme: {
		extend: {
			colors: tailwindcssPaletteGenerator(['#FF0040', '#FFBB00'])
		}
	},
	plugins: []
};

Example - Custom Shades and Lightness

// tailwind.config.js
import { tailwindcssPaletteGenerator } from '@bobthered/tailwindcssPaletteGenerator';

export default {
	content: ['./src/**/*.{html,js,svelte,ts}'],
	theme: {
		extend: {
			colors: tailwindcssPaletteGenerator({
				colors: ['#FF0040'],
				shades: [
					{ name: 'light', lightness: 95 },
					{ name: 'normal', lightness: 46 },
					{ name: 'dark', lightness: 7 }
				]
			})
		}
	},
	plugins: []
};

Example - Override color names

// tailwind.config.js
import { tailwindcssPaletteGenerator } from '@bobthered/tailwindcssPaletteGenerator';

export default {
	content: ['./src/**/*.{html,js,svelte,ts}'],
	theme: {
		extend: {
			colors: tailwindcssPaletteGenerator({
				colors: ['#FF0040', '#FFBB00'],
				names: ['red', 'yellow']
			})
		}
	},
	plugins: []
};

Package Sidebar

Install

npm i @bobthered/tailwindcss-palette-generator

Weekly Downloads

599

Version

4.0.0

License

MIT

Unpacked Size

23.8 kB

Total Files

9

Last publish

Collaborators

  • bobthered