Radio Button
Overview
Use the radio button component to prompt the user to select exactly one item from a small list of options.
All options are visible at the same time and display in a vertical stack.
![Three radio buttons with one item selected](./RadioButtons.png?v=2)
An interesting bit of trivia… old timers may remember that car radios used to have physical buttons for changing the radio station. When you pushed in one button, it tuned to a specific station and pushed out all the other buttons. This mutual exclusion behavior was needed in modern UI too, so the industry settled on the term “radio buttons” for this component as a nod to these physical-world analogs from the past.
![Old car radio buttons](./CarRadioButtons.jpg)
Development
Web component development
Component reference
p-radioButton
Allows the user to select one item from a short list, with all items visible in a vertical list
View the p-radioButton reference doc
If you're adding PrimeNG to your solution for the first time, reference their setup documentation. It's important to note that the inclusion of the nova-light theme css is not necessary to work with Responsive UI. Styling for the PrimeNG components is provided by Responsive UI's theming.
Implementation
Start by importing the RadioButtonModule module into your application.
Display one p-radioButton
instance for each list item.
In the TypeScript, create an array with the radio button options.
Due to a bug with the PrimeNG p-radioButton
when used in a reactive form, you’ll need to subscribe to valueChanges
so the user interface will correctly display the selected item. This is a known issue with PrimeNG and will be fixed in a future release.
p-radioButton
does not currently support selected or disabled states. All disabled radio buttons display as unselected.Angular component development
Component reference
p-radioButton
Allows the user to select one item from a short list, with all items visible in a vertical list
View the p-radioButton reference doc
If you're adding PrimeNG to your solution for the first time, reference their setup documentation. It's important to note that the inclusion of the nova-light theme css is not necessary to work with Responsive UI. Styling for the PrimeNG components is provided by Responsive UI's theming.
Implementation
Start by importing the RadioButtonModule module into your application.
Display one p-radioButton
instance for each list item.
In the TypeScript, create an array with the radio button options.
Due to a bug with the PrimeNG p-radioButton
when used in a reactive form, you’ll need to subscribe to valueChanges
so the user interface will correctly display the selected item. This is a known issue with PrimeNG and will be fixed in a future release.
p-radioButton
does not currently support selected or disabled states. All disabled radio buttons display as unselected.Design
Figma design
Dev Component | Design Component Name |
---|---|
Radio button | RUI / Forms / Radio Button |
Adobe XD design
- Sample App - Editing Form Data
Dev Component | Design Component Name |
---|---|
Radio button - checked | JHA / Forms / Radio Button / Checked |
Radio button - unchecked | JHA / Forms / Radio Button / Unchecked |