CSS in JS
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.
The jss prop
All components accept a jss prop that works like inline styles but with additional capabilities:
<BaseView jss={{ backgroundColor: "red", padding: 12 }} />
Internally, styles become hashed CSS classes, enabling server-side rendering and hydration. Spacing, border, and inset declarations share a class so shorthand, physical, and logical overrides keep their order:
<style>
.x1uc1pme {
background: red;
}
.x1kbdebd {
padding: 12px;
}
</style>
<div class="x1uc1pme x1kbdebd" />
Arrays and conditionals
The jss prop accepts arrays and falsy values for conditional styling:
<BaseView
jss={[
{ padding: 16 },
isActive && { backgroundColor: "blue" },
isDisabled && { opacity: 0.5 },
]}
/>
Automatic pixel conversion
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;
Pseudo-selectors
Use string keys for pseudo-classes and pseudo-elements:
// Hover state
jss({ ":hover": { backgroundColor: "blue" } });
// Keyboard focus
jss({ ":focus-visible": { outline: `2px solid ${cssVar("--outline")}` } });
// First child
jss({ ":first-child": { marginTop: 0 } });
Descendant selectors
Target child elements with space-prefixed selectors:
// All child divs
jss({ " div": { padding: 8 } });
// Direct children
jss({ " > span": { color: "red" } });
Media queries
Use media query strings as keys:
jss({
padding: 8,
"@media (min-width: 750px)": {
padding: 16,
},
});
Responsive helpers
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 |
CSS variables
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"),
}}
/>;
Focus
--outline is the focus-ring color, separate from the --highlight accent. It has dedicated, muted blue values in each theme. Override it through Providers or JSSProvider:
const themes = {
light: { ...lightTheme, "--outline": "#4678af" },
dark: { ...darkTheme, "--outline": "#7daadc" },
};
<JSSProvider themes={themes}>{children}</JSSProvider>;
Buttons and links use :focus-visible. Text fields use an integrated indicator even after pointer focus. Composite inputs show a frame indicator only for their input, not for action buttons inside the frame. Invalid fields keep an error-colored indicator.
There is no global custom outline or global outline reset. Unstyled native elements retain browser defaults. Remove an inner outline only when an enclosing input surface supplies a visible replacement; never rely on a shadow alone in forced colors.
CSS spacing
padding and margin accept standard one-, two-, three-, and four-value CSS shorthands, including nested calc() and var() expressions. Shorthand, longhand, and logical overrides follow jss array order, independently of component render order.
<Box jss={[
{ padding: "4px 12px 8px 20px" },
{ paddingRight: 16, margin: "calc(4px + 8px) auto" },
]} />
<Box jss={[{ padding: 0 }, { paddingInline: 16, paddingBlock: 8 }]} />
Numeric logical dimensions receive pixels, like physical dimensions. Unitless properties such as lineHeight, opacity, and flexGrow remain unitless.
Materials
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.
Available CSS variables
Colors
| 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 |
| --outline | Focus-ring color |
| --warning | Warning indicator |
Text colors
| 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 |
Interactive states
| 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 |
Button backgrounds
| 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 |
Spacing
| Variable | Size |
|---|---|
| --spacing-xs | 2px |
| --spacing-s | 4px |
| --spacing-m | 8px |
| --spacing-l | 12px |
| --spacing-xl | 16px |
| --spacing-xxl | 24px |
| --spacing-xxxl | 32px |
Border radius
| Variable | Size |
|---|---|
| --border-radius-s | 4px |
| --border-radius-m | 8px |
| --border-radius-l | 12px |
| --border-radius-xl | 16px |
Using toClassnames directly
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>
);
}