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
    • Form validation
    • Text controls
    • Numeric controls
    • Selection controls
      • Guidelines
      • Checkboxes and radios
        • Guidelines
        • Switches
      • Basic select
      • Super select
      • Combo box
      • Selectable
    • 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
  • Selection controls
  • Checkboxes and radios
  • Switches

Switches

An EuiSwitch can be substituted for an EuiCheckbox when the semantics of the label dictate a true on/off state.

Loading...

Make sure to pass a

label to ensure a larger clickable area and ensure that screen readers will read out the label when the user is focused on the input. You can find more about labels usage in the guidelines tab.

If the switch is described in some other manner, like when using an EuiFormRow, you can eliminate the visible label with showLabel={false} or use it to further describe the state.

Accessibility requirement

When providing the state as the label, you'll need to provide an aria-describedby with the label's id to associate it with the switch.

Loading...

Props

EuiSwitch

Extends ButtonHTMLAttributes
𐘂𐘂
✄𐘗✄𐘗
Prop
↦
Description and type
↦
Default value
↵
Prop
label#
↦
Description and type

Must be a string if showLabel prop is false

Type: ReactNode
↦
Default value
Required
↵
Prop
checked#
↦
Description and type
Type: boolean
↦
Default value
Required
↵
Prop
onChange#
↦
Description and type
Type: (event: React.BaseSyntheticEvent<React.MouseEvent<HTMLButtonElement>, HTMLButtonElement, EventTarget & { checked: boolean; }>) => void
↦
Default value
Required
↵
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
↵
Prop
showLabel#
↦
Description and type

Whether to render the text label

Type: boolean
↦
Default value
true
↵
Prop
disabled#
↦
Description and type
Type: boolean
↦
Default value
↵
Prop
compressed#
↦
Description and type

Compressed switches are smaller and contain no icon signifiers

Type: boolean
↦
Default value
↵
Prop
labelProps#
↦
Description and type

Object of props passed to the label's <span />

Type: CommonProps & HTMLAttributes<HTMLSpanElement>
↦
Default value
↵
Prop
mini#
↦
Description and type

Mini styling is similar to compressed, but even smaller.
It's undocumented because it has very specific uses.

Type: boolean
↦
Default value
↵
𐘂𐘂
Edit this page

Previous
Guidelines
Next
Basic select
  • Props
EUI is dual-licensed under Elastic License 2.0 and Server Side Public License, v 1 | Crafted with ❤ by Elastic