Skip to content

TypeScript

Types for CSS objects, props, themes, selectors, and custom style functions.

The default style builder uses React CSS property types:

import type { CSSProperties } from '@fluentic/style';
import type { CssProp, CssTheme } from '@fluentic/style';
type Props = {
css?: CssProp;
theme?: CssTheme;
};
import type { StyleObject } from '@fluentic/style';
const base: StyleObject<CSSProperties> = {
display: 'grid',
};
import { createStyleFn, type } from '@fluentic/style';
type AllowedStyles = Pick<CSSProperties, 'color' | 'backgroundColor'>;
const { style } = createStyleFn({
style: type<AllowedStyles>,
selectors: {},
});

Use custom style functions when you want a constrained styling API for a design system or a domain-specific component package.