Thanks to visit codestin.com
Credit goes to primeng.org

RadioButton

RadioButton is an extension to standard radio button element with theming.

import { RadioButtonModule } from 'primeng/radiobutton';

RadioButton is used as a controlled input with value and ngModel properties.

RadioButtons can be generated using a list of values.

Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.

RadioButton provides small and large sizes as alternatives to the base.

When disabled is present, the element cannot be edited and focused.

The invalid state is applied using the ⁠invalid property to indicate failed validation, which can be integrated with Angular Forms.

RadioButton can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.

Screen Reader

RadioButton component uses a hidden native radio button element internally that is only visible to screen readers. Value to describe the component can either be provided via label tag combined with inputId prop or using ariaLabelledBy, ariaLabel props.

<label for="rb1">One</label>
<p-radiobutton inputId="rb1" />

<span id="rb2">Two</span>
<p-radiobutton ariaLabelledBy="rb2" />

<p-radiobutton ariaLabel="Three" />

Keyboard Support

KeyFunction
tabMoves focus to the checked radio button, if there is none within the group then first radio button receives the focus.
left arrowup arrowMoves focus to the previous radio button, if there is none then last radio button receives the focus.
right arrowdown arrowMoves focus to the next radio button, if there is none then first radio button receives the focus.
spaceIf the focused radio button is unchecked, changes the state to checked.
PrimeBlocks
490+ ready to use UI blocks crafted with PrimeNG and Tailwind CSS.