Generate color palettes with dynamic base step
npm install kanastra-paletteKanastra Palette is a TypeScript library for generating color palettes with dynamic base tone determination. Inspired by Palettey, it offers a robust solution for creating balanced color schemes in modern web applications.
- Generates complete color palettes from a single color
- Automatically determines the base tone based on color luminosity
- Creates balanced lighter and darker shades
- Compatible with design frameworks like Tailwind CSS
- Written in TypeScript for enhanced type safety and developer experience
- Includes unit tests for reliability
``bash`
npm install kanastra-palette
`typescript`
import { createPaletteFromColor } from 'kanastra-palette';
// Generate a palette from a color
const primaryPalette = createPaletteFromColor('primary', '#7953e0');
console.log(primaryPalette);
#### createPaletteFromColor(name: string, hex: string, options?: PaletteOptions): Record
Generates a complete color palette from a single color.
- name: Name of the palette (e.g., 'primary', 'secondary')hex
- : Base color in hexadecimal formatoptions
- : Additional options (reserved for future expansions)
Returns an object with the color palette, containing shades from 50 to 900.
`json`
{
"primary": {
"50": "#fafafa",
"100": "#f5f5f5",
"200": "#e5e5e5",
"300": "#d4d4d4",
"400": "#a3a3a3",
"500": "#737373",
"600": "#525252",
"700": "#3f3f3f",
"800": "#262626",
"900": "#171717"
}
}
To set up the project for development:
1. Clone the repository
2. Install dependencies: npm installnpm test
3. Run tests: npm run build`
4. Build the project:
Please make sure to update tests as appropriate and adhere to the existing coding style.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Palettey
- Uses chroma.js for color manipulations