DitherCharts

Radio group

Updated

RadioGroup is a set of native radios in a fieldset, drawn as stepped pixel rings. The arrow keys move the choice, and the checked ring gets a pixel dot. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

Range
import "@/components/dithercharts/controls.css"
import { RadioGroup } from "@/components/dithercharts/radio-group"

<RadioGroup
  legend="Range"
  defaultValue="30d"
  options={[
    { value: "7d", label: "7 days" },
    { value: "30d", label: "30 days" },
    { value: "90d", label: "90 days" },
    { value: "1y", label: "1 year", disabled: true },
  ]}
/>

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add radio-group

Props

It renders a native element, so every other attribute that element takes passes through.

RadioGroup props
PropTypeDefaultDescription
legendrequiredType ReactNodeDefault –The group's caption, read before its options.
optionsrequiredType readonly RadioOption[]Default –
valueType stringDefault –The checked option's value, for a controlled group; pair it with onValueChange.
defaultValueType stringDefault –The option checked at first, for an uncontrolled group.
onValueChangeType (value: string) => voidDefault –
nameType stringDefault a generated idThe radios' form field name.
orientationType "vertical" | "horizontal"Default "vertical"Stack the options, or lay them out in a wrapping row.
disabledType booleanDefault falseDisables every option.
classNameType stringDefault –