Text Field

A labelled input with an optional hint and error message.

We only use it for your receipt.
import { TextField } from '@brand-studio/ui';

export default function TextFieldDemo() {
  return (
    <div style={{ width: '100%', maxWidth: 360 }}>
      <TextField label="Email" type="email" placeholder="you@example.com" hint="We only use it for your receipt." />
    </div>
  );
}

Installation

pnpm add @brand-studio/ui

Usage

import { TextField } from '@brand-studio/ui';
<TextField label="Email" type="email" hint="We only use it for your receipt." />

Examples

Error

An error sets aria-invalid and joins the message to aria-describedby.

Enter a full postcode, such as SW1A 1AA.

import { TextField } from '@brand-studio/ui';

export default function TextFieldError() {
  return (
    <div style={{ width: '100%', maxWidth: 360 }}>
      <TextField label="Postcode" defaultValue="12" error="Enter a full postcode, such as SW1A 1AA." />
    </div>
  );
}

Accessibility

  • The label is always visible and linked to the input.
  • Hint and error ids are added to any aria-describedby you pass, not swapped for it.

API Reference

PropTypeDefault
labelstring
hint?string
error?string

Also accepts every InputHTMLAttributes<HTMLInputElement> attribute.

Still, Deskhand and Hollis are fictional brands. The coffee photographs are original generated artwork. @brand-studio/ui is MIT licensed.