Installation
Install Fluentic Style and choose your first setup path.
Install the package with your package manager:
pnpm add @fluentic/stylenpm install @fluentic/styleyarn add @fluentic/stylebun add @fluentic/styleReact 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.
Pick a mode
Section titled “Pick a mode”There are two useful starting modes. They use the same component code.
| Mode | Best for | Setup |
|---|---|---|
| Runtime-only | Prototyping, tests, component libraries, unsupported bundlers, SSR experiments | JSX import source and useCss |
| Static extraction | Applications and production bundles where a supported bundler is available | Runtime 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.
TypeScript
Section titled “TypeScript”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 */Runtime-only check
Section titled “Runtime-only check”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>;}Add extraction with Vite
Section titled “Add extraction with Vite”Install the Vite React plugin if your app does not already have it:
pnpm add -D @vitejs/plugin-react vitenpm install -D @vitejs/plugin-react viteyarn add -D @vitejs/plugin-react vitebun add -d @vitejs/plugin-react viteThen 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.