string-to-color-gradient
Version:
A lightweight npm library to convert any string into consistent hex colors and CSS gradients — perfect for avatars, tags, themes, blog cards, and visual identifiers. Turn names, emails, or any string into beautiful, deterministic color values that stay th
26 lines (25 loc) • 1.02 kB
TypeScript
import { Brightness, GradientOptions } from './model/model';
/**
* Converts a string into a single HSL-based hex color.
*
* @param str - Input string to hash
* @param brightness - Brightness setting (default: 'normal')
* @returns A hex color string (e.g., "#a1b2c3")
*/
export declare function stringToColor(str: string, brightness?: Brightness): string;
/**
* Converts a string into a gradient composed of two colors.
*
* @param str - Input string to hash
* @param options - Gradient options (brightness)
* @returns A tuple of two hex color strings
*/
export declare function stringToGradient(str: string, options?: GradientOptions): [string, string];
/**
* Converts a string into a complete CSS linear-gradient string.
*
* @param str - Input string to hash
* @param options - Gradient options including angle and brightness
* @returns A CSS gradient string (e.g., `linear-gradient(45deg, #a1b2c3, #d4e5f6)`)
*/
export declare function stringToCssGradient(str: string, options?: GradientOptions): string;