Packages

Playa

ajo-ui-playa: themed components, a UnoCSS preset, plain CSS tokens and the rules its families keep.

ajo-ui-playa is a themed component library for business and operations apps built with Ajo: an ivory suit by day, a warm neutral near-black at night, and satin champagne gold as the one metal. Its families are the accessible ajo-ui components with Playa’s design applied. The official starter builds its pages and forms with it.

The package has three surfaces. The root exports only playa(), the UnoCSS preset your build configuration reads. Each of the 62 family subpaths, such as ajo-ui-playa/button, exports runtime components, and there is no root barrel for them. Two plain stylesheets, ajo-ui-playa/tokens.css and ajo-ui-playa/fonts.css, bring the materials and the faces to any page, with or without UnoCSS.

Install

Terminal
pnpm add ajo@0.2.0 ajo-ui-playa@0.3.0
pnpm add -D unocss@66.10.5

ajo ^0.2.0 is a peer. unocss is an optional peer, and an exact one: the preset and the component families need it, and this release is verified against UnoCSS 66.10.5 with Vite 8.3.1. The two stylesheets do not need UnoCSS; import them through a bundler that resolves package exports, such as Vite. ajo-ui and the Fontsource faces arrive as dependencies of Playa, so a themed application does not declare them.

Set up

  1. Add the preset to the application’s UnoCSS configuration.

    uno.config.ts
    import { playa } from 'ajo-ui-playa'
    import { defineConfig } from 'unocss'
    
    export default defineConfig({ presets: [playa()] })
  2. Import the faces from an application stylesheet, so they resolve from the application.

    src/app.css
    @import 'ajo-ui-playa/fonts.css';
  3. Register the UnoCSS Vite plugin next to Kit’s, and give Kit both stylesheets. Kit links its css entries in the document head before hydration, so the first paint is already styled:

    vite.config.ts
    import { defineConfig } from 'vite'
    import { kit } from 'ajo-kit/vite'
    import unocss from 'unocss/vite'
    
    export default defineConfig({
      plugins: [
        ...kit({ css: ['/src/app.css', 'virtual:uno.css'] }),
        unocss(),
      ],
    })

Without Kit, add unocss() to the Vite plugins and import 'ajo-ui-playa/fonts.css' and 'virtual:uno.css' from the application entry. The fonts are opt-in: leave fonts.css out and the type falls back to system faces. Playa publishes no precompiled component CSS, and there is no ajo-ui-playa/vite wrapper.

The tokens

ajo-ui-playa/tokens.css holds Playa’s materials as custom properties, together with the scheme contract below: no element selectors, no font faces and no network. playa() emits the same file as its first preflight, so an application that uses the preset does not import it again. A page without UnoCSS imports it and reads the materials by name. This site does exactly that: its base stylesheet imports the tokens after its font faces and paints the sea on top.

CSS
@import 'ajo-ui-playa/tokens.css';

.summary {
  background: var(--card);
  color: var(--foreground);
  font: 0.875rem/1.25rem var(--font-body);
  border-radius: calc(var(--radius) + 0.25rem);
  box-shadow: inset 0 0 0 1px var(--border);
}

--background and --foreground paint the page, --card a raised surface and --border its hairline; --accent is the gold tint of a selected item rather than a brand color. A page author mostly reaches for these roles, and the package README lists every property an application may read.

ajo-ui-playa/fonts.css loads DM Sans, JetBrains Mono and Fraunces (its weight axis) as variable faces from Fontsource. Each face declares its unicode ranges, so the browser downloads only the faces and subsets a page’s text uses.

Light and dark

The system color scheme is the default. tokens.css sets color-scheme: light dark on the root and writes every color that changes with the scheme with light-dark(), so a visitor who prefers dark gets the dark theme before any script runs. A light or dark class on the root element only forces a choice.

Playa ships no theme toggle: the application owns the choice. Restore a saved choice before the first paint with an inline script in the document head:

index.html
<script>
  try {
    const theme = localStorage.getItem('theme')
    if (theme === 'light' || theme === 'dark') {
      document.documentElement.classList.add(theme)
    }
  } catch {}
</script>

The toggle removes both classes from the root, adds the one it chose and saves it under the same key. The package README has a complete toggle built on Button.

The rules

Every family keeps these rules, and a screen built from the families keeps them when its own layout does too.

