Inputs and choices
Labelled fields with hints and errors wired in, and native choices that keep keyboard behavior.
Field
Field pairs a visible label with one control and wires the rest: the label's for, the hint and error through aria-describedby, and aria-invalid while there is an error. Placeholders are examples, never labels, because they disappear as soon as someone types.
Sign-in links go to this address.
Use 2 to 40 characters.
Code
<Field label="Email" hint="Sign-in links go to this address.">
<TextInput
type="email"
autoComplete="email"
defaultValue="[email protected]"
/>
</Field>
<Field label="Display name" error="Use 2 to 40 characters.">
<TextInput defaultValue="A" />
</Field>
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | None | Required. Visible unless labelHidden is set. |
hint | ReactNode | None | Help that applies before anything goes wrong. |
error | ReactNode | None | What is wrong and how to fix it. Sets aria-invalid on the control. |
required | boolean | None | Says so in the label. When every field is required, mark the optional ones instead. |
labelHidden | boolean | false | Keeps the label for assistive technology only, when the context already labels the control. |
id | string | None | The control's id, when something else must reference it. The Field's id always wins. |
Text, search and password
Used only if you lose access to your login email.
Code
<TextField
label="Recovery email"
type="email"
hint="Used only if you lose access to your login email."
/>
<Field label="Search sessions" labelHidden>
<SearchInput placeholder="Search sessions" />
</Field>
<Field label="Password">
<PasswordInput autoComplete="current-password" />
</Field>
PasswordInput adds a reveal toggle, labelled "Show password" or "Hide password", that controls the field it belongs to. SearchInput sets the search keyboard and a leading glyph.
Codes and secrets
Six digits from your authenticator app.
JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXPCode
<Field
label="Authenticator code"
hint="Six digits from your authenticator app."
>
<OtpInput />
</Field>
<SecretField
label="Authenticator secret"
value="JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP"
/>
OtpInput asks for the numeric keyboard and offers codes from messages. SecretField wraps a long value instead of overflowing and copies it with one action: the button then says Copied in its own width, with a check that draws in, and a failed copy says what to do. Pass copyLabel when the button should say what it copies.
Select and text area
Describe what happened and when.
Code
<SelectField label="Week starts on" defaultValue="monday">
<option value="monday">Monday</option>
<option value="sunday">Sunday</option>
</SelectField>
<Field label="Note to support" hint="Describe what happened and when.">
<TextArea maxLength={500} showCount />
</Field>
Files
No files chosen
Code
"use client";
import { useState } from "react";
import { FileButton, FormStatus, Stack } from "@oxidase/ui";
/** Choosing files with a real button. The chosen names are announced politely. */
export function FileDemo() {
const [names, setNames] = useState<string[]>([]);
return (
<Stack gap="s8" align="start">
<FileButton accept=".csv,.json" multiple onFiles={(files) => setNames([...files].map((file) => file.name))}>
Choose export files
</FileButton>
<FormStatus>{names.length ? `Chosen: ${names.join(", ")}` : "No files chosen"}</FormStatus>
</Stack>
);
}Checkboxes and radios
Native inputs underneath, so the keyboard works as it does everywhere else: Space toggles a checkbox, arrow keys move through a radio group. A radio group is a fieldset with a visible legend.
Code
<Checkbox
label="Sounds during training"
description="Short cues as a session runs."
defaultChecked
/>
<Checkbox
label="Reduce motion"
description="Still frames in place of movement."
/>
Code
<RadioGroup legend="Session length">
<Radio
name="length"
value="short"
label="Short"
description="About four minutes."
defaultChecked
/>
<Radio
name="length"
value="standard"
label="Standard"
description="About eight minutes."
/>
</RadioGroup>
<RadioGroup legend="Theme">
<RadioCard
name="theme"
value="system"
title="System"
description="Follows the device, day and night."
defaultChecked
/>
<RadioCard
name="theme"
value="light"
title="Light"
description="Paper, whatever the time."
/>
<RadioCard
name="theme"
value="dark"
title="Dark"
description="Night, whatever the time."
/>
</RadioGroup>
Switch and segmented control
A switch changes a setting immediately; there is no save button behind it, and on is ink. A segmented control picks one of a few options that change a view: a tonal pill with an ink selection, built from native radios so arrow keys move the choice. It never grows past its container; long labels wrap.
Code
<Switch
label="Reduce motion"
description="Removes animation and movement across Oxidase."
/>
<SegmentedControl
label="Theme"
defaultValue="system"
options={[{ value: "light", label: "Light" }, { value: "dark", label: "Dark" }, { value: "system", label: "System" }]}
/>
Switch
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | None | Names the setting. The switch itself carries no text. |
description | ReactNode | None | What changes when it is on. |
checked | boolean | None | Controlled state. Omit and use defaultChecked for uncontrolled. |
onCheckedChange | (checked: boolean) => void | None | Called with the new state. |
pending | boolean | false | A save in progress, announced as busy without blocking. |
Segmented control
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | None | The group's accessible name. |
options | { value, label }[] | None | Two to five options. |
value | string | None | Controlled value; or defaultValue for uncontrolled. |
onValueChange | (value) => void | None | Called when the choice changes. |
size | "small" | "regular" | "regular" | Small for dense toolbars. |
Form messages
A form has one place for its outcome. FormError is announced at once and is only for failure. FormStatus is announced politely and reports progress or success. Field errors stay beside their field.
Sign-in failed. Check the email and password and try again.
Password changed. Other devices were signed out.
Code
<FormError>
Sign-in failed. Check the email and password and try again.
</FormError>
<FormStatus>Password changed. Other devices were signed out.</FormStatus>
- Validate when a field is left or the form is sent, not on every keystroke.
- Say what is wrong and how to fix it, in the field's own terms.
- Keep what someone typed when a request fails.
Saved. Your changes apply to new sessions.
Do
Success says what happened, politely.
Saved successfully
Avoid
Success in the error box is alarming, and it interrupts a screen reader.