Components
Field
Wraps a control with its label, hint, error and optional action, wired for assistive tech.
pnpm dlx shadcn@latest add @caliper/fieldWhen to use
Use it for
- Any form control that needs a label, help text or a validation message.
- You want errors announced when they appear.
Skip it when
- The control is labelled by its own content, like a switch row.
Installation
pnpm dlx shadcn@latest add @caliper/field
Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
import { useState, type ReactNode } from "react" import { Field } from "@/components/ui/field" import { Input } from "@/components/ui/input" function Panel({ title, context, className = "max-w-md", children }: { title: string; context: string; className?: string; children: ReactNode }) { return ( <section className={`grid w-full gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting ${className}`}> <div className="grid gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {children} </section> ); } export function EmailField() { const [email, setEmail] = useState("mara.chen@halden"); const invalid = !/^\S+@\S+\.\S+$/.test(email); return ( <Panel title="Billing contact" context="Invoices for Halden Analytics are sent here" className="max-w-sm"> <Field label="Work email" description="We only use it to send invoices." error={invalid ? "Enter a full address, like mara.chen@halden.app." : undefined} required> {(control) => <Input {...control} type="email" value={email} onChange={(event) => setEmail(event.currentTarget.value)} />} </Field> </Panel> ); }
API reference
Field
component
isEmail
component
No props of its own; it accepts the native props of its root element.
Accessibility
It is built on native elements and keeps aria-live and aria-hidden in step with state. Changes that matter are announced through a live region.
No custom key handling; Tab and the native activation keys do the work.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.