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
pnpm add ajo@0.2.0 ajo-ui-playa@0.3.0
pnpm add -D unocss@66.10.5ajo ^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
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()] })Import the faces from an application stylesheet, so they resolve from the application.
src/app.css @import 'ajo-ui-playa/fonts.css';Register the UnoCSS Vite plugin next to Kit’s, and give Kit both stylesheets. Kit links its
cssentries 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.
@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:
<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:
sm32 px, the default 36 px andlg40 px. Button, Input, SelectTrigger, Toggle, ToggleGroup and InputGroup take them assize. Toolbar, ButtonGroup, ToggleGroup and InputGroup pass theirsizeto every child that sets none, so a composed row has one height. A custom control usesh-control,h-control-smorh-control-lg. - One text scale on a 4 px grid, with one line height per size:
text-xs12/16 for captions,text-sm14/20 for body text and every control, label and message,text-base16/24 for reading and for inputs on phones,text-xl20/28 for section headings andtext-title28/36 for the page title (text-2xl24/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
TypographyH1fromajo-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.
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-widthof--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 fromplaya-focus, and a text field fromplaya-field, which includes it. The preflight removes the outline from nativeinput,selectandtextarea, so those need one of the two; a link, asummaryor 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,FieldErrorputs a small alert icon before the message, and the label and the value keep their colors. - Disabled (
disabledoraria-disabled="true") dims to--disabled-opacityand takes no pointer. Buttonloadingkeeps the button’s width, shows a Spinner, reportsaria-busyand 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,ghostorlink, and a destructive onedanger. 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.
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>
)Buttontakes avariant(default,secondary,outline,ghost,muted-ghost,link,danger,danger-ghost) and asize(default,sm,lg, the squareicon,icon-smandicon-lg, the densexsandicon-xsat 24 px, andnone). Withas="a"and anhrefit renders a link.Cardrenders adivby default, or anarticle,section,formorathroughas, withsizedefaultorsm.classalways styles the visible root of a component, so utilities you add, such asgap-2above, 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-plateis the champagne plate of the one primary action; Button’s default variant already wears it.panelis 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.edgeandedge-inputdraw the hairline, or the 3:1 control boundary, inside the box.glass-chromefrosts a sticky bar, andglass-overlaya layer that floats over the page.scrimtints and blurs the backdrop of the modal<dialog>that wears it.navyis 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-2androunded-lg. - Lucide icons. The Icons preset with the Lucide collection, so
i-lucide-pinrenders that icon as an inline block. - Theme. A color for every role and status hue; a radius scale in which
roundedand therounded-xstorounded-2xlsteps derive from one--radius;xs,lgandxlshadows from the elevation tokens;font-sans,font-monoandfont-titlefrom the three type stacks; the control heights andtext-title. - Preflights.
tokens.cssfirst, 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:andpointer-coarse:variants; rules such asscrollbar-none,scroll-fade-x,shimmer, and theanimate-inandanimate-outfamilies. - Shortcuts. The materials above, the designed states
playa-focus,playa-invalid,playa-disabledandplaya-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:
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',
],
})- Unstyled UIThe accessible families underneath Playa.
- Build and configurationThe Kit Vite plugin and its options.
- Quick startCreate a Kit application to style.
Full reference: ajo-kit packages/ajo-ui-playa/README.md