---
title: Fieldset
description: Group related form controls with legends, descriptions, and actions
links:
  source: fieldset/fieldset.tsx
  styles: fieldset.css
  storybook: Components/Forms/Fieldset
---

## Usage

```tsx
import { Fieldset } from '@heroui/react';
```

<ComponentPreview name="fieldset-basic" />

## Anatomy

```tsx
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>
)
```

## Examples

### In Surface

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

<ComponentPreview name="fieldset-on-surface" />

## Customization

### Tailwind CSS

<ComponentPreview name="fieldset-custom-styles" />

### Global CSS

Use the `@layer components` directive to target Fieldset [BEM](https://getbem.com/)-style classes.

```css
@layer components {
  .fieldset {
    @apply gap-5 rounded-xl border border-border/60 bg-surface 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;
  }
}
```

## Styling Reference

HeroUI follows the [BEM](https://getbem.com/) methodology to ensure component variants and states are reusable and easy to customize.

### CSS Classes

The Fieldset compound component exposes these CSS selectors:

#### Base Classes [!toc]

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

## API Reference

### Fieldset

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `className` | `string` | - | Tailwind CSS classes applied to the root element. |
| `children` | `React.ReactNode` | - | Fieldset content (legend, groups, descriptions, actions). |
| `nativeProps` | `React.HTMLAttributes<HTMLFieldSetElement>` | Supports native fieldset attributes and events. |

### Fieldset.Legend

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `className` | `string` | - | Tailwind classes for the legend element. |
| `children` | `React.ReactNode` | - | Legend content, usually plain text. |
| `nativeProps` | `React.HTMLAttributes<HTMLLegendElement>` |  - | Native legend attributes. |

### Fieldset.Group

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `className` | `string` | - | Layout and spacing classes for grouped fields. |
| `children` | `React.ReactNode` | - | Form controls to group inside the fieldset. |
| `nativeProps` | `React.HTMLAttributes<HTMLDivElement>` | - | Native div attributes. |

### Fieldset.Actions

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `className` | `string` | - | Tailwind classes to align action buttons or text. |
| `children` | `React.ReactNode` | - | Action buttons or helper text. |
| `nativeProps` | `React.HTMLAttributes<HTMLDivElement>` | - | Native div attributes. |

## Related Showcases

<RelatedShowcases component="Fieldset" />

## Related Components

<RelatedComponents component="fieldset" />
