Skip to main content
Brand and assets
Build
Monitor and contribute
/
Component library
  • All components
  • Buttons & actions
  • Forms & inputs
    • Checkbox
    • ChoiceGroup
    • CurrencyInput
    • DateInput
    • FileInputZone
    • Filters
    • Form
    • MaskedTextInput
    • PasswordInput
    • Pill
    • Pill
    • Radio
    • SearchInput
    • SegmentedSlider
    • Select
    • Switch
    • TextArea
    • TextInput
  • Layout & containers
  • Overlays
  • Feedback & status
  • Data display
  • Typography
  • Accessibility
  • Contrib
  • Deprecated
  • Forms & inputs
  • Radio

Radio

Picks exactly one option from a group. Use when the member must see all the options at once.

Health
Component health
Source
View on Github
Design
View Figma
Storybook
View in Storybook
Playground
No Example
Accessibility

compliant

Platform
Universal
  • Overview
  • Props
  • Figma

Usage​

Controlled​

import { useState } from "react";
import { Radio } from "murray";

function Demo() {
const [value, setValue] = useState("react");
return (
<Radio.Group
name="favoriteFramework"
label="Select your favorite framework/library"
helpText="This is anonymous"
value={value}
onChange={setValue}
>
<Radio value="react" label="React" />
<Radio value="svelte" label="Svelte" />
<Radio value="ng" label="Angular" />
<Radio value="vue" label="Vue" />
</Radio.Group>
);
}

Condensed theme​

For applications with condensed theme density, this component renders in a condensed style:

Result count​

Use count to show how many results an option matches, e.g. in a filter. It renders in parentheses after the label, in a muted style, and is excluded from the accessible label. 0 is displayed as (0): an option matching nothing keeps its count instead of silently losing it.

Usage in <Form>​

On web, Checkbox and CheckboxGroupNext can be used in <Form> component and be controleld by Formik:

Playground​

Loading...
tip
This component is universal, its usage is the same in murray and murray/mobile.

Radio props

NameTypeDefault ValueDescriptionUsage count
aria-labelstringundefinedAccessible label for the radio, used when no visible label is provided
aria-labelledbystringundefinedID of the element that labels this radio
countnumberundefinedResult count displayed in parentheses after the label, e.g. `Exempted (12)`. `0` is displayed too. Requires `label`, and is not part of the accessible label.
disabledbooleanundefinedDisable radio
helpTextReactNodeContents of `InputHelpTextNext` component, if not set, description is not rendered.
labelReactNodeContents of `InputLabelNext` component, if not set, label is not rendered.
testIDstringundefinedMobile e2e handle: the label is not pressable on native, so a flow has to tap the radio itself.
value*stringRadio value

RadioGroup props

NameTypeDefault ValueDescriptionUsage count
aria-labelstringundefined
children*ReactNodeArray of `Checkbox` eleements
defaultValuestringundefinedRadio checked value (when uncontrolled)
errorReactNodeContents of `InputError` component, if not set, error is not rendered.
helpTextReactNodeContents of `InputHelpTextNext` component, if not set, description is not rendered.
labelReactNode
namestringundefinedName of the current radio
onBlurundefinedFocusEventHandler<HTMLDivElement>Callback that is called when a child radio is blurred
onChange((value: string) => void)undefinedCallback that is called when a child radio state is changing
orientation"vertical""horizontal"undefinedOrientation for the layout (vertical by default). Horizontal groups wrap onto extra lines when the items don't fit the available width.
requiredbooleanundefinedAdds required attribute to the input and a red asterisk on the right side of label, `false` by default
valuestringundefinedRadio checked value (when controlled)
Edit this page
Previous
Pill
Next
SearchInput
  • Usage
  • Controlled
  • Condensed theme
  • Result count
  • Usage in <Form>
  • Playground