FieldsetNew
Group related form controls with legends, descriptions, and actions
Import
import { Fieldset } from '@heroui/react';Usage
"use client";
import {
  Button,
  Description,
  FieldError,
  Fieldset,
  Form,
  Input,
  Label,
  TextArea,
  TextField,
} from "@heroui/react";
import {Icon} from "@iconify/react";
export function Basic() {
  const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    const formData = new FormData(e.currentTarget);
    const data: Record<string, string> = {};
    // Convert FormData to plain object
    formData.forEach((value, key) => {
      data[key] = value.toString();
    });
    alert("Form submitted successfully!");
  };
  return (
    <Form className="w-full max-w-96" onSubmit={onSubmit}>
      <Fieldset>
        <Fieldset.Legend>Profile Settings</Fieldset.Legend>
        <Description>Update your profile information.</Description>
        <Fieldset.Group>
          <TextField
            isRequired
            name="name"
            validate={(value) => {
              if (value.length < 3) {
                return "Name must be at least 3 characters";
              }
              return null;
            }}
          >
            <Label>Name</Label>
            <Input placeholder="John Doe" />
            <FieldError />
          </TextField>
          <TextField isRequired name="email" type="email">
            <Label>Email</Label>
            <Input placeholder="john@example.com" />
            <FieldError />
          </TextField>
          <TextField
            isRequired
            name="bio"
            validate={(value) => {
              if (value.length < 10) {
                return "Bio must be at least 10 characters";
              }
              return null;
            }}
          >
            <Label>Bio</Label>
            <TextArea placeholder="Tell us about yourself..." />
            <Description>Minimum 10 characters</Description>
            <FieldError />
          </TextField>
        </Fieldset.Group>
        <Fieldset.Actions>
          <Button type="submit">
            <Icon icon="gravity-ui:floppy-disk" />
            Save changes
          </Button>
          <Button type="reset" variant="secondary">
            Cancel
          </Button>
        </Fieldset.Actions>
      </Fieldset>
    </Form>
  );
}Anatomy
Import all parts and piece them together.
import {Fieldset} from '@heroui/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} from '@heroui/react';
function CustomFieldset() {
  return (
    <Fieldset className="rounded-xl border border-border bg-surface-2 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.
@layer components {
  .fieldset {
    @apply gap-5 rounded-xl border border-border/60 bg-surface-2 p-6 shadow-field;
  }
  .fieldset__legend {
    @apply text-lg font-semibold;
  }
  .fieldset_field_group {
    @apply gap-3 md:grid md:grid-cols-2;
  }
  .fieldset_actions {
    @apply flex justify-end gap-2 pt-2;
  }
}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
| Prop | Type | Default | Description | 
|---|---|---|---|
asChild | boolean | false | Render the fieldset as a custom component via Slot. | 
className | string | - | Tailwind CSS classes applied to the root element. | 
children | React.ReactNode | - | Fieldset content (legend, groups, descriptions, actions). | 
ref | React.Ref<HTMLFieldSetElement> | - | Ref forwarded to the fieldset element. | 
nativeProps | React.HTMLAttributes<HTMLFieldSetElement> | Supports native fieldset attributes and events. | 
Fieldset.Legend Props
| Prop | Type | Default | Description | 
|---|---|---|---|
asChild | boolean | false | Render the legend as another component with Slot. | 
className | string | - | Tailwind classes for the legend element. | 
children | React.ReactNode | - | Legend content, usually plain text. | 
ref | React.Ref<HTMLLegendElement> | - | Ref forwarded to the legend element. | 
nativeProps | React.HTMLAttributes<HTMLLegendElement> | - | Native legend attributes. | 
Fieldset.Group Props
| Prop | Type | Default | Description | 
|---|---|---|---|
asChild | boolean | false | Render the group as a different component. | 
className | string | - | Layout and spacing classes for grouped fields. | 
children | React.ReactNode | - | Form controls to group inside the fieldset. | 
ref | React.Ref<HTMLDivElement> | - | Ref forwarded to the group wrapper. | 
nativeProps | React.HTMLAttributes<HTMLDivElement> | - | Native div attributes. | 
Fieldset.Actions Props
| Prop | Type | Default | Description | 
|---|---|---|---|
asChild | boolean | false | Render the actions container as a custom component. | 
className | string | - | Tailwind classes to align action buttons or text. | 
children | React.ReactNode | - | Action buttons or helper text. | 
ref | React.Ref<HTMLDivElement> | - | Ref forwarded to the actions container. | 
nativeProps | React.HTMLAttributes<HTMLDivElement> | - | Native div attributes. |