Forms

Fieldset

Group related form controls with legends, descriptions, and actions

Completeness: styles-sufficient

The stylesheet is the whole component. There is no keyboard map beyond what the native element already does and nothing sets state at runtime that the CSS keys on, so a CSS-only port reproduces it.

Import

import { Fieldset } from '@blakeui/react';

Usage

Profile SettingsUpdate your profile information.
Minimum 10 characters
"use client";

import {
  Button,
  Description,

In Surface

When used inside a Surface component, use variant="secondary" on form controls (Input, TextArea, etc.) to apply the lower emphasis variant suitable for surface backgrounds.

Profile SettingsUpdate your profile information.
Minimum 10 characters
"use client";

import {
  Button,
  Description,

Anatomy

Import the Fieldset component and access all parts using dot notation.

import { Fieldset } from '@blakeui/react';

export default () => (
  <Fieldset>
    <Fieldset.Legend />
    <Fieldset.Group>
      {/* form fields go here */}
    </Fieldset.Group>
    <Fieldset.Actions>
      {/* action buttons go here */}
    </Fieldset.Actions>
  </Fieldset>
)

Styling

Passing Tailwind CSS classes

import { Fieldset, TextField, Label, Input } from '@blakeui/react';

function CustomFieldset() {
  return (
    <Fieldset className="rounded-xl border border-border bg-surface p-6 shadow-sm">
      <Fieldset.Legend className="text-lg font-semibold">Team members</Fieldset.Legend>
      <Fieldset.Group className="grid gap-4 md:grid-cols-2">
        <TextField>
          <Label>First name</Label>
          <Input className="rounded-full border-border/60" placeholder="Jane" />
        </TextField>
        <TextField>
          <Label>Last name</Label>
          <Input className="rounded-full border-border/60" placeholder="Doe" />
        </TextField>
      </Fieldset.Group>
      <Fieldset.Actions className="justify-end gap-3">
        {/* Action buttons */}
      </Fieldset.Actions>
    </Fieldset>
  );
}

Customizing the component classes

Use the @layer components directive to target Fieldset BEM-style classes.

A worked example is in Styling.

CSS Classes

The Fieldset compound component exposes these CSS selectors:

  • .fieldset – Root container
  • .fieldset__legend – Legend element
  • .fieldset__field_group – Wrapper for grouped fields
  • .fieldset__actions – Action bar below the fields

API Reference

Fieldset Props

PropTypeDefaultDescription
classNamestring-Tailwind CSS classes applied to the root element.
childrenReact.ReactNode-Fieldset content (legend, groups, descriptions, actions).
nativePropsReact.HTMLAttributes<HTMLFieldSetElement>Supports native fieldset attributes and events.

Fieldset.Legend Props

PropTypeDefaultDescription
classNamestring-Tailwind classes for the legend element.
childrenReact.ReactNode-Legend content, usually plain text.
nativePropsReact.HTMLAttributes<HTMLLegendElement>-Native legend attributes.

Fieldset.Group Props

PropTypeDefaultDescription
classNamestring-Layout and spacing classes for grouped fields.
childrenReact.ReactNode-Form controls to group inside the fieldset.
nativePropsReact.HTMLAttributes<HTMLDivElement>-Native div attributes.

Fieldset.Actions Props

PropTypeDefaultDescription
classNamestring-Tailwind classes to align action buttons or text.
childrenReact.ReactNode-Action buttons or helper text.
nativePropsReact.HTMLAttributes<HTMLDivElement>-Native div attributes.

On this page