---
language: "en"
title: "UniAria"
canonical: "https://uniaria.tenphi.me/"
source: "docs/index.mdx"
index: true
---

# UniAria

0
re-renders

while you hover, press or Tab through 1,000 React buttons. React Aria
renders 400 to 601 times.

1,032
accessibility scenarios

each run in React, Vue and custom elements, in Chromium, Firefox and WebKit,
on every push.

2
tool calls

for an AI agent to change a project's settings. With browser tools: 17, at
five times the cost.

20
behaviors

from Button to Combobox, for React, Vue and plain HTML, plus the building
blocks to write your own.

## Use it. Then hand it to an agent.

A settings card in the [default styles](/guide/default-styles/). Try it
with the mouse or the keyboard: the tabs, the select and the number field
follow their WAI-ARIA patterns, arrow keys and typeahead included.

Then press **Run it**. The agent sends one `act()` call with five steps. Each
step runs through the same code your clicks run, so validation, form values
and change events behave as they do for you. The switch it needs sits in a
closed tab: the agent doesn't have to know that, because the bridge opens the
tab on its way.

## One definition. Every framework.

A component's behavior is written once, in plain TypeScript: its keyboard,
focus, ARIA and state. React, Vue and custom elements are thin adapters over
that one definition, so a Select is the same Select in all three, and a fix
lands in all three at once.

```tsx
import { useSelect } from '@uniaria/react/select';

const regions = [
  { id: 'fra', name: 'Frankfurt' },
  { id: 'iad', name: 'Virginia' },
  { id: 'nrt', name: 'Tokyo' },
];

export function RegionSelect() {
  const region = useSelect({
    items: regions,
    getKey: (item) => item.id,
    getTextValue: (item) => item.name,
  });
  return (
    <div {...region.parts.root}>
      <span {...region.parts.label}>Region</span>
      <button {...region.parts.trigger}>
        <span {...region.parts.value} />
      </button>
      <div {...region.parts.popover}>
        <div {...region.parts.list}>
          {regions.map((item) => (
            <div key={item.id} {...region.getItemProps('option', item.id)}>
              {item.name}
            </div>
          ))}
        </div>
      </div>
      <select {...region.parts.hiddenSelect} name="region" />
    </div>
  );
}
```

```vue
<script setup lang="ts">
import { useSelect } from '@uniaria/vue/select';

const regions = [
  { id: 'fra', name: 'Frankfurt' },
  { id: 'iad', name: 'Virginia' },
  { id: 'nrt', name: 'Tokyo' },
];

const region = useSelect({
  items: regions,
  getKey: (item) => item.id,
  getTextValue: (item) => item.name,
});
</script>

<template>
  <div v-bind="region.parts.root">
    <span v-bind="region.parts.label">Region</span>
    <button v-bind="region.parts.trigger">
      <span v-bind="region.parts.value" />
    </button>
    <div v-bind="region.parts.popover">
      <div v-bind="region.parts.list">
        <div
          v-for="item in regions"
          :key="item.id"
          v-bind="region.getItemProps('option', item.id)"
        >
          {{ item.name }}
        </div>
      </div>
    </div>
    <select v-bind="region.parts.hiddenSelect" name="region" />
  </div>
</template>
```

```html
<script type="module">
  import '@uniaria/elements/select';
</script>

<uni-select>
  <div data-uni="select">
    <span data-element="Label">Region</span>
    <button data-element="Trigger">
      <span data-element="Value"></span>
    </button>
    <div data-element="Popover">
      <div data-element="List">
        <div data-element="Option" data-key="fra">Frankfurt</div>
        <div data-element="Option" data-key="iad">Virginia</div>
        <div data-element="Option" data-key="nrt">Tokyo</div>
      </div>
    </div>
    <select data-element="HiddenSelect" name="region"></select>
  </div>
</uni-select>
```

The custom element works in any framework, or none, and reads its options
from your markup.

You render the elements and own every class. UniAria writes the roles,
`aria-*` attributes, ids, the keyboard and every `data-*` state, and keeps
them current: the list opens in the browser's top layer, so nothing is
portaled or moved, and the hidden `<select>` submits the value with your form.

