Fieldset
Group related form controls under a legend.
use herogpui::components::field::{Fieldset, FieldGroup, FieldsetLegend, FieldsetActions};Fieldset on docs.rsSource at v0.14.0
Usage
Showing In Surface, live: HeroGPUI compiled to WebAssembly. The canvas has no accessibility tree; each example's description and code below carry the same information.
Runs in a view's render: self is the view holding this example's state and cx is its Context<Self>.
use herogpui::prelude::{Button, FieldGroup, FieldVariant, Fieldset, FieldsetActions, FieldsetLegend, Size, Surface, TextField};
use herogpui::gpui::prelude::*;
use herogpui::gpui::px;
Surface::new()
.padding(px(24.))
.gap(px(16.))
.child(
Fieldset::new()
.child(FieldsetLegend::new("Profile"))
.child(
FieldGroup::new()
.child(
TextField::new(self.demo_text("fset-name", "", cx))
.label("Name")
.placeholder("Ada Lovelace")
.variant(FieldVariant::Secondary),
)
.child(
TextField::new(self.demo_text("fset-email", "", cx))
.label("Email")
.placeholder("ada@example.com")
.variant(FieldVariant::Secondary),
),
)
.child(FieldsetActions::new().child(
Button::new("fieldset-save").label("Save").size(Size::Sm),
)),
)Runs in a view's render: self is the view holding this example's state and cx is its Context<Self>.
use herogpui::prelude::{Button, FieldGroup, Fieldset, FieldsetActions, FieldsetLegend, TextField, Variant};
use herogpui::gpui::prelude::*;
Fieldset::new()
.child(FieldsetLegend::new("Shipping address"))
.child(
FieldGroup::new()
.child(
TextField::new(self.input_name.clone())
.label("Street")
.placeholder("221B Baker Street"),
)
.child(
TextField::new(self.input_email.clone())
.label("City")
.placeholder("London"),
),
)
.child(
FieldsetActions::new()
.child(
Button::new("fieldset-cancel")
.label("Cancel")
.variant(Variant::Tertiary),
)
.child(Button::new("fieldset-save").label("Save")),
)Anatomy
Rust types
FieldsetFieldsetLegendFieldGroupFieldsetActions
Fieldset is assembled from these builders. The API reference lists each one.
API reference
Against HeroUI v3.2.6: 5 entries ported, 4 partial, 8 not ported. Partial rows are marked in the tables; entries not ported are listed under each table with the reason.
Builders
| Builder | Values | Default | Description |
|---|---|---|---|
id( | string | — | Optional GPUI identity. A named fieldset reports role=group; an unnamed one produces no AccessKit node. |
ParentElement::Partial | AnyElement | — | Fieldset content: legend, groups, descriptions and actions, composed as ordered children. |
FieldsetLegend::Partial | AnyElement | — | Legend content, usually plain text. Takes the caption text. |
FieldGroup::Partial | AnyElement | — | Form controls to group inside the fieldset. |
FieldsetActions::Partial | AnyElement | — | Action buttons or helper text in the trailing row. |
Not ported8 HeroUI entries not ported
| HeroUI v3 | Why it is not ported |
|---|---|
Fieldset.className | Tailwind styles applied to the root element. |
Fieldset.nativeProps | Native fieldset attributes and events. GPUI has no attribute graph, and the native `disabled` forwarding in particular has no analogue — there is no ancestor context propagation to disable composed descendants, so deliberately ships no disabled state on Fieldset. |
Fieldset.Legend.className | Tailwind classes for the legend element. |
Fieldset.Legend.nativeProps | Native legend attributes. |
Fieldset.Group.className | Layout and spacing classes for grouped fields. |
Fieldset.Group.nativeProps | Native div attributes. |
Fieldset.Actions.className | Tailwind classes to align action buttons or text. |
Fieldset.Actions.nativeProps | Native div attributes. |
Parts
| Part | Description |
|---|---|
Fieldset | Root group on the `.fieldset` BEM class: `flex flex-col gap-6` with `shrink grow basis-0` (the Safari flexbox fix for a fieldset with a legend inside a flex parent), foreground text. |
FieldsetLegend | `text-base font-medium text-foreground` — 16px medium, not semibold. |
FieldGroup | `w-full space-y-4`: the full-width stack of grouped fields, 16px apart. |
FieldsetActions | `flex items-center gap-2 pt-1`: the trailing row for submit/cancel controls, 8px apart with a 4px top offset. |