Skip to main content

Starwind UI v3.7 is here with stable Vue and Svelte, the new Chart component, and full RTL support. Read the release notes

Fieldset Primitive

Use Fieldset when several inputs answer the same question, such as a shipping address. A legend gives the group a name.

Contact details

Anatomy

Use the Astro primitive adapter to render Fieldset anatomy with the Runtime wiring included.

---
import { Fieldset } from "@starwind-ui/astro/fieldset";
---
<Fieldset.Root>
<Fieldset.Legend>Preferences</Fieldset.Legend>
</Fieldset.Root>

Astro, React, Vue, and Svelte components use the same underlying interactions. Each framework has its own way to read and update state. See the examples and your installed package’s types for the available props and events. Plain HTML uses DOM events and Runtime methods.

API Reference

Root

The main element that owns the Fieldset Runtime instance.

Default element
fieldset
Discovery hook
data-sw-fieldset
Role
-

Props

Prop Type Default Toggle
disabled boolean false
Description
Disables the Root part.
Kind
option
Targets
-
Full type
boolean

Data Attributes

Runtime hooks
Attribute Value Description
data-sw-fieldset - Marks the Root part so Starwind Runtime can find it.
Metadata
Attribute Value Description
data-disabled - Reflects the disabled prop on the Root part.

Legend

Legend text for the Fieldset fieldset.

Default element
div
Discovery hook
data-sw-fieldset-legend
Role
-

Data Attributes

Runtime hooks
Attribute Value Description
data-sw-fieldset-legend - Marks the Legend part so Starwind Runtime can find it.

Runtime API

Factory
createFieldset
Import
@starwind-ui/runtime/fieldset
Root hook
root data-sw-fieldset
Option props
disabled

Option Lifecycles

OptionLifecycle
disabledsetter-backed

Runtime Setters

Method Target Description
setDisabled prop: disabled Updates whether Fieldset is disabled from Runtime code.
Component Relationship
Field Composite

Changelog

View version history v1.0.4 7 releases

v1.0.4

  • In Vue, this component now needs Vue 3.5.21 or newer.

v1.0.3

  • In Astro, an attribute that you set on a Fieldset part now wins over the part's own default for the same attribute, such as `role` or `aria-label`.

v1.0.2

  • Fieldset keeps its accessible label linked to its current legend when that legend changes.
  • Reduced repeated JavaScript when Astro Fieldset is used with other Starwind components.

v1.0.1

  • Removed old comments from the Vue Primitive files that said the code was internal and not for release. The CLI also removes the blank line that these comments left in the Vue Primitive `index.ts` files that it copies into your project.

v1.0.0

  • This Primitive is now stable at version `1.0.0`. Its API and behavior stay the same as in the previous release.

v0.1.1

  • The React Primitive files that the CLI copies into your project are now marked with `"use client"`, so they stay client components in React server frameworks.

v0.1.0

  • First release. Fieldset groups fields under a legend. It can disable the fields or mark them invalid, and it connects its description for screen readers.