Skip to content

API Reference ​

One line per page. New here? Start with the Quick Start; check the compatibility scope before reusing Tailwind classes from an existing project.

Browser (@barocss/browser) ​

pagewhat it covers
Browser RuntimeBrowserRuntime, getRuntime, baroBoot/baroStart: generate CSS for classes in the DOM and watch changes (observe, addClass, getCss, updateConfig, destroy). Which one to use: BrowserRuntime or getRuntime

Server (@barocss/server, Node) ​

pagewhat it covers
Server RuntimeServerRuntime: generateCssForHtml(html, { skip }) returns the CSS for one HTML response's classes; generateCss('a b c') returns one complete sheet for class names; ssrStyleTag(css, { nonce }) wraps it in <style data-barocss-ssr> for <head> so the browser runtime adopts it

Experimental renderer (@barocss/render, staged) ​

pagewhat it covers
Renderer APIRenderer, validateSpec, classesFor: five-component profile forms with host state/actions; local example. First public release is not yet published.

Configuration and core (@barocss/kit) ​

pagewhat it covers
Configurationthe config object: theme, darkMode, prefix, cssVarPrefix, utilities, preflight
Context APIcreateContext(config): resolved theme and config lookups shared by parser and engine
Parser APIparseClassToAst: split a class name into variants and utility
Engine APIgenerateCss / generateCssRules: turn classes into CSS text
AST Processing APIlow-level AST transforms behind the engine

Extending ​

pagewhat it covers
Static Utility APIstaticUtility: a fixed class to declarations (flex, hidden)
Functional Utility APIfunctionalUtility: value-taking utilities (p-4, bg-red-500, arbitrary values)
Static Modifier APIstaticModifier: fixed variants (hover:, focus:)
Functional Modifier APIfunctionalModifier: parameterized variants (group-*, data-*, breakpoints)

Guides: Vite + Tailwind 4, Next to a Tailwind build, Astro (SSR and static), Security.

📖 Quick Reference ​

By Use Case ​

Browser Development
Server-Side Rendering
Custom Development
Advanced Usage

🎯 Main Entry Points ​

Browser Usage ​

typescript
// CDN
import { BrowserRuntime } from 'https://cdn.jsdelivr.net/npm/@barocss/browser@0.11.2/dist/cdn/barocss.js';

// NPM
import { BrowserRuntime } from '@barocss/browser';

Server Usage ​

typescript
import { ServerRuntime } from '@barocss/server';
import { createContext, generateCss } from '@barocss/kit';

Core Usage ​

typescript
import { 
  createContext, 
  parseClassToAst, 
  generateCss,
  IncrementalParser 
} from '@barocss/kit';

🔧 Key Concepts ​

Context ​

The central configuration and theme management system that provides access to theme values and configuration options.

Engine ​

The core CSS generation system that parses class names, builds ASTs, and converts them to CSS rules.

Runtime ​

Environment-specific implementations that handle CSS injection (browser) or generation (server).

Custom Utilities ​

Context registries for adding custom utilities and variants.

📖 API Categories ​

Core Functions ​

  • createContext(config) - Create a BaroCSS context
  • parseClassToAst(className, ctx) - Parse class to AST
  • generateCss(classList, ctx) - Generate CSS from classes
  • IncrementalParser - Efficient class processing

Runtime Classes ​

  • BrowserRuntime - Browser DOM integration
  • ServerRuntime - Server-side processing
  • ChangeDetector - DOM change monitoring

Custom Utilities ​

  • staticUtility() - Register static utilities with fixed CSS
  • functionalUtility() - Register dynamic utilities with value processing

Custom Modifiers ​

  • staticModifier() - Register static modifiers with fixed selectors
  • functionalModifier() - Register dynamic modifiers with pattern matching

Configuration ​

  • Config interface - Configuration options
  • Theme interface - Theme structure
  • Theme extension and customization

🎨 Usage Patterns ​

Basic Styling ​

typescript
const runtime = new BrowserRuntime();
runtime.addClass('bg-blue-500 text-white p-4');

Custom Theme ​

typescript
const ctx = createContext({
  theme: {
    extend: {
      colors: {
        brand: {
          50: '#eff6ff',
          500: '#3b82f6',
          900: '#1e3a8a'
        }
      }
    }
  }
});

Custom Utilities ​

typescript
import { staticUtility, functionalUtility } from '@barocss/kit';
import { decl } from '@barocss/kit';

// Register static utility
staticUtility('custom-bg', [
  decl('background-color', 'var(--custom-color)'),
  decl('border-radius', '8px')
]);

// Register functional utility
functionalUtility({
  name: 'custom-text',
  prop: 'color',
  handle: (value) => [decl('color', value)]
});

Ready to dive deeper? Start with the Context API to understand how BaroCSS manages themes and configuration.

Released under the MIT License.