Field
Combine labels, controls, and help text to compose accessible form fields and grouped inputs.
Installation
pnpm add @heyramzi/uiUsage
import * as Field from "@heyramzi/ui/shadcn/field";<Field.Set>
<Field.Legend>Payment method</Field.Legend>
<Field.Description>All transactions are secure and encrypted.</Field.Description>
<Field.Group>
<Field.Field>
<Field.Label for="card-number">Card number</Field.Label>
<input id="card-number" placeholder="1234 5678 9012 3456" />
<Field.Description>Enter your 16-digit number.</Field.Description>
</Field.Field>
</Field.Group>
</Field.Set>Keyboard and accessibility
- Field is a group. A FieldSet with a FieldLegend names a whole set of controls.
- FieldError has role="alert", so it's read out when it appears.
- Field doesn't link the description or error to the control. Set aria-describedby yourself, or use SimpleField, which does.
API reference
Field
orientation"vertical" | "horizontal" | "responsive"- Default
"vertical" refbindableHTMLDivElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
orientation | "vertical" | "horizontal" | "responsive" | "vertical" |
ref bindable | HTMLDivElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Set
refbindableHTMLFieldsetElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLFieldsetAttributesfromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLFieldsetElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLFieldsetAttributes from svelte/elements | |
Legend
variant"legend" | "label"- Default
"legend" refbindableHTMLLegendElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLLegendElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
variant | "legend" | "label" | "legend" |
ref bindable | HTMLLegendElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLLegendElement> from svelte/elements | |
Group
refbindableHTMLDivElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLDivElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Content
refbindableHTMLDivElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLDivElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Label
refbindableLabel- Default
null classstringchildrenSnippet...rest- Every prop of
Label
| Prop | Type | Default |
|---|---|---|
ref bindable | Label | null |
class | string | |
children | Snippet | |
...rest | Every prop of Label | |
Title
refbindableHTMLDivElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLDivElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Description
refbindableHTMLParagraphElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLParagraphElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLParagraphElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLParagraphElement> from svelte/elements | |
Separator
childrenSnippetrefbindableHTMLDivElement | null- Default
null classstring...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
children | Snippet | |
ref bindable | HTMLDivElement | null | null |
class | string | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Error
childrenSnippeterrors{ message?: string }[]refbindableHTMLDivElement | null- Default
null classstring...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
children | Snippet | |
errors | { message?: string }[] | |
ref bindable | HTMLDivElement | null | null |
class | string | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Simple
labelstringdescriptionstringerrorstringforstring- Id of the control the label binds to. Also picks the control that gets the message link.
labelVariant"default" | "muted"- Default
"default" - "default" is text-sm foreground; "muted" is a text-xs micro-label.
classstringchildrenrequiredSnippet
| Prop | Type | Default |
|---|---|---|
label | string | |
description | string | |
error | string | |
for Id of the control the label binds to. Also picks the control that gets the message link. | string | |
labelVariant "default" is text-sm foreground; "muted" is a text-xs micro-label. | "default" | "muted" | "default" |
class | string | |
children required | Snippet |