8.4k

Field

A component that provides labelling and validation for form controls.

API Reference

Installation

pnpm dlx shadcn@latest add https://coss.com/ui/r/field.json

Usage

import {
  Field,
  FieldControl,
  FieldDescription,
  FieldError,
  FieldLabel,
  FieldValidity,
} from "@/components/ui/field"
<Field>
  <FieldLabel>Name</FieldLabel>
  <FieldControl type="text" placeholder="Enter your name" />
  <FieldDescription>Visible on your profile</FieldDescription>
  <FieldError>Please enter a valid name</FieldError>
  <FieldValidity>
    {(validity) => (
      {validity.error && <p>{validity.error}</p>}
    )}
  </FieldValidity>
</Field>

Examples

Required Field

Disabled Field

With Error

Enter an invalid email address and press enter to see the error.

With Validity

Autocomplete Field

Combobox Field

Combobox Multiple Field

Textarea Field

Select Field

Checkbox Field

Checkbox Group Field

Radio Group Field

Switch Field

Slider Field

Number Field

Complete Form Example

coss.com ui

Built by and for the team of Cal.com, Inc. — the leading commercial open source company (“coss”).