Billing details
Group fields in a fieldset with a legend, one hint and one associated error. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.
"use client"
import * as React from "react"
import {
Field,
FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
FieldLegend,
FieldSet,
} from "@/components/ui/field"
import { Input } from "@/components/ui/input"
export function FieldBillingDetails() {
const id = React.useId()
return (
<div className="flex w-full max-w-md flex-col gap-10">
<FieldSet className="w-full max-w-md">
<FieldLegend>Billing details</FieldLegend>
<FieldGroup>
<Field>
<FieldLabel htmlFor="field-demo-company">Company</FieldLabel>
<Input id="field-demo-company" placeholder="Acme Inc." aria-describedby="field-demo-company-hint" />
<FieldDescription id="field-demo-company-hint">
Appears on every invoice we send.
</FieldDescription>
</Field>
<Field>
<FieldLabel htmlFor="field-demo-vat">VAT number</FieldLabel>
<Input id="field-demo-vat" defaultValue="12" aria-invalid aria-describedby="field-demo-vat-error" />
<FieldError id="field-demo-vat-error">A VAT number has at least 8 characters.</FieldError>
</Field>
</FieldGroup>
</FieldSet>
</div>
)
}