Sizes and type

  • Three control heights: sm 32 px, the default 36 px and lg 40 px. Button, Input, SelectTrigger, Toggle, ToggleGroup and InputGroup take them as size. Toolbar, ButtonGroup, ToggleGroup and InputGroup pass their size to every child that sets none, so a composed row has one height. A custom control uses h-control, h-control-sm or h-control-lg.
  • One text scale on a 4 px grid, with one line height per size: text-xs 12/16 for captions, text-sm 14/20 for body text and every control, label and message, text-base 16/24 for reading and for inputs on phones, text-xl 20/28 for section headings and text-title 28/36 for the page title (text-2xl 24/32 on phones).
  • Spacing uses the steps 4, 8, 12, 16, 24, 32 and 48 px: fields in a group sit 24 apart, groups and page sections 32, and the page header 24 above the content.
  • DM Sans is the interface. Fraunces appears once per page, as its title, through TypographyH1 from ajo-ui-playa/typography. JetBrains Mono (font-mono) is for values a person copies or compares, such as ids, versions, tokens and log lines, never for labels.

Fields

A vertical Field is three rows, whatever its children’s order: the label, the control (at least one control tall) and one message line that help text and the error share. The error takes the help’s place, and the help stays in aria-describedby. Pass invalid to every field that can show an error, even as false: the field then keeps its message line while valid, so an error appears without moving anything. A field with neither help nor validation has no message row.

FieldRow puts fields side by side inside a FieldGroup. Its fields share their three rows, so their controls keep one top when only one of them has help, an error or a label that wraps, and the row stacks when the group is narrower than 28rem.

src/apps/app-fields.tsx
import {
  Field, FieldDescription, FieldError, FieldGroup,
  FieldLabel, FieldRow,
} from 'ajo-ui-playa/field'
import { Input } from 'ajo-ui-playa/input'

type Errors = { name?: string; domain?: string }

export const AppFields = ({ errors }: { errors: Errors }) => (
  <FieldGroup>
    <FieldRow>
      <Field name="app-name" invalid={errors.name !== undefined}>
        <FieldLabel>App name</FieldLabel>
        <Input name="name" />
        <FieldError>{errors.name}</FieldError>
      </Field>
      <Field name="app-domain" invalid={errors.domain !== undefined}>
        <FieldLabel>Domain</FieldLabel>
        <Input name="domain" dir="ltr" />
        <FieldDescription>
          Point its DNS here before the first deploy.
        </FieldDescription>
        <FieldError>{errors.domain}</FieldError>
      </Field>
    </FieldRow>
  </FieldGroup>
)

FieldError renders nothing without a message, so it can stay in the markup, and it takes a validator’s errors list in place of children. A checkbox or switch beside its label is a Field with orientation="horizontal". Placeholders take --faint-foreground, so a placeholder never reads as a value.

States

  • Focus is one ring: --focus-width of --ring (bronze by day, champagne at night), flush on the control’s boundary with no gap and no halo, and in the danger hue on an invalid control. A custom control takes the ring from playa-focus, and a text field from playa-field, which includes it. The preflight removes the outline from native input, select and textarea, so those need one of the two; a link, a summary or a custom button takes the ring from the preflight outline.
  • Hover changes a color, the plate’s sheen or a link’s underline, and adds no ring. Invalid is aria-invalid="true": the boundary and the message take the danger hue, FieldError puts a small alert icon before the message, and the label and the value keep their colors.
  • Disabled (disabled or aria-disabled="true") dims to --disabled-opacity and takes no pointer. Button loading keeps the button’s width, shows a Spinner, reports aria-busy and ignores activation until it clears.
  • Gold is scarce. Button’s default variant wears the gold plate: give it to the one primary action on a screen, make every other action secondary, outline, ghost or link, and a destructive one danger. Switches, checkboxes, radios, slider ranges and progress fill with the text color; gold marks only focus and the selected item of a set, such as a tab, a day, the current item, a menu highlight or selected rows.

Direction

Families follow the document’s direction: set dir and lang on <html>, and use DirectionProvider from ajo-ui-playa/direction only for a subtree that differs. Application markup uses logical utilities (ps, pe, ms, me, start, end, text-start, rounded-s, border-s) and flips an icon that points a direction, such as a chevron, with rtl:-scale-x-100. An icon that names an object does not flip.

Use the components

Import each family from its subpath. Family imports are side-effect-free and tree-shakeable.

src/notes/note-card.tsx
import { Button } from 'ajo-ui-playa/button'
import {
  Card, CardAction, CardContent, CardDescription,
  CardFooter, CardHeader, CardTitle,
} from 'ajo-ui-playa/card'

type Args = { title: string; text: string; created: string }

