rn-multiple-choices

1.0.1 • Public • Published

rn-multiple-choices

React native component for multiple choice questions-answers/choices.

Install

To add this package to your project:

npm

  npm install rn-multiple-choices

yarn

  yarn add rn-multiple-choices

Usage

Import

import MultipleChoice from 'rn-multiple-choices';

Basic

                <MultipleChoice
                    title={'What is ReactJS?'}
                    choices={['Server-side framework', 'user interface framework', 'both a and b', 'none of the above']}
                    onSelection={(index, choice) => {
                        console.log('selected choice index', index)
                        console.log('selected choice value', choice)
                    }}
                />

Basic usage

Custom styling

                <MultipleChoice
                    title={'What is ReactJS?'}
                    choices={['Server-side framework', 'user interface framework', 'both a and b', 'none of the above']}
                    onSelection={(index, choice) => {
                        console.log('selected choice index', index)
                        console.log('selected choice value', choice)
                    }}
                    containerStyle={{backgroundColor: '#bfc2c7', paddingVertical: 25, paddingHorizontal: 10, borderRadius: 6}}
                    titleStyle={{fontSize: 24, color: '#1D5C5D'}}
                    choicesContainerStyle={{marginTop: 10, padding: 10, borderWidth: 0.5, borderColor: '#1D5C5D', borderRadius: 12}}
                    choiceButtonStyle={{width : '100%', alignItems: 'flex-start'}}
                    choiceTextColor={'#1D5C5D'}
                />

Custom styling

Props

Basic

Prop Type Description
title string title string
choices array[string] Array of choice
onSelection func callback for option is selected

Custom styling

Prop Type Description
containerStyle object parent container style
titleStyle object title/question textStyle
choicesContainerStyle object container style for choices/options
choiceButtonStyle object button style for choices/options
choiceTextColor string choice text & radio icon color value

Authors

Contributing

Contributions are always welcome!

License

MIT License MIT

Package Sidebar

Install

npm i rn-multiple-choices

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

9.24 kB

Total Files

5

Last publish

Collaborators

  • little-infinity