Radio Group
Choose one value from a short list.
Examples
Choose one value from a short list
React code
import { RadioGroup, Label } from "@accelerate/react/components";
export function Example() {
return (
<>
<RadioGroup>
<legend>Review frequency</legend>
<Label><input type="radio" name="frequency" value="weekly" defaultChecked /> Weekly</Label>
<Label><input type="radio" name="frequency" value="monthly" /> Monthly</Label>
</RadioGroup>
</>
);
}Angular code
import { Component } from "@angular/core";
import { AccRadioGroup, AccLabel } from "@accelerate/angular/components";
@Component({
selector: "app-example",
imports: [
AccRadioGroup,
AccLabel,
],
template: `
<fieldset accRadioGroup>
<legend>Review frequency</legend>
<label accLabel><input type="radio" name="frequency" value="weekly" checked> Weekly</label>
<label accLabel><input type="radio" name="frequency" value="monthly"> Monthly</label>
</fieldset>
`,
})
export class Example {}Installation
Source preview. The expanded component catalog is ahead of the public npm releases. To run these examples in your own application, use packages built from the SDK source used for the previews or a release that includes the APIs below.
- React
@accelerate/ui@0.4.0and@accelerate/react@0.4.0- Angular
@accelerate/ui@0.4.0and@accelerate/angular@0.2.0
Load @accelerate/ui/theme.css and put acc-theme on the app or the region using Accelerator components. See the framework setup guide for the theme and adapter conventions.
Usage
Use a legend plus same-name native radio buttons.
Import the React component RadioGroup from @accelerate/react/components. For Angular, add AccRadioGroup to the standalone component’s imports and use <fieldset accRadioGroup>.
Examples use these React parts: RadioGroup, Label. The Angular examples show the corresponding directives and template hosts.
API reference
- legend
- Names the option set.
- name
- Give all radio inputs the same name for exclusive selection.