1.1.19 β€’ Published 2 months ago

react-native-basic-elements v1.1.19

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

react-native-basic-elements

Note: This README is only relevant to the latest version of our plugin. If you are using an older version, please switch to the relevant tag on our GitHub repo to view the docs for that particular version. This plugin provides basic components of React Native for Easy Design and smooth experience to your React Native app(s).

πŸŽ‰ πŸŽ‰ πŸŽ‰Special Announcement: We launch a new package react-native-basic-element-generator for generating react native project with a pre-defined file structure and some necessary configuration. It is ready to use.πŸŽ‰ πŸŽ‰ πŸŽ‰

Table of Contents

Getting Started

Follow the instruction given bellow

npm install react-native-basic-elements

After run this command you have successfully install this plugin. Now you have to install react-native-vector-icons because we use icon internally.

npm install --save react-native-vector-icons

After installing react-native-vector-icons you have to configure it. Read the configuration process of react-native-vector-icons

Components

CheckBox Component

Example

import React, { useState } from 'react'
import {CheckBox} from 'react-native-basic-elements';

const MyComponent = () => {
    const [check, setCheck] = useState(false);
    return (
        <CheckBox
            checked = {check}
            onChange = {(val) => setCheck(val)}
            size = {25}
        >
    )
}

ezgif com-gif-maker

Properties

PropsDescriptionDefault
checkedThis is the default value of CheckBox. Props type booleanfalse
activeColorThis color show when checked is set to true'blue'
inactiveColorThis color show when checked is set to false'#999'
tintColorColor of check icon.'#fff'
sizeSize of checkBox16
containerStyleWith this you can change the style of checkboxundefined

Method

PropsDescription
onChnageThis callback function is called when you click on checkbox. It returns boolean value

RadioButton Component

Example

import React, { useState } from 'react'
import {RadioButton} from 'react-native-basic-elements';

const MyComponent = () => {
    const [selected, setSelected] = useState(false);
    return (
        <RadioButton
            selected = {selected}
            onChange = {(val) => setSelected(val)}
            size = {25}
        >
    )
}

ezgif com-gif-maker-2

Properties

PropsDescriptionDefault
selectedThis is the default value of RadioButton. Props type booleanfalse
activeColorThis color show when selected is set to true'blue'
inactiveColorThis color show when selected is set to false'#999'
sizeSize of RadioButton20
containerStyleWith this you can change the style of RadioButtonundefined

Method

PropsDescription
onChnageThis callback function is called when you click on RadioButton. It returns boolean value

Card Component

This is a card with pre-styled and clickable.

Example

import {Card} from 'react-native-basic-elements';

const MyComponent = () => {
    return (
        <Card>
            {/* Your JSX Elements */}
        </Card>
    )
}

Properties

PropsDescriptionDefault
styleFor styling the card.undefined
shadowThis is for enabling or disabling pre defined shadow. Also you can overwrite them with defining shadow in style. It take boolean value.true

And it also support all View and Pressable props.

StatusBar Component

This is for status bar that configured on android and ios both.

Example

import {StatusBar} from 'react-native-basic-elements';

const MyComponent = () => {
    return (
        <StatusBar
            backgroundColor={'green'}
            barStyle = 'light-content'
        />
    )
}

Properties

