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

react-native-radio-buttonx

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-radio-buttonx

test

1.0.1
latest
Source
npm
Version published
Weekly downloads
7
-53.33%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-radio-buttonx

Create radio buttons with a range of styles and customize the radio button selector using your own custom component. This package is perfect for developers who need to create visually appealing and interactive radio buttons in their mobile applications

Demo Image

Installation

npm install react-native-radio-buttonx

Usage

import { StyleSheet, Text, View, Image } from 'react-native';
import { useState } from 'react';
import { RadioButtons } from 'react-native-radio-buttonx';


const foo = () => {
  return (
    <Image source={require('./assets/favicon.png')}  style={{width: 12, height: 12}}/>
    //<Text>✅</Text>
  )
}

export default function App() {

  const [selectedOption, setSelectedOption] = useState('Apple');
  
  const handleSelect = (option: string) => {
    setSelectedOption(option);
  };

  return (
    <View style={styles.container}>
      <Text style={{marginBottom: 40}}>Selected: {selectedOption}</Text>
      
      <RadioButtons
          gap={19}
          options={['Apple','Orange','Banana']}
          selectedOption={selectedOption}
          onSelect={handleSelect}
          styleOptions={styleOptions}
          //SelectorComponent={foo}

          />

    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});


const styleOptions = {
  rounded: true,
  radio: 20,
  display: 'column',
  //defaultColor: 'gray',
  //selectedColor: 'brown',
  //fontWeight: 'bold',
  //fontSize: 20,
  //fontStyle: 'italic',
  //color: 'brown'
}
// ...

Props

The RadioButtons component accepts the following props:

PropertyTypeRequiredDescription
optionsArray<string>YesAn array of options to be displayed as radio buttons
selectedOptionstringYesThe currently selected option
onSelect(option: string) => voidYesA function to be called when an option is selected
gapnumberNoThe gap between the radio buttons
styleOptionsStyleOptionsNoAn object containing style options for the radio buttons
SelectorComponentReact.ComponentTypeNoA custom component to be used as the selector for the radio buttons

The StyleOptions type is defined as follows:

type StyleOptions = {
  rounded?: boolean;
  radio?: number;
  display?: 'row' | 'column';
  defaultColor?: string;
  selectedColor?: string;
  fontWeight?: string;
  fontSize?: number;
  fontStyle?: 'normal' | 'italic' | 'oblique';
  color?: string;
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

If you find this project helpful, please consider buying me a coffee.

Buy Me A Coffee

License

MIT

Made with :heart: by Énio Carlos

Keywords

react-native-radio-buttons

FAQs

Package last updated on 01 Apr 2023

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