Field

A wrapper component for form inputs with labels and validation.

Installation

Install the component package, shared coss-svelte theme, and Bits UI peer.

npm install coss-svelte @coss-svelte/theme bits-ui

Usage

Import the Svelte component exports directly from the package.

import { Field, FieldDescription, FieldError, FieldLabel, FieldValidity } from "coss-svelte";

Anatomy

  • Field
  • FieldDescription
  • FieldError
  • FieldLabel
  • FieldValidity

API Reference

Field

A wrapper component for form inputs with labels and validation.

PropTypeDefaultDescription
idstring-ID forwarded to the form control.
labelstring""Accessible label or fallback visible label for the control.
descriptionstring""Supporting text rendered by the component's built-in fallback layout.
errorstring""Validation message rendered by the field fallback layout.
requiredbooleanfalseMarks the field or label as required.
disabledbooleanfalseDisables interaction with the control.
invalidbooleanfalseMarks the component invalid independently of parse validity.
children : Snippet<[]>

Inherits from Svelte <div> attributes.

FieldDescription

Provides supporting copy for the parent component.

children : Snippet<[]>

Inherits from Svelte component attributes.

FieldError

Renders validation or error feedback for the parent field.

children : Snippet<[]>

Inherits from Svelte <p> attributes.

FieldLabel

Labels the parent component or a grouped section.

PropTypeDefaultDescription
requiredbooleanfalseMarks the field or label as required.
forstring-Configures the for behavior for this component.
children : Snippet<[]>

Inherits from Svelte <label> attributes.

FieldValidity

Renders validation state for the parent field.

children : Snippet<[]>

Inherits from Svelte component attributes.

Implementation Details

Status
Stable
Foundation
compound
Category
Forms & Validation
Particles
18