Skip to content
oxidaseSign in

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>
PropTypeDefaultDescription
labelReactNodeNoneRequired. Visible unless labelHidden is set.
hintReactNodeNoneHelp that applies before anything goes wrong.
errorReactNodeNoneWhat is wrong and how to fix it. Sets aria-invalid on the control.
requiredbooleanNoneSays so in the label. When every field is required, mark the optional ones instead.
labelHiddenbooleanfalseKeeps the label for assistive technology only, when the context already labels the control.
idstringNoneThe 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.

Authenticator secret
JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP
Code
<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

0 of 500 characters

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."
/>
Session length
Theme
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.

Reduce motionRemoves animation and movement across Oxidase.
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

PropTypeDefaultDescription
labelReactNodeNoneNames the setting. The switch itself carries no text.
descriptionReactNodeNoneWhat changes when it is on.
checkedbooleanNoneControlled state. Omit and use defaultChecked for uncontrolled.
onCheckedChange(checked: boolean) => voidNoneCalled with the new state.
pendingbooleanfalseA save in progress, announced as busy without blocking.

Segmented control

PropTypeDefaultDescription
labelstringNoneThe group's accessible name.
options{ value, label }[]NoneTwo to five options.
valuestringNoneControlled value; or defaultValue for uncontrolled.
onValueChange(value) => voidNoneCalled 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.

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.

Avoid

Success in the error box is alarming, and it interrupts a screen reader.