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/uinpm install @brand-studio/uiyarn add @brand-studio/uibun add @brand-studio/uiInstall the peer dependencies
npm install react react-domImport the stylesheet once
import '@brand-studio/ui/styles.css';Wrap your app in a brand theme
import { BrandTheme, TextField } from '@brand-studio/ui'; import brand from './brand.json'; <BrandTheme palette={brand.tokens} mode="system"> {/* your app */} </BrandTheme>
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-describedbyyou pass, not swapped for it.
API Reference
| Prop | Type | Default |
|---|---|---|
label | string | – |
hint? | string | – |
error? | string | – |
Also accepts every InputHTMLAttributes<HTMLInputElement> attribute.