🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

react-native-radio-btn

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-radio-btn

Custom Radio button component for React Native

0.1.2
latest
Source
npm
Version published
Weekly downloads
8
100%
Maintainers
1
Weekly downloads
 
Created
Source

React Native Radio Button

Fork of: react-native-flexi-radio-button

Example Expo Snack

Installation

npm i react-native-radio-btn

or

yarn add react-native-radio-btn

Usage

import {RadioGroup, RadioButton} from 'react-native-radio-btn'

state = {
   radioItems: [
     {
       id: 1,
       label: 'Item 1',
       selected: false,
     },
     {
       id: 2,
       label: 'Item 2',
       selected: false,
     },
     {
       id: 3,
       label: 'Item 3',
       selected: false,
     },
   ],
 };

 onSelect(index, value) {
   console.log(`Selected index: ${index} , value: ${value}`);
 }

render(){
  return(
    <View style={styles.container}>

    <RadioGroup onSelect={(index, value) => this.onSelect(index, value)}>
        {this.state.radioItems.map((item, index) => {
          return (
            <RadioButton
              key={index}
              value={item.label}
              displayText={item.label}
              displayTextColor="#000"
              displayTextActiveColor="#fff"
              prefixColor="rgba(0, 0, 0, 0.4)"
              prefixActiveColor="rgba(0, 0, 0, 0.4)"
              prefixWithNumbers
            />
          );
        })}
      </RadioGroup>

    </View>
  )
}

Configuration

Radio Group:
PropertyTypeDefaultDescription
sizenumber20Size of the radio button
thicknessnumber1width of radio button border
colorstring'#007AFF'color of radio button
activeColorstringnullcolor of radio button when selected
highlightColorstringnullbackground of radio button after selected
selectedIndexnumbernulldefault selected index of radio group, can be changed to new value or to null for clear selection
styleobjectnullCustom styles to be applied if supplied
onSelectfunction(index, value)nullfunction to be invoked when radio button is selected
Radio Button:
PropertyTypeDefaultDescription
valueanynullvalue will be passed on callback onSelect as second argument
styleobjectnullStyles to be applied on 'RadioButton' component
colorstringsame as 'RadioGroup' componentcolor of radio dot
disabledboolfalseIf true, disable all interactions for this component.
displayTextColorstring'#000'color of label text
displayTextActiveColorstring'#fff'color of label text when selected
prefixColorstring'#000'color of prefixes
prefixActiveColorstring'#fff'color of prefixes when selected
prefixWithAlphabetbooleanfalseprefixes label with alphabets (a,b,...z)
prefixWithNumbersbooleanfalseprefixes label with numbers (1,2...n)

Keywords

react-native

FAQs

Package last updated on 01 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts