@trousers/react
@trousers/react
Default export
SourceClassic React JSX factory that resolves the css and $ selection props before creating an element.
function jsx<Props extends TrousersProps>(type: ElementType, props: Props | null, ...children: ReactNode[]): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
classnames
SourceResolve compiled styles and active selections into a string for className.
Use selection keys without the $ prefix. Boolean modifiers activate on
true, and named variants activate when the value matches a choice.
function classnames<Styles extends CompiledStyles<VariantOptions>>(styles: Styles | false | null | undefined, selections?: Readonly<Record<string, VariantSelection>> & VariantSelections<Styles>): string;
Example
classnames(button, { primary: true, size: 'm' });
css
SourceDefine 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.
function css(styles: CSSObject): CollectorReturn;
function css(id: string, styles: CSSObject): CollectorReturn;
Example
const button = css('button', { borderRadius: 8 })
.modifier('primary', { backgroundColor: '#f95b5b' });
jsx
SourceClassic React JSX factory that resolves the css and $ selection props before creating an element.
function jsx<Props extends TrousersProps>(type: ElementType, props: Props | null, ...children: ReactNode[]): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
TrousersProps
SourceStyling props accepted by Trousers JSX, including $ modifier flags and variant choices.
export type TrousersProps = {
css?: CollectorReturn | false | null;
className?: string;
[selection: `$${string}`]: VariantSelection;
};
@trousers/react/jsx-runtime
Fragment
SourceLets you group elements without a wrapper node.
export { Fragment } from 'react';
Example
```tsx
import { Fragment } from 'react';
<Fragment>
<td>Hello</td>
<td>World</td>
</Fragment>
```tsx
// Using the <></> shorthand syntax:
<>
<td>Hello</td>
<td>World</td>
</>
jsx
SourceCreate an element through the automatic JSX runtime and resolve its Trousers props.
function jsx(type: ElementType, props: TrousersProps, key?: Key): ReactElement;
JSX
Sourceexport type { JSX } from 'react/jsx-runtime';
jsxs
SourceCreate an element with static children through the automatic Trousers JSX runtime.
function jsxs(type: ElementType, props: TrousersProps, key?: Key): ReactElement;
@trousers/react/jsx-dev-runtime
Fragment
SourceLets you group elements without a wrapper node.
export { Fragment } from 'react';
Example
```tsx
import { Fragment } from 'react';
<Fragment>
<td>Hello</td>
<td>World</td>
</Fragment>
```tsx
// Using the <></> shorthand syntax:
<>
<td>Hello</td>
<td>World</td>
</>
JSX
Sourceexport type { JSX } from 'react/jsx-dev-runtime';
jsxDEV
SourceDevelopment JSX runtime that resolves Trousers props and forwards React's debugging metadata.
function jsxDEV(type: ElementType, props: TrousersProps, key: Key | undefined, isStaticChildren: boolean, source: Parameters<typeof reactJsxDEV>[4], self: unknown): ReactElement;