Skip to content
PorabuildHeroGPUI component library
v0.14.0 · Apache-2.0

Forms

Fieldset

Group related form controls under a legend.

Rust
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.

In Surface

Runs in a view's render: self is the view holding this example's state and cx is its Context<Self>.

Rust
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),
            )),
    )

Usage

Runs in a view's render: self is the view holding this example's state and cx is its Context<Self>.

Rust
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

Fieldset builders
BuilderValuesDefaultDescription
id(ElementId)string—Optional GPUI identity. A named fieldset reports role=group; an unnamed one produces no AccessKit node.
ParentElement::extendPartialAnyElement—Fieldset content: legend, groups, descriptions and actions, composed as ordered children.
FieldsetLegend::new(text)PartialAnyElement—Legend content, usually plain text. Takes the caption text.
FieldGroup::new() / ParentElement::extendPartialAnyElement—Form controls to group inside the fieldset.
FieldsetActions::new() / ParentElement::extendPartialAnyElement—Action buttons or helper text in the trailing row.
Not ported8 HeroUI entries not ported
Fieldset builders not ported
HeroUI v3Why it is not ported
Fieldset.classNameTailwind styles applied to the root element.
Fieldset.nativePropsNative 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.classNameTailwind classes for the legend element.
Fieldset.Legend.nativePropsNative legend attributes.
Fieldset.Group.classNameLayout and spacing classes for grouped fields.
Fieldset.Group.nativePropsNative div attributes.
Fieldset.Actions.classNameTailwind classes to align action buttons or text.
Fieldset.Actions.nativePropsNative div attributes.

Parts

Fieldset parts
PartDescription
FieldsetRoot 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.