Colorhacks is a collection of color conversion and manipulation utilities for TypeScript.
npm install @sillybit/colorhacks
yarn add @sillybit/colorhacks
pnpm add @sillybit/colorhacks
bun add @sillybit/colorhacks
import { getColorNameFromHex } from '@sillybit/colorhacks';
getColorNameFromHex('#FF0000');
// returns { hexcode: '#ff0000', colorName: 'Red', isExactMatch: true, shadeHex: '#ff0000', shadeName: 'Red', distance: 0 }
import { generateTheme } from '@sillybit/colorhacks';
generateTheme({
baseColor: '#FF0000',
expandPalette: true,
colorScheme: 'complementary',
infoHue: 200,
successHue: 120,
warningHue: 40,
errorHue: 0,
});
// returns { brand: { ... }, primary: { ... }, secondary: { ... }, accent: { ... }, neutral: { ... }, info: { ... }, success: { ... }, warning: { ... }, error: { ... }, schemeColors: [ ... ] }
For more examples and API details, see the docs.
You can use this under the MIT license. See the LICENSE file for more details.
We welcome contributions to this project. Please read our CONTRIBUTING.md file for more details.