# The accessible base

> @sypnia/base: the behaviour every piece needs, with no look of its own.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://design.docs.sypnia.com/components/the-base/

For agents: @sypnia/base (MIT, React 19, built on React Aria; npm): unstyled primitives — Button, Link, TextField, NumberField, SearchField, Select, ComboBox, Checkbox, RadioGroup, Switch, Slider, Dialog, AlertDialog, Sheet, Popover, Menu, Tooltip, Tabs, Disclosure, Toast region, Table, GridList, Calendar, DatePicker, FileTrigger, DropZone, Toolbar, Breadcrumbs, Form, VisuallyHidden, SkipLink, Layer. Guarantees: visible focus only for keyboard, full keyboard use, ARIA roles/names/states, focus trapped in dialogs and returned on close, Escape closes the top layer, scroll lock, one layer manager for z-order, live regions for toasts, phone behaviour (44 px hit areas, sheets instead of popovers under 640 px, safe areas, virtual keyboard keeps fields visible, no hover-only actions), RTL. States as data attributes (data-pressed, data-focus-visible, data-open, data-invalid, data-disabled, data-selected) for plain CSS. No CSS, no tokens, no icons. Apps import pieces from their own src/design, never the base directly.

Some things are hard to get right and should never look different from one app to the next: how the keyboard moves through a menu, where focus goes when a dialog closes, what a screen reader says about a switch. `@sypnia/base` does those things, and nothing else. It has **no colours, no sizes, no fonts and no icons**.

It is a React package, MIT-licensed, built on React Aria, the same engine Sypnia's own library uses. Every customer shares it; no customer looks like another because of it.

## What it guarantees

| Area                  | What the base does                                                                                                                                                              |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Focus**             | a visible focus state only when people use the keyboard; focus moves to a dialog when it opens and back when it closes                                                          |
| **Keyboard**          | every piece works with the keyboard alone: arrows in menus and tabs, Escape to close, Enter and Space to press                                                                  |
| **Screen readers**    | the right role, name and state on every piece; announcements for toasts and changes                                                                                             |
| **Layers**            | one manager for everything that floats (menus, popovers, dialogs, sheets, toasts): the right one is on top, Escape closes the top one, the page behind does not scroll          |
| **Dialogs and menus** | focus kept inside while open, outside clicks handled, nested menus                                                                                                              |
| **Phone behaviour**   | hit areas of at least 44 px; popovers become bottom sheets under 640 px; safe areas respected; the field you type in stays visible above the keyboard; nothing depends on hover |
| **Languages**         | right-to-left layouts, dates and numbers in the person's language                                                                                                               |

## The pieces

Button, Link, TextField, NumberField, SearchField, Select, ComboBox, Checkbox, RadioGroup, Switch, Slider, Dialog, AlertDialog, Sheet, Popover, Menu, Tooltip, Tabs, Disclosure, Toast region, Table, GridList, Calendar, DatePicker, FileTrigger, DropZone, Toolbar, Breadcrumbs, Form, VisuallyHidden, SkipLink and Layer.

## How your look attaches

The base exposes each state as a data attribute, so your styles are plain CSS:

`src/design/components/Button.module.css (part)`

```css
.button { background: var(--espiga-color-accent); border-radius: var(--espiga-radius-control); }
.button[data-pressed] { transform: translateY(1px); }
.button[data-focus-visible] { outline: 2px solid var(--espiga-color-focus); outline-offset: 2px; }
```

States: `data-pressed`, `data-hovered`, `data-focus-visible`, `data-open`, `data-selected`, `data-invalid`, `data-disabled`.

## You never import it directly

Screens import pieces from your own `src/design/`. `design check` reports a screen that imports `@sypnia/base` directly, because that piece would have no look and no place in your gallery.