PropsDescriptionDefault
backgroundColorFor statusbar color.#fff
barStyleFor StatusBar content color. Value type **`enum('dark-content', 'light-content') | 'dark-content'
hiddenThis is used for show or hide the statusbar.false
translucentIf the status bar is translucent. When translucent is set to true, the app will draw under the status bar. This is useful when using a semi transparent status bar color.false

Text Components

Screenshot 2022-09-12 at 10 47 55 PM

import {Container, Text} from 'react-native-basic-elements';

const MyComponent = () => {
    return (
        <Container
            style = {{
                alignItems: 'center'
            }}
        >
            <Text>
                This is my Text
            </Text>

            <Text.Heading
                title='This is my Heading'
            />

            <Text.SubHeading
                title='This is my SubHeading'
            />
        </Container>
    )
}

export default MyComponent;

We have 3 types of pre-configured Text Components bellow :

Text

It's same as react-native Text component but it takes color autometic from theme.

Heading & SubHeading

PropsDescription
titleIt takes string in title.
styleIt is for styling the text.

And all Text props are available in those components.

Accordion

Example

import { Accordion } from 'react-native-basic-components';

const MyComponent = () => {
    return (
        <Accordion
            leftIcon={{
                name: 'home',
                size: 25
            }}
            title='Home'
            containerStyle={{
                margin: 10
            }}
            shadow={true}
        >
            {/* your design */}
        </Accordion>
    )
}

export default MyComponent;

Properties

PropsDescriptionDefault
titleTitle of the accordion.undefined
leftIconIcon in the left side of the Title. Type of Icon Propsundifined
openIconIt is used for right indicator when accordion is oppned'chevron-up'
closeIconIt is used for right indicator when accordion is closed'chevron-down'
titleStyleStyle for title.undefined
containerStyleStyle for accordion containerundefined
inputStyleStyle for accordion Inputundefined
shadowIf it is true then accordion has a shadowfalse
customElementYou can add custom components from here.undefined
bottomElementYou can add bottom components that is visiable when accordion is openedundefined

Accordion-Item

Example

import { Accordion } from 'react-native-basic-components';

const MyComponent = () => {
    return (
        <Accordion
            leftIcon={{
                name: 'home',
                size: 25
            }}
            title='Home'
            containerStyle={{
                margin: 10
            }}
            shadow={true}
        >
            <Accordion.Item
                title='Home 1'
                leftIcon={{
                    name: 'thumbs-up',
                    type: 'Feather'
                }}
            />

            <Accordion.Item
                title='Home 2'
                leftIcon={{
                    name: 'upload',
                    type: 'Feather'
                }}
            />

            <Accordion.Item
                title='Home 2'
                leftIcon={{
                    name: 'upload',
                    type: 'Feather'
                }}
            />
        </Accordion>
    )
}

export default MyComponent;

ezgif com-gif-maker (2)

Properties

PropsDescriptionDefault
titleTitle of the accordion item.undefined
leftIconIcon in the left side of the Title. Type of Icon Propsundifined
titleStyleStyle for title.undefined
styleStyle for accordion item containerundefined
leftSpacingIf it is true then the item take some spacing from lefttrue

Accordion-Custom

Example

import { Accordion } from 'react-native-basic-components';

const MyComponent = () => {
    return (
        <Accordion
            leftIcon={{
                name: 'home',
                size: 25
            }}
            title='Home'
            containerStyle={{
                margin: 10
            }}
            shadow={true}
        >
            <Accordion.Custom
                children={<View
                    style={{
                        height: 200,
                        flex: 1,
                        borderWidth: 1
                    }}
                />}
            />
        </Accordion>
    )
}

export default MyComponent;

Properties

PropsDescriptionDefault
styleStyle for accordion item containerundefined
leftSpacingIf it is true then the item take some spacing from lefttrue
childrenThis is the custom childrenrequired

Dropdown Picker

Select Dropdown

Example

import {Picker} from 'react-native-basic-components';

const MyComponent = () => {
    const [dropdownValue, setDropdownValue] = useState('');
    return (
        <Picker
            options={[
                {
                    label: 'Item 1',
                    value: 'item1'
                },
                {
                    label: 'Item 2',
                    value: 'item2'
                },
                {
                    label: 'Item 3',
                    value: 'item3'
                },
                {
                    label: 'Item 4',
                    value: 'item4'
                },
                {
                    label: 'Item 5',
                    value: 'item5'
                },
            ]}
            placeholder="PlaceHolder"
            textStyle={{
                fontSize: 15
            }}
            selectedValue={dropdownValue}
            onValueChange={(val) => setDropdownValue(val)}
        />
    )
}

Properties

PropsDescriptionDefault
styleStyle of the Picker Component.undefined
optionsIt takes an Array as options for the picker.[]
placeholderPlaceholder for the Picker Inputundefined
showPlaceholderShow the placeholder or not.undefined
labelKeyIt takes that key as the lebel key from options Array'label'
valueKeyIt takes that key as the value key from options Array'value'
selectedValueIt takes the defalut value(Required)''
modeThis is the mode of the Picker. Value type **`enum('dropdown', 'dialog') |dropdown
containerStyleThis is the Style of the input containerundefined
iosModalBackGroundColorThis is for ios. It change the modal background color.Theme card color
onValueChangeCallback that is called when the picker change it's value. Changed item value is passed as a single string argument to the callback handler.undefined
dropdownIconColorOn Android, specifies color of dropdown triangle.undefined

