Skip to content

JSX Runtime

Configure the css and scope props for React elements.

Fluentic Style ships a JSX runtime so DOM elements can receive two special props:

PropAcceptsPurpose
cssresolved CSS items from useCss, arrays, falsy valuesAdds generated class names.
scopea CssInstance from useCss, arrays, falsy valuesMakes resolved slots available to descendants.

These props are stripped before they reach the DOM.

{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@fluentic/style"
}
}

Most React bundlers also need their React transform configured:

react({
jsxImportSource: '@fluentic/style',
});
/** @jsxImportSource @fluentic/style */

This is useful when you want to adopt Fluentic Style gradually.

<button css={[css.root, isSelected && css.selected, props.css]} />

Falsy values are ignored. Nested arrays are supported.

const css = useCss(styles);
return <section scope={css} />;

Do not pass raw style.scope(...) builders to scope. Resolve your slots with useCss first, then pass the returned instance.