Socket
Socket
Sign inDemoInstall

react-native-radio-buttons-group

Package Overview
Dependencies
0
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-radio-buttons-group

Simple and Best. An easy to use radio buttons for react native apps.


Version published
Maintainers
1
Install size
108 kB
Created

Readme

Source

React Native Radio Buttons Group

Simple, best and easy to use radio buttons for react native apps.

npm LICENSE MIT

NPM

Getting Started

Just a sneak peek (lots more can be done)

DEMO

Installation

npm i react-native-radio-buttons-group --save

or

yarn add react-native-radio-buttons-group

Usage

Javascript Example
App.js
import React, { useMemo, useState } from 'react';
import RadioGroup from 'react-native-radio-buttons-group';

export default function App() {

    const radioButtons = useMemo(() => ([
        {
            id: '1', // acts as primary key, should be unique and non-empty string
            label: 'Option 1',
            value: 'option1'
        },
        {
            id: '2',
            label: 'Option 2',
            value: 'option2'
        }
    ]), []);

    const [selectedId, setSelectedId] = useState();

    return (
        <RadioGroup 
            radioButtons={radioButtons} 
            onPress={setSelectedId}
            selectedId={selectedId}
        />
    );

}

Typescript Example
App.tsx
import React, { useMemo, useState } from 'react';
import RadioGroup, {RadioButtonProps} from 'react-native-radio-buttons-group';

export default function App() {

    const radioButtons: RadioButtonProps[] = useMemo(() => ([
        {
            id: '1', // acts as primary key, should be unique and non-empty string
            label: 'Option 1',
            value: 'option1'
        },
        {
            id: '2',
            label: 'Option 2',
            value: 'option2'
        }
    ]), []);

    const [selectedId, setSelectedId] = useState<string | undefined>();

    return (
        <RadioGroup 
            radioButtons={radioButtons} 
            onPress={setSelectedId}
            selectedId={selectedId}
        />
    );

}

Props

RadioButton
KeyTypeRequiredDefaultValid Values
accessibilityLabelstringnoradio buttonany string
borderColorstringnocolorcss color formats
borderSizenumber2positive numbers
colorstringno#444css color formats
containerStyleobjectnoreact style
descriptionstringnoany string
descriptionStyleobjectnoreact style
disabledbooleannofalsetrue / false
idstringyesunique string
labelstringnoany string
labelStyleobjectnoreact style
layoutenumnorowrow / column
onPressfunctionnoany function
selectedbooleannofalsetrue / false
sizenumberno24positive numbers
testIDstringnoany string
valuestringnoany string
RadioGroup
KeyTypeRequiredDefaultValid Values
accessibilityLabelstringnoradio groupany string
containerStyleobjectnoreact style
layoutenumnocolumnrow / column
onPressfunctionnoany function
radioButtonsarrayyesarrary of RadioButton objects
selectedIdstringnounique string
testIDstringnoany string
Horizontal (side by side)
<RadioGroup 
    radioButtons={radioButtons} 
    onPress={onPressRadioButton} 
    layout='row'
/>

Contributions

Fork and create a pull request

License

MIT License

Stargazers over time

Stargazers over time

Sponsor

Buy Me A Coffee

Keywords

FAQs

Last updated on 30 Sep 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc