Field Set

Fieldsets encapsulate the composition of form controls, labels & validation messages with the necessary attributes to ensure good accessibility for screen readers.

FieldSet

Maven Central Class reference Source code

Default

Day Night
FieldSet component FieldSet component - dark mode

Error

Day Night
Error FieldSet component Error FieldSet component - dark mode

Validated

Day Night
Validated FieldSet component Validated FieldSet component - dark mode

Disabled

Day Night
Disabled FieldSet component Disabled FieldSet component - dark mode

Installation

Backpack Compose is available through Maven Central. Check the main Readme for a complete installation guide.

Usage

FieldSet is a component which wraps its content (user input or form element) and adds optional title, description and error labels around it depending on the field status.

The statuses available are Default, Disabled, Error and Validated. The statuses are automatically dispatched to the child element (if the children support it).

Example of a FieldSet with Validated status:


                                                
                                                import net.skyscanner.backpack.compose.fieldset.BpkFieldSet
                                                import net.skyscanner.backpack.compose.fieldset.BpkFieldStatus
                                                
                                                BpkFieldSet(
                                                  status = BpkFieldStatus.Validated,
                                                  label = "Title (optional)",
                                                  description = "Description (optional)",
                                                ) {
                                                    // field content – for instance, BpkTextField()
                                                }

Example of a FieldSet with Error status:


                                                
                                                import net.skyscanner.backpack.compose.fieldset.BpkFieldSet
                                                import net.skyscanner.backpack.compose.fieldset.BpkFieldStatus
                                                
                                                BpkFieldSet(
                                                  status = BpkFieldStatus.Error("Error text"),
                                                  label = "Title (optional)",
                                                  description = "Description (optional)",
                                                ) {
                                                    // field content – for instance, BpkTextField()
                                                }