This documentation is under construction. Pages can be missing or change at any time. Follow it on GitHub.

Skip to content

Toggle

A two-state button that can be on or off.

API reference#

Import the components of the family:

use Phem\Ui\ToggleGroup;
use function Phem\Ui\Toggle;

Toggle#

A button that the user presses and releases: Base UI Toggle, on the phem-toggle controller.

In a ToggleGroup, the group owns the state: give the toggle a value. In a Toolbar, the toggle is an item of the toolbar. In a Tooltip, it is a trigger of the tooltip. Show the state with the data-pressed variant, for example group-data-pressed:block on an icon in it.

PropTypeDefault
defaultPressedboolfalse
disabledboolfalse
value?stringnull
children?Htmlnull
...restmixed—

ToggleGroup#

A group of toggle buttons with one state: Base UI ToggleGroup, on the phem-toggle-group controller. defaultValue lists the values of the pressed toggles. Give it an aria-label.

PropTypeDefault
defaultValuearray[]
multipleboolfalse
orientation'horizontal' | 'vertical'Orientation::Horizontal
loopFocusbooltrue
disabledboolfalse
children?Htmlnull
...attrsarray[]

The source of the examples: examples/ui/Toggle.phem.

Phem
Esc
↑↓ to navigate↵ to openEsc to close