## State goes to the DOM, not through your renders

In most libraries, hover, press, focus and a highlighted option are framework
state, so each one renders your component again. UniAria writes them straight
to the elements. A component renders again only for the state it reads:

```tsx
import { useSelectState } from '@uniaria/react/select';

// Renders again when the selection changes, and for nothing else:
// opening the list, moving through it, hover and focus render nothing.
const selected = useSelectState(region, (state) => state.value[0]);
```

The difference shows in long lists, in pages with many components, and in
design-system components whose render is expensive. A thousand buttons in
React, against React Aria's:

|                                     | React Aria | UniAria |
| ----------------------------------- | ---------: | ------: |
| Renders, hovering 200 buttons       |        400 |       0 |
| Renders, clicking 100 buttons       |        598 |       0 |
| Renders, pressing Tab 200 times     |        601 |       0 |
| Script time, hovering 200 buttons   |    98.0 ms | 32.9 ms |
| Script time, clicking 100 buttons   |    79.8 ms | 18.2 ms |
| Script time, pressing Tab 200 times |    80.6 ms |  9.9 ms |
| One button, gzip                    |    11.9 kB |  8.4 kB |

Production builds in headless Chromium, medians of seven runs
([the benchmark](https://github.com/tenphi/uniaria/blob/main/packages/react/bench/results.md)).
A button that reads its hover state renders for it, as it should: 400 times.
[Reading state](/guide/state/#reading-state).

## Style it from the DOM

Every part carries a marker and its state as attributes, so plain CSS styles
it, with no class names to pass and no render props. Positions come as CSS
variables:

```css
[data-uni='select'] [data-element='Trigger'][data-focus-visible] {
  outline: 2px solid var(--focus);
}
[data-uni='select'] [data-element='Popover'] {
  min-width: var(--anchor-width);
  max-height: min(16rem, var(--available-height));
}
[data-uni='select'] [data-element='Option'][data-focused] {
  background: var(--hover);
}
[data-uni='select'] [data-element='Option'][data-selected] {
  font-weight: 600;
}
```

```tsx
import { tasty } from '@tenphi/tasty';

// Spread `region.parts.root` on it: the parts are its sub-elements.
const RegionSelectRoot = tasty({
  styles: {
    display: 'grid',
    gap: '.5x',
    Trigger: {
      border: { '': '1bw #border', open: '1bw #accent' },
    },
    Option: {
      fill: { '': '#clear', '@own(focused)': '#hover' },
      color: { '': '#text', '@own(selected)': '#accent' },
    },
  },
});
```

Or start from [`@uniaria/styles`](/guide/default-styles/): a complete look
for every component, in light, dark and high contrast, written against the
same attributes. The demo above wears it.

## Ready for agents. Both kinds.

### Agents that operate your page

An agent driving a page through browser tools clicks and types one control at
a time, and works out again how each widget opens, filters and chooses. The
agent bridge gives it the components instead: `snapshot()` lists them as data,
and `act()` runs a whole task in one call.

```ts
import { createAgent } from '@uniaria/core/agent';

const agent = createAgent({
  // Asked before every step: keep a person in charge of what matters.
  allow: (step) => (step.confirm ? confirmWithPerson(step.confirm) : true),
});

// Hand the model the three tools, then run each call it makes.
const tools = agent.tools;
const result = await agent[call.name](call.input);
```

On UI SDK's agent benchmark, which asks an agent to change a project's
settings, the same task on the same screen took:

|            | Browser tools | Agent bridge |
| ---------- | ------------: | -----------: |
| Tool calls |            17 |            2 |
| Text read  |         36.6k |         4.6k |
| Time       |       22–29 s |          8 s |
| Cost       |        $0.116 |       $0.021 |

Sonnet through Claude Code, December 2026
([the benchmark](https://github.com/tenphi/uniaria/blob/main/apps/agent-benchmark/README.md)).
The bridge speaks [UI SDK](https://ui-sdk.dev)'s agent protocol, so an agent,
a tool definition or a harness written for UI SDK drives a UniAria page
unchanged. [Agents](/guide/agents/).

### Agents that write your code

`@uniaria/core` ships the docs of its version and the `uniaria-build` skill to
your coding agents, through [harnesspm](https://harnesspm.tenphi.me):

```sh
npx -y @harnesspm/cli init
```

With only that skill and those docs, an agent built a settings form, a
searchable select and a disclosure UniAria doesn't ship. All 10 behavior
tests passed, and the types checked
([the evaluation](https://github.com/tenphi/uniaria/blob/main/apps/agent-eval/README.md)).

## Accessibility you can check

Every component follows its
[WAI-ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/)
pattern, on a native element wherever one exists. 1,032 conformance scenarios
hold it there: each runs through React, Vue and the custom elements, in
Chromium, Firefox and WebKit, with a virtual screen reader checking what is
spoken, on every push. VoiceOver and NVDA run every night.

The same checks test your own widgets, built on UniAria or not:

```ts
import { checkPattern } from '@uniaria/testing/browser';

// Roles, states, names, id references, then the keyboard, the way a
// keyboard and screen-reader user meets it. Every problem in one error.
await checkPattern(document.querySelector('#formatting')!, 'toolbar');
```

[How UniAria is tested](/guide/accessibility/).

## Build what isn't in the box

UniAria's own components are definitions like this one, composed from the
same building blocks: a collection, roving focus, selection, press. Yours get
what they get: every framework, server rendering, no re-renders and the agent
bridge.

```ts
import { createListCollection } from '@uniaria/core/collections';
import { createRovingFocus } from '@uniaria/core/dom';
import { defineBehavior, prop } from '@uniaria/core';

export const toolbar = defineBehavior({
  name: 'toolbar',
  parts: ['root'],
  itemParts: ['item'],
  props: {
    items: prop<readonly { key: string; label: string }[]>([]),
    label: prop<string | undefined>(undefined, { type: 'string' }),
  },
  setup(ctx) {
    const collection = ctx.memo(
      () => [ctx.props.items()] as const,
      (items) =>
        createListCollection(items, {
          getKey: (tool) => tool.key,
          getTextValue: (tool) => tool.label,
          isDisabled: () => false,
          getChildren: () => undefined,
        }),
    );
    // One Tab stop, arrow keys between the items, Home, End, right to left.
    const roving = createRovingFocus(ctx, {
      collection,
      element: (key) => ctx.itemElement('item', key) as HTMLElement | null,
      root: () => ctx.element('root') as Element | null,
    });
    return { roving };
  },
  expose: () => ({}),
  connect: ({ props }) => ({
    root: { attrs: { role: 'toolbar', 'aria-label': props.label() } },
  }),
  connectItem: ({ api }, _part, key) => api.roving.itemProps(key),
});
```

`useBehavior(toolbar, props)` in React or Vue, or `<uni-toolbar>` once
`defineElement(toolbar)` registers it. [Custom components](/guide/custom-components/).

## Behaviors

UniAria isn't a component library: it renders nothing. Each behavior is one
definition that your React or Vue component, or a custom element, runs on
markup you write.

Button, which is a link too with an `href`, and ToggleButton.

Form, Field, TextField, TextInput, NumberField, Checkbox, CheckboxGroup,
Switch, Radio and RadioGroup.

Dialog, Popover and Tooltip, in the browser's top layer.

Listbox, Select, Autocomplete, Combobox and Tabs, with typeahead and
optional virtualization.

For behaviors UniAria doesn't ship: press, long press and hold to repeat,
hover, focus-visible, roving focus over lists, grids and trees, typeahead,
selection, dismissable layers, positioning, presence and findable panels,
announcements and shortcuts.

## Start

UniAria is at 0.x on npm: its APIs can change in any 0.x version.

Read the [introduction](/guide/introduction/) for the ideas behind UniAria,
see how it [compares with other libraries](/guide/comparison/), or go
straight to [getting started](/guide/getting-started/).
