File: selectbutton.md | Updated: 11/15/2025
Introducing PrimeReact v11 Alpha 🥁Learn More
SearchK
10.9.7
FEATURES
API
THEMING
PASS THROUGH
SelectButton is used to choose single or multiple items from a list using buttons.
Import#
import { SelectButton } from 'primereact/selectbutton';
Copy
Basic#
SelectButton is used as a controlled component with value and onChange properties along with an options collection. Label and value of an option are defined with the optionLabel and optionValue properties respectively. Default property name for the optionLabel is label and value for the optionValue. If optionValue is omitted and the object has no value property, the object itself becomes the value of an option. Note that, when options are simple primitive values such as a string array, no optionLabel and optionValue would be necessary.
Off
On
<SelectButton value={value} onChange={(e) => setValue(e.value)} options={options} />
Copy
Multiple#
SelectButton allows selecting only one item by default and enabling multiple allows choosing more. In multiple case, model property should be an array instead of a single value.
Option 1
Option 2
Option 3
<SelectButton value={value} onChange={(e) => setValue(e.value)} optionLabel="name" options={items} multiple />
Copy
Template#
Options support templating using the itemTemplate property that references a function to render the content. Notice the usage of optionLabel, although not rendered visually, it is still required to be used as the list key.
<SelectButton value={value} onChange={(e) => setValue(e.value)} itemTemplate={justifyTemplate} optionLabel="value" options={justifyOptions} />
Copy
Invalid#
Invalid state is displayed using the invalid prop to indicate a failed validation. You can use this style when integrating with form validation libraries.
Off
On
<SelectButton invalid value={value} onChange={(e) => setValue(e.value)} options={options} />
Copy
Disabled#
When disabled is present, the element cannot be edited and focused entirely. Certain options can also be disabled using the optionDisabled property.
Off
On
Option 1
Option 2
<SelectButton disabled options={options1} />
<SelectButton value={value} onChange={(e) => setValue(e.value)} options={options2} optionLabel="name" optionDisabled="constant" />
Copy
Accessibility#
The container element that wraps the buttons has a group role whereas each button element uses button role and aria-pressed is updated depending on selection state. Value to describe an option is automatically set using the aria-label property that refers to the label of an option so it is still suggested to define a label even the option display consists of presentational content like icons only.
| Key | Function | | --- | --- | | tab | Moves focus to the buttons. | | space | Toggles the checked state of a button. |
Import
Basic
Multiple
Template
Invalid
Disabled
Accessibility
PrimeReact 10.9.7 by PrimeTek