Overview

Mates ships a lightweight CSS-in-JS system: stylesheet() for scoped class maps, globalCSS / rootCSS for app-level rules, globalTheme for light/dark token sets, and keyframes for animations — no build-time CSS extraction required.

Start with stylesheet() for feature sheets, then theme / rootCSS for design tokens. Pair class maps with the classes() directive for conditionals.

API at a glance

API
Scope
Returns
stylesheet() Module / feature { css, mount, keyframes }
globalCSS(rules) Document Class map (Cl)
globalTheme(themes) Document { cssVars } — theme via data-theme
keyframes(name, stops) Document Animation name string

stylesheet() live demo

Scoped class map from stylesheet().css(), toggled with the classes() directive.

import { html, atom, renderApp, stylesheet, classes } from 'mates';

const { css, mount } = stylesheet();
mount();

const cl = css({
card: {
borderRadius: 'var(--m-r)',
padding: '16px 20px',
background: 'var(--m-surface)',
border: '1px solid var(--m-border)',
color: 'var(--m-fg)',
maxWidth: '280px',
},
title: { margin: '0 0 8px', fontSize: '1.1rem', color: 'var(--m-primary)' },
active: { boxShadow: '0 0 0 2px var(--m-primary)' },
});

const App = () => {
const on = atom(false);
return () => html`
<div class="${cl.card}" ${classes([[on(), cl.active]])}>
<h2 class="${cl.title}">Scoped card</h2>
<p class="muted m-b-10">stylesheet() → css() → class map</p>
<button @click=${() => on.set(v => !v)}>
${on() ? 'Active' : 'Toggle active'}
</button>
</div>
`;
};

renderApp(App, document.getElementById('app'));

globalCSS utility

Shared document-level class map (auto-mounted).

import { html, renderApp, globalCSS } from 'mates';

const g = globalCSS({
pill: {
display: 'inline-block',
padding: '4px 10px',
borderRadius: '999px',
background: '#0f766e',
color: '#ecfdf5',
fontSize: '0.85rem',
},
});

const App = () => () => html`
<div class="m-col m-gap">
<p class="muted">globalCSS injects into a shared sheet (microtask mount).</p>
<span class="${g.pill}">shared utility class</span>
</div>
`;
renderApp(App, document.getElementById('app'));