v2.1.4

Radio

Installation

Install yarn add @spark-web/radio
Source GitHub.com
Bundle unpkg.com

Radios are used select a single value from several options — ususally in a form. If multiple choices are valid, consider using a Checkbox instead.

Examples

In order to toggle between options, all Radio components should have a matching name prop (unless you are using them inside of a RadioGroup).

Shrek Characters

Size

Radio buttons are available in two sizes: small and medium.

Radio variations (small)
Radio variations (small)

RadioGroup

The RadioGroup can be used to control a group of Radio components. The RadioGroup handles the value, tone, message, and disabled state of it's children.

Controlled

To control a group of Radio components, wrap them with a RadioGroup and provide it with a value and onChange function.

All Radio children must be provided with a value.

Shrek Characters
The selected character is Shrek

Message and tone

The message is used to communicate the status of a field, such as an error message. This will be announced on focus and can be combined with a tone to illustrate intent. The supported tones are: critical, positive and neutral.

Message and Tone
Critical message

RadioCard

A RadioCard is an alternative to Radio. Use RadioCard where a user needs to make one selection out of several choices, and where each option requires some detailed information.

Controlled

Select a repayment term
You have selected 6 months

Uncontrolled

Select a repayment term

Without description

RadioCards without a description have a lower prominence label.

Shrek Characters
The selected character is Shrek

Props

Radio

PropTypeDescription

checked?

boolean

When true, the radio will be checked.

children?

ReactNode: string | number | false | true | {} | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

The radio label content.

data?

DataAttributeMap

Sets data attributes for the element.

disabled?

boolean

When true, the radio will be disabled.

size?

RadioSize: "small" | "medium"

The size of the radio.

value?

string

The value of the radio.

The Radio component also extends InputHTMLAttributes props and are not listed here.

RadioPrimitive

PropTypeDescription

checked?

boolean

When true, the radio will be checked.

data?

DataAttributeMap

Sets data attributes for the element.

disabled?

boolean

When true, the radio will be disabled.

size?

RadioSize: "small" | "medium"

The size of the radio.

Default: "small"

value?

string

The value of the radio.

The CheckboxPrimitive component also extends InputHTMLAttributes props and are not listed here.

RadioGroup

PropTypeDescription

children

ReactNode: string | number | false | true | {} | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

`Radio` components.

onChange

(selectedValue: Value) => void

Function that is fired whenever a change event is triggered on a `Radio`.

value

string

The value of the nested radios.

aria-describedby?

string

id(s) of the element(s) that describe the `Radio`.

disabled?

boolean

When true, disables the group of nested radios.

id?

string

An identifier which must be unique in the whole document.

message?

string

Provide a message, informing the user about changes in state.

name?

string

Name for the group of `Radio` components.

size?

RadioSize: "small" | "medium"

The size of the nested radios.

tone?

"critical" | "positive" | "neutral"

Provide a tone to influence elements of the field, and its input.

Default: "neutral"

RadioCard

PropTypeDescription

checked?

boolean

When true, the radio will be checked.

children?

ReactNode: string | number | false | true | {} | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

The radio label content.

data?

DataAttributeMap

Sets data attributes for the element.

description?

string

The radio description.

disabled?

boolean

When true, the radio will be disabled.

value?

string

The value of the radio.

The RadioCard component also extends InputHTMLAttributes props and are not listed here.

© 2023 Brighte Capital Pty Ltd