BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/nativeui/radio-group

Radio Group

nativeui/radio-group
FreeComponent

A radio group component for React Native applications.

Live preview

live · rendered by the registry
Rendered by nativeui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://nativeui.ribbi.ch/r/radio-group.json

Source

registry/radio-group/radio-group.tsxnativeui.ribbi.ch/r/radio-group.json
1import * as React from "react"
2import { View, Text, Pressable } from "react-native"
3import { cn } from "@/lib/utils"
4
5interface RadioGroupRootProps extends React.ComponentPropsWithoutRef<typeof View> {
6 value?: string
7 defaultValue?: string
8 onValueChange?: (value: string) => void
9 disabled?: boolean
10}
11
12interface RadioGroupItemProps extends Omit<React.ComponentPropsWithoutRef<typeof Pressable>, 'children'> {
13 value: string
14 disabled?: boolean
15 id?: string
16}
17
18interface RadioGroupLabelProps extends React.ComponentPropsWithoutRef<typeof Text> {
19 disabled?: boolean
20 htmlFor?: string
21}
22
23const RadioGroupContext = React.createContext<{
24 value?: string
25 onValueChange?: (value: string) => void
26 disabled?: boolean
27}>({})
28
29function RadioGroup({
30 value,
31 defaultValue,
32 onValueChange,
33 disabled = false,
34 className,
35 children,
36 ...props
37}: RadioGroupRootProps) {
38 const [innerValue, setInnerValue] = React.useState<string | undefined>(value ?? defaultValue)
39 const currentValue = value !== undefined ? value : innerValue
40
41 const handleValueChange = React.useCallback((newValue: string) => {
42 if (disabled) return
43
44 if (value === undefined) {
45 setInnerValue(newValue)
46 }
47
48 onValueChange?.(newValue)
49 }, [value, onValueChange, disabled])
50
51 return (
52 <RadioGroupContext.Provider
53 value={{ value: currentValue, onValueChange: handleValueChange, disabled }}
54 >
55 <View
56 className={cn("space-y-4", className)}
57 accessibilityRole="radiogroup"
58 {...props}
59 >
60 {children}
61 </View>
62 </RadioGroupContext.Provider>
63 )
64}
65
66const RadioGroupItem = React.forwardRef<
67 React.ElementRef<typeof Pressable>,
68 RadioGroupItemProps
69>(({ className, value, disabled, id, ...props }, ref) => {
70 const { value: groupValue, onValueChange, disabled: groupDisabled } = React.useContext(RadioGroupContext)
71 const isDisabled = disabled || groupDisabled
72 const isChecked = value === groupValue
73
74 const handlePress = () => {
75 if (!isDisabled) {
76 onValueChange?.(value)
77 }
78 }
79
80 return (
81 <Pressable
82 ref={ref}
83 accessibilityRole="radio"
84 accessibilityState={{ checked: isChecked, disabled: isDisabled }}
85 onPress={handlePress}
86 disabled={isDisabled}
87 className={cn(
88 "h-6 w-6 rounded-full border-2 justify-center items-center",
89 isChecked
90 ? "border-primary bg-primary/10"
91 : "border-border bg-transparent",
92 isDisabled && "opacity-50",
93// … truncated

What it pulls in

npm packages

  • react-native

Files it writes

  • registry/radio-group/radio-group.tsx

Facts

Registry
nativeui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

Docs on nativeui nativeui.ribbi.ch nativeui-org/ui on GitHub Raw registry item This item as JSON

More from nativeui

All 29 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionnativeuiComponentsFree2 deps
AlertalertnativeuiComponentsFree2 deps
Alert Dialogalert-dialognativeuiComponentsFree1 dep
AvataravatarnativeuiComponentsFree1 dep
BadgebadgenativeuiComponentsFree2 deps
BreadcrumbbreadcrumbnativeuiComponentsFree2 deps
ButtonbuttonnativeuiComponentsFree2 deps
CalendarcalendarnativeuiComponentsFree4 deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex