Field
We'll never share it.
That name is taken.
Where you're based.
Optional.
Weekdays only.
A form-field wrapper that links a label, optional description and error message
to a control, wiring aria-describedby / aria-invalid for you.
Import
Section titled “Import”<script> import Field from "@invisible-ui/svelte/Field.svelte";</script><script setup> import { Field } from "@invisible-ui/vue";</script>import { Field } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-field></ds-field>| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Field label. |
description | string | undefined | undefined | Helper text. |
error | string | undefined | undefined | Error message (sets aria-invalid). |
required | boolean | false | Mark the field required. |
disabled | boolean | false | Disable styling/state. |
id | string | undefined | undefined | Control id. |
children | Snippet<[{ controlProps: FieldApi["controlProps"]; controlId: string }]> | undefined | undefined | The control, given the props to spread onto it and its id. |
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | The field label. |
description | string | undefined | Optional helper/description text. |
error | string | undefined | Optional error message; when set, the field is marked invalid. |
required | boolean | false | Whether the control is required. |
disabled | boolean | false | Whether the field is disabled. |
id | string | undefined | Base id; auto-generated when omitted. |
Slots: default.
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | The field label. |
description | string | — | Optional helper text. |
error | string | — | Optional error message; when set, the control is marked invalid. |
required | boolean | false | |
disabled | boolean | false | |
id | string | — | Base id. Generated when omitted. |
children | (control: FieldControl) => ReactNode | — | Renders the control from the props to spread onto it and its id. |
| Attribute | Reactive | Description |
|---|---|---|
label * | yes | |
description | yes | |
error | yes | |
required | yes | |
disabled | yes | |
field-id | — | read once at mount — see below |
Reactive attributes re-render the element when they change after the first render.
In Svelte, the control is the children snippet, which receives controlProps and controlId:
<Field label="Email"> {#snippet children({ controlProps })} <input {...controlProps} type="email" /> {/snippet}</Field>In React, children is a function that receives controlProps and
controlId, and useField wires markup of your own:
<Field label="Email" error={error}> {({ controlProps }) => <input {...controlProps} type="email" />}</Field>Themeable via --ds-field-*.