Package org.patternfly.component.togglegroup
package org.patternfly.component.togglegroup
Provides a toggle group component for selecting one or multiple options from a group of buttons.
A toggle group is a set of toggle items that can operate in single-select or multi-select mode. Items can display text, icons, or both, and support compact and disabled states.
Key Classes
ToggleGroup- Main toggle group containerToggleGroupItem- Individual toggle button
Usage
Create a single-select toggle group:
import static org.patternfly.component.SelectionMode.single;
import static org.patternfly.component.togglegroup.ToggleGroup.toggleGroup;
import static org.patternfly.component.togglegroup.ToggleGroupItem.toggleGroupItem;
ToggleGroup group = toggleGroup(single)
.addItem(toggleGroupItem("option-1", "Option 1"))
.addItem(toggleGroupItem("option-2", "Option 2"))
.addItem(toggleGroupItem("option-3", "Option 3"));
Create a multi-select toggle group with icons:
import static org.patternfly.component.SelectionMode.multi;
import static org.patternfly.component.togglegroup.ToggleGroup.toggleGroup;
import static org.patternfly.component.togglegroup.ToggleGroupItem.toggleGroupItem;
import static org.patternfly.icon.IconSets.fas.copy;
import static org.patternfly.icon.IconSets.fas.undo;
ToggleGroup iconGroup = toggleGroup(multi)
.addItem(toggleGroupItem("copy").iconAndText(copy(), "Copy"))
.addItem(toggleGroupItem("undo").iconAndText(undo(), "Undo"));
- See Also:
-
ClassesClassDescriptionA toggle group is a group of controls that can be used to quickly switch between actions or states.