No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

The component failed to render properly, likely due to a configuration issue in Storybook. Here are some common causes and how you can address them:

  1. Missing Context/Providers: You can use decorators to supply specific contexts or providers, which are sometimes necessary for components to render correctly. For detailed instructions on using decorators, please visit the Decorators documentation.
  2. Misconfigured Webpack or Vite: Verify that Storybook picks up all necessary settings for loaders, plugins, and other relevant parameters. You can find step-by-step guides for configuring Webpack or Vite with Storybook.
  3. Missing Environment Variables: Your Storybook may require specific environment variables to function as intended. You can set up custom environment variables as outlined in the Environment Variables documentation.

RadioButtonGroup

RadioButtonGroup is used to select a single value from multiple mutually exclusive options.

When to use

Use RadioButtonGroup for mutually exclusive selections if there are up to four options available. This is because the RadioButtonGroup cannot have more than one row and should still accommodate small resolutions. For a mutually exclusive selection of more than four options, use Select component.

Radio buttons can only exist in this type of group. If you want one single option, it's better to use Switch instead. To offer multiple choices within the same group or context which are not mutually exclusive, use Checkbox instead.

Usage

import { RadioButtonGroup } from '@grafana/ui'; <RadioButtonGroup options={...} value={...} onChange={...} />

Disabling options

To disable some options pass those options to the RadioButtonGroup via disabledOptions property:

const options = [ { label: 'Prometheus', value: 'prometheus' }, { label: 'Graphite', value: 'graphite' }, { label: 'Elastic', value: 'elastic' }, { label: 'InfluxDB', value: 'influx' }, ]; const disabledOptions = ['prometheus', 'elastic']; <RadioButtonGroup options={options} disabledOptions={disabledOptions} value={...} onChange={...} />
NameDescriptionDefault
value
T
-
id
string
-
disabled
boolean
-
disabledOptions
T[]
-
options*
SelectableValue<T>[]
-
onChange
((value: T) => void)
-
onClick
((value: T) => void)
-
size
"sm""md"
"md"
fullWidth
boolean
false
className
string
-
autoFocus
boolean
false
aria-label
string
-
invalid
boolean
false