export default ({ title, text, created }: Args) => (
  <Card as="article">
    <CardHeader>
      <CardTitle role="heading" aria-level={2}>{title}</CardTitle>
      <CardDescription>{created}</CardDescription>
      <CardAction>
        <Button variant="ghost" size="icon-sm" aria-label="Pin note">
          <span class="i-lucide-pin" aria-hidden="true" />
        </Button>
      </CardAction>
    </CardHeader>
    <CardContent>
      <p>{text}</p>
    </CardContent>
    <CardFooter class="gap-2">
      <Button size="sm">Edit</Button>
      <Button size="sm" variant="outline" as="a" href="/notes">
        All notes
      </Button>
    </CardFooter>
  </Card>
)
  • Button takes a variant (default, secondary, outline, ghost, muted-ghost, link, danger, danger-ghost) and a size (default, sm, lg, the square icon, icon-sm and icon-lg, the dense xs and icon-xs at 24 px, and none). With as="a" and an href it renders a link.
  • Card renders a div by default, or an article, section, form or a through as, with size default or sm.
  • class always styles the visible root of a component, so utilities you add, such as gap-2 above, join the theme’s classes there.
  • Families that export reusable recipes name them …Variants. buttonVariants({ variant, size }) returns the class list of a button for another element.

Families that wrap an ajo-ui family render its components underneath, so ajo-ui’s keyboard behavior, ARIA wiring, state arguments and state attributes carry over. The families run from actions and status through content and layout, inputs and selection, navigation and overlays, to data and media such as data-table and message; the package README lists every subpath.

Materials in your markup

The preset names the materials, so application markup wears them the way the families do:

  • gilt-plate is the champagne plate of the one primary action; Button’s default variant already wears it.
  • panel is the card fill with a 1 px hairline, for a group that carries meaning: a table, a metric, a settings section with its own save.
  • edge and edge-input draw the hairline, or the 3:1 control boundary, inside the box.
  • glass-chrome frosts a sticky bar, and glass-overlay a layer that floats over the page. scrim tints and blurs the backdrop of the modal <dialog> that wears it.
  • navy is the carpet under code and logs; what sits on it takes the dark tokens in both themes.

Color utilities read the roles and status hues by name, such as bg-card, text-muted-foreground, text-faint-foreground, text-gold-text, bg-accent, bg-danger-fill and border-input. Chart series are read as var(--chart-1) to var(--chart-5).

What the preset configures

playa() takes no options. It sets up:

  • Wind4. UnoCSS’s Wind4 preset provides the utility classes, such as flex, gap-2 and rounded-lg.
  • Lucide icons. The Icons preset with the Lucide collection, so i-lucide-pin renders that icon as an inline block.
  • Theme. A color for every role and status hue; a radius scale in which rounded and the rounded-xs to rounded-2xl steps derive from one --radius; xs, lg and xl shadows from the elevation tokens; font-sans, font-mono and font-title from the three type stacks; the control heights and text-title.
  • Preflights. tokens.css first, then the default focus ring, the text selection in gold, the faint placeholder color, keyframes, themed scrollbars and overflow edge fades. A family’s own rules come with its classes, so a family you never import adds nothing.
  • Variants and rules. aria-invalid:, has-aria-invalid: and pointer-coarse: variants; rules such as scrollbar-none, scroll-fade-x, shimmer, and the animate-in and animate-out families.
  • Shortcuts. The materials above, the designed states playa-focus, playa-invalid, playa-disabled and playa-field, and the families’ playa-* recipes.

How classes are found

UnoCSS generates only the classes it sees. Each published Playa module carries UnoCSS’s @unocss-include marker, so the families your application imports pass through the build and contribute their classes; families you never import add nothing. Classes you write in your own source are found there. One stylesheet results, and neither UnoCSS nor the icon data reaches client JavaScript.

A class that exists only at runtime cannot be found. Write every class as a complete literal, and put names you compute, such as an icon chosen from data, in the application’s safelist. Application-wide combinations belong in uno.config.ts as your own shortcuts:

uno.config.ts
import { playa } from 'ajo-ui-playa'
import { defineConfig } from 'unocss'

export default defineConfig({
  presets: [playa()],
  shortcuts: {
    'note-grid': 'grid gap-4 sm:grid-cols-2',
  },
  // Built as `i-lucide-${note.icon}`: no source file names them.
  safelist: [
    'i-lucide-star',
    'i-lucide-archive',
    'i-lucide-lightbulb',
  ],
})

Full reference: ajo-kit packages/ajo-ui-playa/README.md