Package org.patternfly.component.switch_


package org.patternfly.component.switch_
Provides a switch (toggle) component for binary on/off selections.

A switch is used to toggle the state of a setting between two options (on and off). It supports labels, reversed layout, check icons, and a disabled state. The package name uses a trailing underscore because switch is a reserved Java keyword.

Usage

Create a switch with an ID, name, and initial checked state:

 import static org.patternfly.component.switch_.Switch.switch_;

 // Basic switch with a label
 Switch toggle = switch_("my-switch", "my-switch", true)
         .label("Enable notifications");

 // Reversed layout (label before switch)
 Switch reversed = switch_("reversed", "reversed", true)
         .reversed()
         .label("Reversed layout");

 // Without a label, using a check icon and ARIA label
 Switch noLabel = switch_("no-label", "no-label", true)
         .checkIcon()
         .ariaLabel("Toggle feature");

 // Disabled switch
 Switch disabled = switch_("disabled", "disabled", true)
         .disabled()
         .label("Disabled option");
See Also:
  • Classes
    Class
    Description
    A switch toggles the state of a setting (between on and off).