Active Foundation · Example
Disabled, several errors, horizontal and grouped
Disabled, several errors, horizontal and groupedClient
Set when the account was created.
- Use at least 12 characters.
- Add at least one digit.
Monthly statement
One message on the first working day of the month.
Full source examples/ui/field-states.tsx
// apps/docs/examples/ui/field-states.tsx'use client';
import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSet, FieldTitle,} from '@workspace/active-ui/components/primitives/field';import {Input} from '@workspace/active-ui/components/primitives/input';import {Switch} from '@workspace/active-ui/components/primitives/switch';
/** * Disabled, several errors at once, a horizontal row for a switch, and a * group of fields under one legend. */export default function FieldStates() { return ( <div className="grid w-full max-w-2xl gap-8 sm:grid-cols-2"> <Field data-disabled> <FieldLabel htmlFor="states-organisation">Organisation</FieldLabel> <Input id="states-organisation" disabled defaultValue="Example Ltd" /> <FieldDescription>Set when the account was created.</FieldDescription> </Field>
<Field data-invalid> <FieldLabel htmlFor="states-password">Password</FieldLabel> <Input id="states-password" type="password" aria-invalid aria-describedby="states-password-errors" defaultValue="short" /> <FieldError id="states-password-errors" errors={[ {message: 'Use at least 12 characters.'}, {message: 'Add at least one digit.'}, {message: 'Use at least 12 characters.'}, ]} /> </Field>
<Field orientation="horizontal"> <FieldContent> <FieldTitle id="states-statement-title">Monthly statement</FieldTitle> <FieldDescription id="states-statement-description"> One message on the first working day of the month. </FieldDescription> </FieldContent> <Switch aria-labelledby="states-statement-title" aria-describedby="states-statement-description" /> </Field>
<FieldSet> <FieldLegend>Address</FieldLegend> <FieldGroup> <Field> <FieldLabel htmlFor="states-street">Street</FieldLabel> <Input id="states-street" autoComplete="address-line1" /> </Field> <Field> <FieldLabel htmlFor="states-city">City</FieldLabel> <Input id="states-city" autoComplete="address-level2" /> </Field> </FieldGroup> </FieldSet> </div> );}