Skip to content
React NativeBeta

RadioGroup

Single choice from a list, as rows or as cards.

Beta. React Native support is in beta. APIs may change or break between prereleases (npm tag native).

On this page
Web preview — real device may differ
tsx
import { useState } from "react";
import { Radio, RadioGroup } from "@/component-lib/radio-group";
import { Section } from "./layout"; // Section and Row: page layout for the demo
 
export function RadioGroupDemo() {
  const [plan, setPlan] = useState<string | null>("pro");
  return (
    <>
      <Section title="RadioGroup · options">
        <RadioGroup
          label="Billing cycle"
          description="You can change this later."
          defaultValue="monthly"
          clearable
          options={["Monthly", "Quarterly", "Yearly"].map((label) => ({ value: label.toLowerCase(), label }))}
        />
      </Section>
 
      <Section title="RadioGroup · cards">
        <RadioGroup
          label="Plan"
          variant="card"
          value={plan}
          onValueChange={setPlan}
          options={[
            { value: "free", label: "Free", description: "Up to 3 projects" },
            { value: "pro", label: "Pro", description: "₹499 / month, unlimited projects" },
            { value: "team", label: "Team", description: "Contact sales", disabled: true },
          ]}
        />
      </Section>
 
      <Section title="RadioGroup · horizontal, error, children">
        <RadioGroup label="Delivery" orientation="horizontal" required error="Choose a delivery option.">
          <Radio value="pickup" label="Pickup" />
          <Radio value="courier" label="Courier" />
          <Radio value="post" label="Post" disabled />
        </RadioGroup>
        <RadioGroup label="Sizes" orientation="horizontal" defaultValue="md">
          <Radio value="sm" size="sm" label="Small" />
          <Radio value="md" label="Medium" />
          <Radio value="lg" size="lg" label="Large" />
        </RadioGroup>
      </Section>
    </>
  );
}

Install

npx @grampro/kit@native add RadioGroup

Usage

tsx
import { RadioGroup, Radio } from "@/component-lib/radio-group";
 
<RadioGroup label="Billing cycle" defaultValue="monthly">
  <Radio value="monthly" label="Monthly" />
  <Radio value="yearly" label="Yearly" />
</RadioGroup>

Props

RadioGroupProps

PropTypeDescription
valuestring | nullThe chosen value (controlled). null for nothing chosen.
defaultValuestring | nullThe choice selected to begin with, when you are not controlling value.
onValueChange(value: string | null) => voidThe chosen value, or null when the group was emptied with clearable.
optionsreadonly (string | RadioOption)[]Render these choices, or pass <Radio value="…"> children. Plain strings work too.
childrenReactNode
labelReactNodeThe question the choices answer, shown as the group's legend.
descriptionReactNode
errorReactNodeThe validation message for the question. Marks every radio invalid.
requiredboolean
disabledboolean
sizeRadioSizeDefault md.
orientationRadioOrientationDefault vertical.
variantRadioVariantDefault default. card draws each choice as a tile.
clearablebooleanOffer a button that empties the group.
styleStyleProp<ViewStyle>
stylesPartial<{ root: StyleProp<ViewStyle>; legend: StyleProp<TextStyle>; description: StyleP…
localeTextPartial<RadioGroupLocaleText>

RadioProps

PropTypeDescription
value (required)stringThe value this choice contributes to its group.
checkedbooleanSelected (controlled). Inside a RadioGroup the group decides instead.
defaultCheckedbooleanSelected to begin with, for a standalone radio you are not controlling.
onCheckedChange(checked: boolean) => voidThis radio was chosen. Only ever fires with true.
labelReactNodeThe text beside the radio. Pressing it selects this choice.
descriptionReactNodeA hint under the label.
errorReactNodeThe validation message for this one choice.
sizeRadioSizeDefault md, or the size of the RadioGroup it sits in.
disabledboolean
styleStyleable<ViewStyle>
stylesPartial<{ root: Styleable<ViewStyle>; control: Styleable<ViewStyle>; label: Styleable<T…

Also accepts the props of Omit<PressableProps, "children" | "style" | "onPress" | "disabled">.

Native and web