Default
A set of labeled controls: a legend in the script font, fields that stack label, control and help, and the gaps between them. Nothing is drawn but the controls; Field is layout and words.
The words around a control: a label, help text and an error, stacked or in a row, grouped in sets with a legend. It is layout, so the only drawings are the wavy red pencil underline of an error and the hand-drawn card around a choice (a label that wraps a radio or checkbox with its own title and help).
npx shadcn@latest add @wobko/field第一次使用?先把 registry 加进 components.json。 如何安装
A set of labeled controls: a legend in the script font, fields that stack label, control and help, and the gaps between them. Nothing is drawn but the controls; Field is layout and words.
`vertical` (label above), `horizontal` (label beside a switch or checkbox, with FieldContent holding the words) and `responsive` (vertical until its FieldGroup is md wide, using a container query, so it follows the box, not the screen).
A FieldLabel around a whole Field becomes a hand-drawn card; when the radio or checkbox inside it is checked the card gets a highlighter wash and a felt box. Click anywhere on a card.
`FieldError` takes children or an `errors` array: one message is text, several are a list, duplicates collapse. It is announced as an alert and wears a wavy red pencil underline; `data-invalid` on the Field turns the label red, `aria-invalid` on the control draws its box red.
shadcn's `field-demo`, the big one: two FieldSets with legends, a three-column row of Month, Year and CVV, a checkbox row, a comment box and a pair of buttons, all separated by a FieldSeparator.
shadcn's `field-input`: a description can sit under the control (Username) or between the label and the control (Password); the order in the JSX is the order on the page.
shadcn's `field-textarea`: a labeled ruled box with a hint underneath. `rows` sets the height, as on a plain textarea.
shadcn's `field-fieldset`: a real `<fieldset>` with a legend and a line of help, a full-width field and a two-column row of City and Postal Code.
shadcn's `field-radio`: a RadioGroup inside a FieldSet, each option a horizontal Field with the button first and its label after it.
shadcn's `field-checkbox`: a legend styled as a label over a tight group of boxes, then, below a separator, one box whose label and description share a FieldContent column.
shadcn's `field-switch`: label and description in a FieldContent column, the switch at the far end of a horizontal Field. Click the words or the switch.
shadcn's `field-slider`: a range slider has no single control to label, so FieldTitle names it (and `aria-label` goes on the slider). The description reads the two values out.
shadcn's `field-select`: a Radix Select under a label with a hint. The label points at the trigger (`htmlFor` and `id`, which the original leaves out), so a click on the word opens the list.
shadcn's `field-choice-card`: a FieldLabel wrapped around a whole Field makes the row one big target. Here each card is a small hand-drawn slip, and the checked one gets the highlighter wash.
shadcn's `field-group`: FieldGroups stack fields and FieldSets, and `data-slot="checkbox-group"` tightens the gap between boxes. The first box is checked and disabled, the second set has a link in its help line.
shadcn's `field-responsive`: `orientation="responsive"` stacks label above control on a narrow container and puts them side by side once the FieldGroup is wide enough. It answers to the container, not the viewport, so resize the preview.
The title of a set (a `<legend>`).
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| variant | "legend" | "label" | "legend" | `legend` is set in the script font; `label` like a Label. |
One labeled thing: a role=group with the control, label, help and error in it. `data-invalid="true"` turns its words red; `data-disabled="true"` dims the label.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| orientation | "vertical" | "horizontal" | "responsive" | "vertical" | Label above, label beside, or vertical until the FieldGroup is md wide (a container query). |
A Label. When a direct child is a whole `Field` it turns into a choice card: a hand-drawn box that gets a highlighter wash and a felt outline when a control inside it is checked.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| card | boolean | - | Force the choice-card drawing on or off (default: on when a direct child is a Field). Use it when the Field is wrapped in your own component. |
| seed | string | number | - | Pins the hand of the card. |
The message under a field, announced as an alert and underlined with a wavy red pencil line. Renders nothing when there is nothing to say.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| errors | Array<{ message?: string } | undefined> | - | react-hook-form / zod style errors: one message is text, several a bullet list, duplicates once. |
| children | ReactNode | - | Your own message; wins over `errors`. |
| seed | string | number | - | Pins the hand of the underline. |
CLI 会复制进你项目的文件。
正在加载源码