Documentation

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 })]}
/>;
HelperBreakpoint
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.

Try the focus laboratory.

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

VariablePurpose
--primary-backgroundMain background
--secondary-backgroundAlternate background
--overlay-backgroundModal/popover background
--material-auroraDiffuse blue-green material surface
--material-dawnPale blue, peach, and gold surface
--material-mistNeutral, diffuse material surface
--material-twilightIndigo and violet material surface
--dividerBorder/divider color
--highlightAccent/brand color
--outlineFocus-ring color
--warningWarning indicator

Text colors

VariablePurpose
--primary-textMain text
--secondary-textSupporting text
--subtle-textMuted/disabled text
--highlight-textAccent text
--negative-textError/destructive text
--light-textText on dark backgrounds
--inverse-textText on inverse controls

Interactive states

VariablePurpose
--hovered-backgroundHover state
--pressed-backgroundActive/pressed state
--selected-backgroundSelected item
--light-highlightHighlighted selection
--light-highlight-hoveredHighlighted selection on hover
--light-highlight-pressedHighlighted selection while pressed

Button backgrounds

VariablePurpose
--background-button-primaryPrimary action buttons
--background-button-secondarySecondary buttons
--background-button-negativeDestructive buttons
--background-button-inverseTheme-inverted buttons
--background-button-disabledDisabled buttons

Spacing

VariableSize
--spacing-xs2px
--spacing-s4px
--spacing-m8px
--spacing-l12px
--spacing-xl16px
--spacing-xxl24px
--spacing-xxxl32px

Border radius

VariableSize
--border-radius-s4px
--border-radius-m8px
--border-radius-l12px
--border-radius-xl16px

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>
  );
}