Forms Core Stable

FormField

Wraps a control with a label, help/error text and id wiring, so a screen reader gets the full picture without manual aria plumbing

Preview

Installation

pnpm add fancy-ui-svelte
import { FormField } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { FormField } from 'fancy-ui-svelte';
</script>

<FormField />

Examples

Basic Usage

A labelled field with help text underneath.

With Error

error replaces the help text and marks the field invalid.

Validated

valid's decorative checkmark, plus a control drawing its own success look.

Disabled

disabled reaches the control through context.

Props

PropTypeDefaultDescription
label string-Label text — the common case. For custom label markup, render a Label in children instead
description string-Help text under the control, replaced by error while the field is invalid
error string-Error text. Setting it marks the field invalid and replaces the help text
valid booleanfalseDecorative checkmark next to the help text; error always wins if both are set
required booleanfalseMarks the field required: the label gets an asterisk, the control gets aria-required
disabled booleanfalseDisables the field: reaches the wrapped control through context
id string-Opts out of the generated id. description/error ids are suffixes of this same value
class string-Additional CSS classes, merged onto the root
ref HTMLDivElement | nullnullBindable reference to the root element

Slots

SlotDescription
childrenThe control