Skip to main content
Elastic UI
Elastic UI
ComponentsPatternsContentData visualization
EUI ChangelogGitHubFigma
  • Guidelines
    • Getting started
    • Accessibility
    • Writing
    • Testing
  • Theming
    • Theme provider
    • Color mode
    • High contrast mode
    • Borders
    • Breakpoints
    • Colors
    • Sizing
    • Typography
  • Templates
    • Page template
    • Sitewide search
  • Layout
    • Accordion
    • Bottom bar
    • Flex
    • Flyout
    • Header
    • Horizontal rule
    • Modal
    • Page components
    • Page header
    • Panel
    • Popover
    • Resizable container
    • Spacer
  • Navigation
    • Breadcrumbs
    • Buttons
    • Collapsible nav
    • Context menu
    • Facet
    • Key pad menu
    • Link
    • Pagination
    • Side nav
    • Steps
    • Tabs
    • Tree view
  • Display
    • Aspect ratio
    • Avatar
    • Badge
    • Callout
    • Card
    • Comment list
    • Description list
    • Drag and drop
    • Empty prompt
    • Health
    • Icons
    • Image
    • List group
    • Loading
    • Progress
    • Skeleton
    • Stat
    • Text
    • Timeline
    • Title
    • Toast
    • Tooltip
    • Tour
  • Forms
    • Form controls
    • Form layouts
      • Guidelines
      • Form rows
      • Described form groups
      • Compressed forms
      • Form labels
      • Prepends and appends
      • Form control layouts
    • Form validation
    • Text controls
    • Numeric controls
    • Selection controls
    • Search and filter controls
    • Date and time controls
    • Other controls
  • Tabular content
    • Tables
    • Data grid
  • Editors & Syntax
    • Code
    • Markdown
  • Utilities
    • Accessibility
    • Auto sizer
    • Beacon
    • Color palettes
    • Copy
    • CSS utility classes
    • Delay
    • Error boundary
    • Focus trap
    • Highlight and mark
    • HTML ID generator
    • I18n
    • Inner text
    • Mutation observer
    • Outside click detector
    • Overlay mask
    • Portal
    • Pretty duration
    • Provider
    • Resize observer
    • Scroll
    • Text diff
    • Text truncation
    • Window events
  • EUI
  • Forms
  • Form layouts
  • Form labels

Form labels

The best way to provide an accessible name to form elements is to use the

label prop provided by EuiFormRow. However, certain types of form controls require extra care to ensure an accessible experience. Below are just a few examples.

Form controls that come with their own label donβ€˜t need the one provided by EuiFormRow. For controls like EuiSwitch, EuiButton, and EuiLink be sure to pass hasChildLabel={false} to the wrapping EuiFormRow.

Loading...

Implicit titles for the first form control

When displaying the form control's name in some other way than through the visual label prop, the form control still needs to be associated with that element. To do this, either:

  • duplicate the text and pass it as the aria-label of the form control, or
  • pass the id of the text to the form control's aria-labelledby.
Loading...

More complicated form labels

Some controls are just hard though and will often require some custom work. Refer to an individual componentβ€˜s documentation and remember to test with a screen reader!

Loading...

Fieldset and legend

Use EuiFormFieldset for groups of related controls where the individual labels for each control do not provide a sufficient description and an additional group level description is needed accessible name.

EuiFormFieldset wraps its children in a <fieldset> with the option to add a <legend> via the legend object prop. While most commonly used for

checkboxes and radios, it can also be used to group related inputs and selects under a shared label.

Loading...

Props

EuiFormLabel

Extends HTMLAttributes
π˜‚π˜‚
βœ„π˜—βœ„π˜—
Prop
↦
Description and type
↦
Default value
↡
Prop
type#
↦
Description and type

Default type is a label but can be changed to a legend
if using inside a fieldset.

Type: "label" | "legend"
↦
Default value
label
↡
Prop
isFocused#
↦
Description and type
Type: boolean
↦
Default value
↡
Prop
isInvalid#
↦
Description and type
Type: boolean
↦
Default value
↡
Prop
isDisabled#
↦
Description and type

Changes cursor to default.

Type: boolean
↦
Default value
↡
Prop
className#
↦
Description and type
Type: string
↦
Default value
↡
Prop
aria-label#
↦
Description and type

Defines a string value that labels the current element.
@see aria-labelledby.

Type: string
↦
Default value
↡
Prop
data-test-subj#
↦
Description and type
Type: string
↦
Default value
↡
Prop
css#
↦
Description and type
Type: Interpolation<Theme>
↦
Default value
↡
π˜‚π˜‚

EuiFormFieldset

Extends HTMLAttributes
π˜‚π˜‚
βœ„π˜—βœ„π˜—
Prop
↦
Description and type
↦
Default value
↡
Prop
legend#
↦
Description and type

Adds an EuiFormLegend element as the first child

Type: EuiFormLegendProps
↦
Default value
↡
Prop
className#
↦
Description and type
Type: string
↦
Default value
↡
Prop
aria-label#
↦
Description and type
Type: string
↦
Default value
↡
Prop
data-test-subj#
↦
Description and type
Type: string
↦
Default value
↡
Prop
css#
↦
Description and type
Type: Interpolation<Theme>
↦
Default value
↡
π˜‚π˜‚
Edit this page

Previous
Compressed forms
Next
Prepends and appends
  • Implicit titles for the first form control
  • More complicated form labels
  • Fieldset and legend
  • Props
EUI is dual-licensed under Elastic License 2.0 and Server Side Public License, v 1 | Crafted with ❀ by Elastic