React ToggleButton is used to select a boolean value using a button.
Setup
Refer to PrimeReact setup documentation for download and installation steps for your environment.
Import
import { ToggleButton } from 'primereact/togglebutton';
Getting Started
ToggleButton is used as a controlled input with checked and onChange properties.
<ToggleButton checked={checked1} onChange={(e) => setChecked1(e.value)} />
Labels and Icons
Icons and Labels can be customized using onLabel, offLabel, onIcon and offIcon properties.
<ToggleButton onLabel="I confirm" offLabel="I reject" onIcon="pi pi-check" offIcon="pi pi-times" checked={checked2} onChange={(e) => setChecked2(e.value)} />
Theming
ToggleButton supports various themes featuring Material, Bootstrap, Fluent as well as your own custom themes via the Designer tool.
Resources
Visit the PrimeReact ToggleButton showcase for demos and documentation.