Contents

Start here

Quick start

Install CSSX, enable the build plugin, and write your first static utility styles.

CSSX turns static utility strings into generated CSS during your build. Start with the runtime package and the plugin for your bundler.

Install

pnpm add @cssxio/cssx @cssxio/unplugin

Enable the Vite plugin

import cssx from '@cssxio/unplugin/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [cssx({ cssFileName: 'assets/cssx.css' })],
});

The plugin finds static CSSX strings, compiles the utilities, and emits the stylesheet as part of the build.

Add utilities to a component

import { sx } from '@cssxio/cssx';

export function Button() {
  return (
    <button className={sx('rounded-lg bg-blue-600 px-4 py-2 text-white', 'hover:bg-blue-700')}>Save changes</button>
  );
}

Use sx to join static utility strings and runtime conditions. CSSX compiles the static strings; runtime values are joined as class names. See Utility syntax and Variants for the full reference.