Pilipinas Interface

Foundation

  • Overview
  • Get Started
  • Colors
  • Typography
  • Icons
  • Layout & Spacing
  • States & Feedback
  • Motion & Transitions
  • Expressions

Components

  • Overview
  • Accordion
  • Alert
  • Avatar
  • Badge
  • Banner
  • Breadcrumb
  • Button
  • Card
  • Checkbox
  • Code Block
  • Combobox
  • Command Menu
  • Dialog
  • Popover
  • Progress
  • Radio Group
  • Scroll Area
  • Select
  • Skeleton
  • Switch
  • Table
  • Tabs
  • Text Field
  • Tooltip

Resources

  • Registry

Components

Text Field

A field is a label, a control and whatever the control needs to say. Labels sit flush with the control's edge; helper text and errors never share a line.

Preview

We only use it for account recovery.

As shown on a government ID.

Assigned on submission.

Try leaving the email blank.

<Field>
  <FieldLabel htmlFor="reference">Reference number</FieldLabel>
  <Input id="reference" />
  <FieldDescription>Printed on your receipt.</FieldDescription>
  <FieldError>Enter 12 digits.</FieldError>
</Field>

Usage

Every text control that needs a label, help and an error.

Do and don't

  • Do. Link the label and error to the control with htmlFor and aria-describedby.
  • Don't. Use the placeholder as a label or show help and error together.

Composition

Field is the wrapper. Put one of Input, Textarea, Combobox or Selectinside it. There is no separate Input documentation; the control's own props are standard input attributes plus size="default" | "compact".

Contract

  • FieldLabel is a real <label> tied to its control by htmlFor.
  • FieldDescription and FieldError link through aria-describedby, so a screen reader reads them on focus.
  • Errors announce via role="alert". Exactly one helper or one error renders at a time.
  • <Field data-invalid> tints its label like the control's own aria-invalid.
  • FieldSet + FieldLegend group related controls. Other slots are FieldContent, FieldTitle, FieldSeparator and FieldGroup.
  • FieldError also accepts an errors array of objects with an optional message.

Related

Labels and helper text use the Typography caption role; invalid states use the semantic ink in Colors.

← PreviousTabsNext →Tooltip

Install

npx shadcn@latest add @pilipinas/field

For your coding agent