UNPKG

@equinor/fusion-react-styles

Version:
42 lines 1.43 kB
import type { StyleRules } from './types'; /** * Type-safe helper function for creating style rules * * This function provides better TypeScript inference for style objects. * It's mainly a type assertion helper that ensures proper typing. * * @template ClassKey - The string literal type for class keys * @template Props - The props type for dynamic styles * * @param styles - Optional style rules object * @returns The same styles object with proper type inference, or never if styles is undefined * * @example * ```tsx * import { createStyles, makeStyles } from '@equinor/fusion-react-styles'; * * const useStyles = makeStyles((theme) => * createStyles({ * root: { * color: theme.colors.text.static_icons__default.getVariable('color'), * }, * button: { * padding: theme.spacing.comfortable.medium.getVariable('padding'), * } * }), * { name: 'MyComponent' } * ); * * function Component() { * const classes = useStyles(); * return ( * <div className={classes.root}> * <button className={classes.button}>Click me</button> * </div> * ); * } * ``` */ export declare function createStyles<T extends Record<string, any>>(styles: T): T; export declare function createStyles<ClassKey extends string, Props extends {} = {}>(styles?: StyleRules<Props, ClassKey>): StyleRules<Props, ClassKey> | never; //# sourceMappingURL=create-styles.d.ts.map