Multi Select Dropdown

Example

import {Picker} from 'react-native-basic-components';

const MyComponent = () => {
    const [dropdownValue, setDropdownValue] = useState([]);
    return (
        <Picker.Multi
                options={[
                    {
                        label: 'Item 1',
                        value: 'item1'
                    },
                    {
                        label: 'Item 2',
                        value: 'item2'
                    },
                    {
                        label: 'Item 3',
                        value: 'item3'
                    },
                    {
                        label: 'Item 4',
                        value: 'item4'
                    },
                    {
                        label: 'Item 5',
                        value: 'item5'
                    },
                    {
                        label: 'Item 6',
                        value: 'item6'
                    },
                    {
                        label: 'Item 7',
                        value: 'item7'
                    },
                    {
                        label: 'Item 8',
                        value: 'item8'
                    },
                    {
                        label: 'Item 9',
                        value: 'item9'
                    },
                    {
                        label: 'Item 10',
                        value: 'item10'
                    },
                ]}
                returnDataType={(item) => { return {value: item.value} }}
                onValueChange={(val) => {
                    setDropdownValue(val)
                }}
                selectedValues={dropdownValue}
            />
    )
}

Properties

PropsDescriptionDefault
modalContainerStyleStyle for modal container.undefined
optionsIt takes an Array as options for the picker.[]
placeholderPlaceholder for the Picker Inputundefined
placeholderStyleStyle for picker placeholder.undefined
labelKeyIt takes that key as the lebel key from options Array'label'
valueKeyIt takes that key as the value key from options Array'value'
selectedValuesIt takes the defalut value(Required)[]
closeIconModal Close Icon. Type of Icon Propsundefined
modalHeadingHeading of the Selection modal'Choose'
modalHeadingTitleHeading text style of the Selection modalundefined
itemContainerStyleThis is the Item List style.undefined
itemTextStyleThis is the Item List text style.undefined
selectedIconThis is the selected item icon. Type of Icon Propsundefined
itemTextStyleThis is the Item List text style.undefined
onValueChangeCallback that is called when the picker change it's value. Changed item value is passed as a single string argument to the callback handler.undefined
returnDataTypeTakes an item from options, and which data type you return that will be give as value in onValueChange.(item) => {return itemvalueKey}

Custom Select Dropdown

Example

import {Picker} from 'react-native-basic-components';

const MyComponent = () => {
    const [dropdownValue, setDropdownValue] = useState([]);
    return (
        <Picker.Custom
            selectedValue={dropdownValue}
            options={[
                {
                    label: 'Item 1',
                    value: 'item1'
                },
                {
                    label: 'Item 2',
                    value: 'item2'
                },
                {
                    label: 'Item 3',
                    value: 'item3'
                },
                {
                    label: 'Item 4',
                    value: 'item4'
                },
                {
                    label: 'Item 5',
                    value: 'item5'
                },
                {
                    label: 'Item 6',
                    value: 'item6'
                },
                {
                    label: 'Item 7',
                    value: 'item7'
                },
                {
                    label: 'Item 8',
                    value: 'item8'
                },
                {
                    label: 'Item 9',
                    value: 'item9'
                },
                {
                    label: 'Item 10',
                    value: 'item10'
                },
            ]}
            placeholder='Dropdown'
            renderItem={(item, index, onPress, isSelected) => {
                return (
                    <Pressable
                        style={{
                            height: 50,
                            justifyContent: 'center',
                            paddingHorizontal: 10,
                            backgroundColor: isSelected ? 'green' : undefined
                        }}
                        onPress={onPress}
                    >
                        <Text>{item['label']}</Text>
                    </Pressable>
                )
            }}
            onValueSelect={setDropdownValue}
        />
    )
}

Properties

