Aidos UI uses a custom CSS-in-JS system called jss. Every component accepts a jss prop for styling, and the library includes utilities for theming, responsive design, and type-safe CSS variables.
All components accept a jss prop that works like inline styles but with additional capabilities:
<BaseView jss={{ backgroundColor: "red", padding: 12 }} />
Internally, each property becomes an atomic CSS class with a deterministic hash, enabling server-side rendering and hydration:
<style>
.x1uc1pme {
background: red;
}
.x1kbdebd {
padding: 12px;
}
</style>
<div class="x1uc1pme x1kbdebd" />
The jss prop accepts arrays and falsy values for conditional styling:
<BaseView
jss={[
{ padding: 16 },
isActive && { backgroundColor: "blue" },
isDisabled && { opacity: 0.5 },
]}
/>
Numeric values are automatically converted to pixels for dimensional properties:
<BaseView jss={{ padding: 16, fontSize: 14, opacity: 0.5 }} />
// Results in: padding: 16px; font-size: 14px; opacity: 0.5;
Use string keys for pseudo-classes and pseudo-elements:
// Hover state
jss({ ":hover": { backgroundColor: "blue" } });
// Focus state
jss({ ":focus": { outline: "2px solid blue" } });
// First child
jss({ ":first-child": { marginTop: 0 } });
Target child elements with space-prefixed selectors:
// All child divs
jss({ " div": { padding: 8 } });
// Direct children
jss({ " > span": { color: "red" } });
Use media query strings as keys:
jss({
padding: 8,
"@media (min-width: 750px)": {
padding: 16,
},
});
The library provides helper functions for common breakpoints:
import { mobile, tablet, laptop, desktop } from "aidos-ui";
<BaseView
jss={[{ padding: 8 }, tablet({ padding: 16 }), desktop({ padding: 24 })]}
/>;
| Helper | Breakpoint |
|---|---|
| mobile() | max-width: 479px |
| tablet() | min-width: 480px |
| laptop() | min-width: 1024px |
| desktop() | min-width: 1280px |
Use the cssVar() helper for type-safe access to theme variables:
import { cssVar } from "aidos-ui";
<BaseView
jss={{
backgroundColor: cssVar("--primary-background"),
color: cssVar("--primary-text"),
padding: cssVar("--spacing-m"),
}}
/>;
Materials are named, reusable surface treatments. The shared Material type keeps the vocabulary consistent across components, while getMaterial() lets custom surface components use the same treatment.
import { BaseView, getMaterial, type Material } from "aidos-ui";
const material: Material = "aurora"; // "dawn" | "mist" | "twilight"
<BaseView jss={getMaterial(material)} />;
Prefer a component's material prop when it exposes one. Use getMaterial() when building a new surface component.
| Variable | Purpose |
|---|---|
| --primary-background | Main background |
| --secondary-background | Alternate background |
| --overlay-background | Modal/popover background |
| --material-aurora | Diffuse blue-green material surface |
| --material-dawn | Pale blue, peach, and gold surface |
| --material-mist | Neutral, diffuse material surface |
| --material-twilight | Indigo and violet material surface |
| --divider | Border/divider color |
| --highlight | Accent/brand color |
| --warning | Warning indicator |
| Variable | Purpose |
|---|---|
| --primary-text | Main text |
| --secondary-text | Supporting text |
| --subtle-text | Muted/disabled text |
| --highlight-text | Accent text |
| --negative-text | Error/destructive text |
| --light-text | Text on dark backgrounds |
| --inverse-text | Text on inverse controls |
| Variable | Purpose |
|---|---|
| --hovered-background | Hover state |
| --pressed-background | Active/pressed state |
| --selected-background | Selected item |
| --light-highlight | Highlighted selection |
| --light-highlight-hovered | Highlighted selection on hover |
| --light-highlight-pressed | Highlighted selection while pressed |
| Variable | Purpose |
|---|---|
| --background-button-primary | Primary action buttons |
| --background-button-secondary | Secondary buttons |
| --background-button-negative | Destructive buttons |
| --background-button-inverse | Theme-inverted buttons |
| --background-button-disabled | Disabled buttons |
| Variable | Size |
|---|---|
| --spacing-xs | 4px |
| --spacing-s | 8px |
| --spacing-m | 12px |
| --spacing-l | 16px |
| --spacing-xl | 24px |
| --spacing-xxl | 32px |
| --spacing-xxxl | 48px |
| Variable | Size |
|---|---|
| --border-radius-s | 4px |
| --border-radius-m | 8px |
| --border-radius-l | 12px |
| --border-radius-xl | 16px |
For custom components, use toClassnames() to convert style objects to class names:
import { toClassnames } from "aidos-ui";
function CustomComponent({ active }) {
return (
<div
className={toClassnames([
{ padding: 16, borderRadius: 8 },
active && { backgroundColor: "blue" },
])}
>
Content
</div>
);
}