Trousers

@trousers/styled

@trousers/styled

Default export

Source

Create a React component from an HTML or SVG element and compiled styles. The component accepts the element's props and ref, plus $ modifiers and named variants inferred from the style definition.

ts
const styled: Styled;

Example

ts
const Button = styled.button(buttonStyles);

Define static styles that the bundler plugin extracts into CSS. Apply the result with classnames, styled, or the JSX css prop. Use React's style prop for runtime values. Give the style definition a readable prefix in the emitted class names.

ts
function css(styles: CSSObject): CollectorReturn;
function css(id: string, styles: CSSObject): CollectorReturn;

Example

ts
const button = css('button', { borderRadius: 8 })
    .modifier('primary', { backgroundColor: '#f95b5b' });