GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing docs.nativebase.io — Radio | NativeBase | Universal Components for React and React Native

Radio | NativeBase | Universal Components for React and React Native

NativeBase
3.4.x
🎉 Prompt to React Native UI
→
Search
⌘
K
Hire us
NativeBase
Introduction
Getting Started
Installation
Setup NativeBase Provider
Migration
Upgrading to v3
Upgrading to 3.2.0 from 3.x
Upgrading to 3.4.0 from 3.3.x
Components Migration
ActionSheet
Badge
Button
Card
Checkbox
DatePicker
DeckSwiper
Drawer
FABs
FooterTab
Form
Header
Icon
Layout
Picker
Radio Button
Searchbar
Segment
Spinner
SwipeList
Tabs
Thumbnail
Toast
Typography
Resources
Contribution
Creating a Universal App with NativeBase and Solito
Core Concepts
Utility First
Utility Props Specificity
Design Tokens
Pseudo Props: Overview
Pseudo Props: Dos & Don'ts
Internal Pseudo Props
Responsive
Features
Utility Props
Color mode (Dark Mode)
NativeBase Factory
SafeAreaView Props
Strict Mode
Accessibility
Theme
Default Theme
Customizing Theme
Customizing Fonts
Customizing Components
Making components dark mode compatible
Breakpoints
Using Theme
TypeScript
Layout
AspectRatio
Box
Center
Container
Flex
HStack / Row
Stack
VStack / Column
ZStack
Forms
Button
Pressable
Checkbox
FormControl
IconButton
Input
Link
Radio
Select
Slider
Switch
TextArea
Data Display
Badge
Divider
Feedback
Alert
Progress
Skeleton
Spinner
Toast
Typography
Text
Heading
Overlay
AlertDialog
Menu
Modal
Popover
Tooltip
Disclosure
ActionSheet
Media and Icons
Avatar
Icon
Image
Transition
PresenceTransition
Slide
Stagger
Others
Fab
Hidden
ReactNative Components
ScrollView
View
KeyboardAvoidingView
StatusBar
FlatList
SectionList
Hooks
useDisclose
useBreakpointValue
useClipboard
useMediaQuery
useTheme
useToken
useColorMode
useColorModeValue
useContrastText
useAccessibleColors
Examples
Todo-List
Kitchen Sink
Recipes
Designs
AppBar
Card
Drawer Navigation
Tab View
Swipe List
Forms
Form with Validation
Login/Signup Forms
SearchBar
Layout
App Drawer
Footer
More
Changelog
Testing
FAQ's
More Props
If you are starting a new project, please try gluestack-ui for better performance and new design.
Radio
Radio limits the selection from a series of options to only one.
Show Code
Playground
const Example = () => {
const [value, setValue] = React.useState('one');
return <Radio.Group name="myRadioGroup" accessibilityLabel="favorite number" value={value} onChange={nextValue => {
setValue(nextValue);
}}>
<Radio shadow={2} value="one" my="2">
One
</Radio>
<Radio shadow={2} value="two" my="2">
Two
</Radio>
</Radio.Group>;
};
Examples
Controlled
Playground
const Example = () => {
const [value, setValue] = React.useState("one");
return <Radio.Group name="myRadioGroup" accessibilityLabel="favorite number" value={value} onChange={nextValue => {
setValue(nextValue);
}}>
<Radio value="one" my={1}>
One
</Radio>
<Radio value="two" my={1}>
Two
</Radio>
</Radio.Group>;
};
Uncontrolled
Playground
const Example = () => {
return <Radio.Group defaultValue="1" name="myRadioGroup" accessibilityLabel="Pick your favorite number">
<Radio value="1" my={1}>
First
</Radio>
<Radio value="2" my={1}>
Second
</Radio>
<Radio value="3" my={1}>
Third
</Radio>
</Radio.Group>;
};
Disabled
Playground
const Example = () => {
return <Radio.Group defaultValue="2" name="exampleGroup" accessibilityLabel="select prize">
<Radio value="1" my={1} isDisabled>
First
</Radio>
<Radio value="2" my={1}>
Second
</Radio>
<Radio value="3" my={1}>
Third
</Radio>
</Radio.Group>;
};
Invalid
Playground
const Example = () => {
return <Radio.Group name="exampleGroup" accessibilityLabel="select an option">
<Radio value="test" isInvalid>
Others
</Radio>
</Radio.Group>;
};
Size
Playground
const Example = () => {
return <Radio.Group name="exampleGroup" defaultValue="1" accessibilityLabel="pick a size">
<Stack direction={{
base: "column",
md: "row"
}} alignItems={{
base: "flex-start",
md: "center"
}} space={4} w="75%" maxW="300px">
<Radio value="1" colorScheme="red" size="sm" my={1}>
Small
</Radio>
<Radio value="2" colorScheme="green" size="md" my={1}>
Medium
</Radio>
<Radio value="3" colorScheme="yellow" size="lg" my={1}>
Large
</Radio>
</Stack>
</Radio.Group>;
};
Custom Color
Playground
const Example = () => {
return <Radio.Group defaultValue="1" name="exampleGroup" accessibilityLabel="favorite colorscheme">
<Radio colorScheme="emerald" value="1" my={1}>
emerald
</Radio>
<Radio colorScheme="secondary" value="2" my={1}>
secondary
</Radio>
<Radio colorScheme="warning" value="3" my={1}>
warning
</Radio>
</Radio.Group>;
};
Custom Icon
Playground
const Example = () => {
return <Radio.Group defaultValue="1" size="lg" name="exampleGroup" accessibilityLabel="pick a choice">
<Radio _text={{
mx: 2
}} colorScheme="green" value="1" icon={<Icon as={<MaterialCommunityIcons name="alien" />} />} my={1}>
Alien
</Radio>
<Radio _text={{
mx: 2
}} colorScheme="red" value="2" icon={<Icon as={<MaterialCommunityIcons name="fire" />} />} my={1}>
Fire
</Radio>
<Radio colorScheme="warning" _text={{
mx: 2
}} value="3" icon={<Icon as={<MaterialCommunityIcons name="exclamation" />} />} my={1}>
Warning
</Radio>
</Radio.Group>;
};
Form Controlled
Playground
const Example = () => {
const [groupValue, setGroupValue] = React.useState("1");
return <Container>
<FormControl isInvalid>
<FormControl.Label _text={{
fontSize: "lg",
bold: true
}}>
Select Prize
</FormControl.Label>
<Radio.Group name="exampleGroup" accessibilityLabel="select prize" defaultValue={groupValue} onChange={value => {
setGroupValue(value || "");
}}>
<Radio value="1" my="1">
First
</Radio>
<Radio value="2" my="1">
Second
</Radio>
<Radio value="3" my="1">
Third
</Radio>
</Radio.Group>
<FormControl.ErrorMessage leftIcon={<WarningOutlineIcon size="xs" />}>
You must select a Prize.
</FormControl.ErrorMessage>
</FormControl>
</Container>;
};
Basic (With Ref)
Playground
const Example = () => {
const myRef = React.useRef({});
return <Radio.Group name="exampleGroup" colorScheme="success" accessibilityLabel="pick an option" onChange={value => {
if (value === "2") {
if (Platform.OS !== "web") myRef.current.setNativeProps({
backgroundColor: "#00de0050"
});
} else {
if (Platform.OS !== "web") myRef.current.setNativeProps({
backgroundColor: "#fa000050"
});
}
}}>
<Radio colorScheme="success" value="1" my={1}>
Wrong
</Radio>
<Radio colorScheme="success" ref={myRef} value="2" my={1}>
Right
</Radio>
</Radio.Group>;
};
Props
Radio
Radio implements
FlexProps
,
ColorProps
,
LayoutProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
,
View
,
SafeAreaProps
,
PlatformProps
size
The size (width and height) of the radio.
Type: ThemeComponentSizeType<"Radio">
colorScheme
The color of the radio. This should be one of the color keys in the theme (e.g."green", "red").
Type: (ColorSchemeType & ResponsiveValue<"default">) & ColorSchemeType
Default: 'primary'
icon
If given, will use this icon instead of the default.
Type: Element
wrapperRef
Ref to be passed to Icon's wrapper Box
Type: any
isHovered
If true, the radio will be hovered
Type: boolean
isPressed
If true, the radio will be pressed
Type: boolean
isFocused
If true, the radio will be focused
Type: boolean
value
The value to be used in the radio input. This is the value that will be returned on form submission
Type: string
isDisabled
If true, the radio will be disabled
Type: boolean
isFocusVisible
If true, the radio focus ring will be visible
Type: boolean
isInvalid
If true, the radio is marked as invalid. Changes style of unchecked state.
Type: boolean
_stack
Props to be passed to the Stack used inside.
Type: Partial<IStackProps>
_disabled
Passed props wilICheckboxGroupProps will be applied on the disabled state.
Type: Omit<Partial<IRadioProps>, "_disabled">
_checked
Passed props will be applied on checked state.
Type: Omit<Partial<IRadioProps>, "_checked">
_focus
Passed props will be applied on focus state.
Type: Omit<Partial<IRadioProps>, "_focus">
_hover
Passed props will be applied on hover state.
Type: Omit<Partial<IRadioProps>, "_hover">
_invalid
Passed props will be applied on invalid state.
Type: Omit<Partial<IRadioProps>, "_invalid">
_pressed
Passed props will be applied on pressed state on native.
Type: Omit<Partial<IRadioProps>, "_pressed">
_icon
Icon related props can be passed in _icon.
Type: Partial<IIconProps>
_readOnly
Passed props will be applied on readonly state.
Type: Omit<Partial<IRadioProps>, "_readOnly">
_interactionBox
You can style interaction box around the checkbox using this.
Type: Omit<Partial<IRadioProps>, "_interactionBox">
Radio Group
RadioGroup implements
View
,
SafeAreaProps
,
PlatformProps
,
FlexProps
,
ColorProps
,
LayoutProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
value
The value of the radio group.
Type: string
name
The name of the input field in a radio (Useful for form submission).
Type: string
defaultValue
The initial value of the radio group.
Type: string
colorScheme
The color of the radios. This should be one of the color keys in the theme (e.g."green", "red").
Type: ColorSchemeType
Default: 'primary'
size
The size (width and height) of the radio.
Type: ResponsiveValue<number | "full" | "sm" | "6" | "2xs" | "2" | "8" | "xs" | "3" | "12" | "md" | "4" | "16" | "xl" | "5" | "24" | "32" | "7" | "0.5" | "2.5" | "lg" | "1" | "2xl" | "1.5" | "10" | "20" | "64" | ... 27 more ... | "5/6">
onChange
The callback fired when any children radio is checked or unchecked.
Type: IRadioGroupOnChangeHandler
_radio
Pass props will be passed to each radio.
Type: Partial<IRadioProps>
Accessibility
Uses React Native ARIA
@react-native-aria/radio
which follows the
Radio Group WAI-ARIA design pattern
.
Keyboard Interactions
Key
Description
Tab
Moves focus to either the checked radio item or the first radio item in the group.
Space
When focus is on an unchecked radio item, checks it.
ArrowDown
Moves focus to the next radio item in the group.
ArrowRight
Moves focus to the next radio item in the group.
ArrowUp
Moves focus to the previous radio item in the group.
ArrowLeft
Moves focus to the previous radio item in the group.
Styling
NativeBase ships with a default theme for each component. Check out the default theme of the radio
here
.
Info: We can easily extend the radio component theme using extendTheme function as described in the documentation
here
.
Previous
Link
Next
Select
Quick Nav
Examples
Controlled
Uncontrolled
Disabled
Invalid
Size
Custom Color
Custom Icon
Form Controlled
Basic (With Ref)
Props
Radio
Radio Group
Accessibility
Keyboard Interactions
Styling
MadeWithNativeBase
gluestack-ui
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.