NativeUI Primitives

Radio

Create accessible radio buttons with custom styling and full keyboard support across all platforms.


Preview

Interactive Demo

Installation

npm install @native-ui-org/primitives
pnpm add @native-ui-org/primitives
yarn add @native-ui-org/primitives
bun add @native-ui-org/primitives

Overview

Radio is a compound component for building radio buttons with labels and custom indicators. Unlike checkboxes, only one radio in a group can be selected at a time.

FeatureDescriptionPlatforms
RadioRoot container managing stateiOS, Android, Web
RadioIndicatorVisual radio state indicatoriOS, Android, Web
RadioLabelClickable label textiOS, Android, Web

Setup & Usage Guide

Radio provides the structure for accessible radio inputs with full control over styling.

1. Install and Import

Install from npm:

npm install @native-ui-org/primitives

Then import from the package:

import { 
  Radio, 
  RadioIndicator,
  RadioLabel 
} from "@native-ui-org/primitives";

2. Basic Usage

Simple radio with label:

<Radio defaultChecked={false}>
  <RadioIndicator>
    {({ checked }) => (
      <View style={checked ? styles.checked : styles.unchecked}>
        {checked && <View style={styles.dot} />}
      </View>
    )}
  </RadioIndicator>
  <RadioLabel htmlFor="option1">
    <Text>Option 1</Text>
  </RadioLabel>
</Radio>

3. Controlled State

Manage radio state externally:

const [checked, setChecked] = useState(false);

<Radio checked={checked} onCheckedChange={setChecked}>
  <RadioIndicator>
    {({ checked }) => (
      <View style={styles.indicator}>
        {checked && <Text>●</Text>}
      </View>
    )}
  </RadioIndicator>
  <RadioLabel htmlFor="option1">
    <Text>Select option</Text>
  </RadioLabel>
</Radio>

4. Disabled State

<Radio disabled checked={true}>
  <RadioIndicator>
    {({ checked }) => (
      <View style={styles.indicatorDisabled}>
        {checked && <View style={styles.dotDisabled} />}
      </View>
    )}
  </RadioIndicator>
  <RadioLabel htmlFor="disabled">
    <Text style={styles.labelDisabled}>Disabled option</Text>
  </RadioLabel>
</Radio>

API Reference

Radio

Root container managing radio state.

PropTypeDefaultDescription
checkedbooleanControlled checked state
defaultCheckedbooleanfalseInitial state (uncontrolled)
onCheckedChange(checked: boolean) => voidCallback when state changes
disabledbooleanfalseDisable interactions
requiredbooleanfalseMark as required (forms)
namestringForm field name
valuestringRadio value (used in RadioGroup)
asChildbooleanfalseUse Slot pattern

RadioIndicator

Visual indicator for radio state.

PropTypeDefaultDescription
childrenfunction | React.ReactNodeRender function or content
forceMountbooleanfalseKeep mounted when unchecked
asChildbooleanfalseUse Slot pattern

RadioLabel

Clickable label text.

PropTypeDefaultDescription
htmlForstringID of radio
asChildbooleanfalseUse Slot pattern
...propsanyStandard Text props

Platform Behavior

PlatformImplementationCharacteristics
iOS / AndroidPressable with stateNative touch feedback
WebInput radio (hidden) + visualKeyboard accessible, form compatible
All PlatformsConsistent APISame props, same behavior

Accessibility

Web:

  • Hidden <input type="radio"> for form compatibility
  • Proper label association
  • Keyboard support (Space/Enter to toggle)
  • Focus management
  • Radio group semantics

Mobile:

  • Accessibility role "radio"
  • State announced to screen readers
  • Works with VoiceOver and TalkBack

Version History

VersionNotes
0.1.0Initial release — radio with label and indicator, controlled/uncontrolled states.

Summary: Radio provides accessible radio button inputs with full styling control. Use it for single-select forms, option groups, or any exclusive choice input. Supports both controlled and uncontrolled modes with proper accessibility.