PropsDescriptionDefault
inputStyleStyle for dropdown input.undefined
inputTextStyleText Style of dropdown input.undefined
selectedValueIt takes the defalut value(Required)''
placeholderPlaceholder for the Picker Inputundefined
placeholderColorColor for picker placeholder.'#999'
optionsIt takes an Array as options for the picker.[]
labelKeyIt takes that key as the lebel key from options Array'label'
valueKeyIt takes that key as the value key from options Array'value'
backdropColorIt is the color of backdrop.'#000000'
backdropOpacityIt is opacity of the color of backdrop.0.5
backdropIt takes a boolean value to ensure that backdrop is shown or nottrue
modalContainerStyleStyle for modal container.undefined
modalBackgroundColorBackground Color for modal container.'#ffffff
closeIconModal Close Icon. Type of Icon Propsundefined
inputRightIconInput Right Icon. Type of Icon Propsundefined
modalHeadingHeading of the Selection modal'Choose'
modalHeadingTitleHeading text style of the Selection modalundefined
modalHeaderShadowShow the header shadow or not.true
showHeaderShow the header or not.true
onValueSelectCallback that is called when the picker change it's value. Changed item value is passed as a single string argument to the callback handler.undefined
renderItemIt's a function. From it, you should return a ReactElement that will show in the modal as an item.undefined

Outline Select Dropdown

Example

import {Picker} from 'react-native-basic-components';

const MyComponent = () => {
    const [dropdownValue, setDropdownValue] = useState([]);
    return (
        <Picker.Outline
            selectedValue={dropdownValue}
            options={[
                {
                    label: 'Item 1',
                    value: 'item1'
                },
                {
                    label: 'Item 2',
                    value: 'item2'
                },
                {
                    label: 'Item 3',
                    value: 'item3'
                },
                {
                    label: 'Item 4',
                    value: 'item4'
                },
                {
                    label: 'Item 5',
                    value: 'item5'
                },
                {
                    label: 'Item 6',
                    value: 'item6'
                },
                {
                    label: 'Item 7',
                    value: 'item7'
                },
                {
                    label: 'Item 8',
                    value: 'item8'
                },
                {
                    label: 'Item 9',
                    value: 'item9'
                },
                {
                    label: 'Item 10',
                    value: 'item10'
                },
            ]}
            placeholder='Dropdown'
            renderItem={(item, index, onPress, isSelected) => {
                return (
                    <Pressable
                        style={{
                            height: 50,
                            justifyContent: 'center',
                            paddingHorizontal: 10,
                            backgroundColor: isSelected ? 'green' : undefined
                        }}
                        onPress={onPress}
                    >
                        <Text>{item['label']}</Text>
                    </Pressable>
                )
            }}
            onValueSelect={setDropdownValue}
        />
    )
}

Properties

PropsDescriptionDefault
inputStyleStyle for dropdown input.undefined
borderWidthStyle for border width .1
inputTextStyleText Style of dropdown input.undefined
selectedValueIt takes the defalut value(Required)''
placeholderPlaceholder for the Picker Inputundefined
activeBorderColorThis is the color of the input border when the input is Focused'blue'
inactiveBorderColorThis is the color of the input border when the input is not Focused'#000'
placeholderColorColor for picker placeholder.'#999'
placeholderTextStyleThis is tha style for styling the placeholder text.'#999'
optionsIt takes an Array as options for the picker.[]
labelKeyIt takes that key as the lebel key from options Array'label'
valueKeyIt takes that key as the value key from options Array'value'
backdropColorIt is the color of backdrop.'#000000'
backdropOpacityIt is opacity of the color of backdrop.0.5
backdropIt takes a boolean value to ensure that backdrop is shown or nottrue
modalContainerStyleStyle for modal container.undefined
modalBackgroundColorBackground Color for modal container.'#ffffff
containerStyleIt is the style of the whole container including.none
closeIconModal Close Icon. Type of Icon Propsundefined
inputRightIconInput Right Icon. Type of Icon Propsundefined
modalHeadingHeading of the Selection modal'Choose'
modalHeadingTitleHeading text style of the Selection modalundefined
modalHeaderShadowShow the header shadow or not.true
placeholderTextSizeShow the header shadow or not.18
showHeaderShow the header or not.true
modalHeadingTitleStyleIt is the style of Modal Heading.undefine
onValueSelectCallback that is called when the picker change it's value. Changed item value is passed as a single string argument to the callback handler.undefined
renderItemIt's a function. From it, you should return a ReactElement that will show in the modal as an item.undefined
1.1.19

2 months ago

1.1.18

3 months ago

1.1.16

4 months ago

1.1.17

4 months ago

1.1.15

5 months ago

1.1.14

5 months ago

1.1.13

5 months ago

1.1.9

9 months ago

1.1.8

9 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

10 months ago

1.1.12

8 months ago

1.1.11

8 months ago

1.1.10

8 months ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago