@cerberus-design/react
Version:
The Cerberus Design React component library.
23 lines (22 loc) • 998 B
TypeScript
/**
* This module provides a hook to get Cerberus colors from the document root.
* @module useRootColors
*/
export interface RootColorsResult {
/**
* A record of Cerberus colors where the key is the token name provided and the value is the color hex.
*/
colors: Record<string, string>;
/**
* A function to refetch the Cerberus colors from the document root. Useful when you need the latest colors after a theme/mode change.
*/
refetch: () => Promise<void>;
}
/**
* This hook returns a record of Cerberus colors from the document root.
* This is useful when you are working with a component that uses the `<canvas>`
* element.
* @param colors - An array of Cerberus tokens to get from the document root (i.e. `['dataViz.diverging.50', 'dataViz.diverging.200']`).
* @returns A record of Cerberus colors where the key is the token name provided and the value is the color hex.
*/
export declare function useRootColors(colors?: string[]): RootColorsResult;