Skip to content

Installation

Install Fluentic Style and choose your first setup path.

Install the package with your package manager:

Terminal window
pnpm add @fluentic/style

React 18 or newer is a peer dependency. Fluentic Style imports React for its JSX runtime and hooks, but your app provides the React version. Bundler packages are optional peer dependencies, so you only install the integration you actually use.

There are two useful starting modes. They use the same component code.

ModeBest forSetup
Runtime-onlyPrototyping, tests, component libraries, unsupported bundlers, SSR experimentsJSX import source and useCss
Static extractionApplications and production bundles where a supported bundler is availableRuntime setup plus a bundler plugin and virtual CSS imports

Runtime-only is not a throwaway mode. It is the fallback that keeps the same style definitions usable when static evaluation is not available. Static extraction is an optimization path for chains the compiler can evaluate.

Use the custom JSX runtime so css and scope props are accepted on DOM and SVG elements.

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

You can also use a file-level pragma:

/** @jsxImportSource @fluentic/style */

After the JSX runtime is configured, this is enough to verify the runtime path:

/** @jsxImportSource @fluentic/style */
import { style, useCss } from '@fluentic/style';
const styles = {
root: style.slot({
display: 'inline-flex',
borderRadius: 6,
padding: '8px 12px',
}),
};
export function Button() {
const css = useCss(styles);
return <button css={css.root} scope={css}>Save</button>;
}

Install the Vite React plugin if your app does not already have it:

Terminal window
pnpm add -D @vitejs/plugin-react vite

Then add the Fluentic Style plugin:

import { plugin as stylePlugin } from '@fluentic/style/plugin/vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
stylePlugin(),
react({
jsxImportSource: '@fluentic/style',
}),
],
});

Then import the virtual runtime module once near your application entry:

import 'virtual:fluentic-styles';

The runtime virtual module tells Fluentic Style whether the build is handled by the plugin and whether CSS was extracted.

Other bundler adapters follow the same idea: configure the adapter, keep the JSX runtime, and import the virtual runtime module once. Some adapters need explicit CSS handling. See Integrations for Vite, Rollup, Rolldown, Rspack, Webpack, esbuild, and Babel.