Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 05 Choices

Radio group

One choice from a short list, with every option in view. Native radios: Tab reaches the group, arrow keys move the choice. For more than five or six options, use a select.

Use it in Angular
import { RadioGroupComponent } from '@okaapi-ui/angular';
// Options are { value, label, disabled? }, as for ui-select.
Works with

One per line

Delivery

Same day is not available for this address.

Angular
<ui-radio-group
  label="Delivery"
  hint="Same day is not available for this address."
  [options]="speeds"
  formControlName="speed"
/>

Side by side, with an error

Short answers can sit on one line. An error adds a red edge and the message, which is announced.

Do you have a parking space?
Angular
<ui-radio-group
  label="Do you have a parking space?"
  orientation="horizontal"
  [options]="yesNo"
  formControlName="parking"
  [error]="form.controls.parking.invalid ? 'Choose yes or no' : undefined"
/>

In Arabic

التوصيل
Angular
<ui-radio-group label="التوصيل" [options]="speeds" formControlName="speed" />

When to use something else

If you needUse
Several choices at onceCheckbox
More than about 7 optionsSelect
Switch the view of the pageSegmented control

Inputs

NameTypeDefaultWhat it does
labelstring — Required. Names the group.
optionsRadioOption<T>[] — Required. { value, label, disabled? } for each radio.
orientation'vertical' | 'horizontal''vertical'Side by side for two or three short answers.
hintstring — Help text under the label, read with the group.
errorstring — The translated error. Marks the group invalid and announces the message.
compareWith(a: T, b: T) => boolean===How to match the form value to an option, for object values.
testIdstring — data-testid prefix; each radio gets -<index>.

Keyboard and screen readers

KeysWhat they do
Tab Reach the group, on the chosen option.
Arrow keys Move the choice to the next or previous option.
  • Native radios in a named group, so the group name is read first.