1.0.1 • Published 1 year ago

rn-multiple-choices v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

PropTypeDescription
titlestringtitle string
choicesarraystringArray of choice
onSelectionfunccallback for option is selected

Custom styling

PropTypeDescription
containerStyleobjectparent container style
titleStyleobjecttitle/question textStyle
choicesContainerStyleobjectcontainer style for choices/options
choiceButtonStyleobjectbutton style for choices/options
choiceTextColorstringchoice text & radio icon color value

Authors

Contributing

Contributions are always welcome!

License

MIT License MIT