Skip to content

Latest commit

 

History

History
150 lines (118 loc) · 3.7 KB

File metadata and controls

150 lines (118 loc) · 3.7 KB

ZipcodeField

TextField unfocused TextField with placeholder TextField focused TextField focused

Usage

import React, { useState } from 'react';
import { ZipcodeField } from '@pbsc/react-native-ui-components';

// ...

const [postalCode, setPostalCode] = useState('');

const handlePostalcodeSubmit = (value) => {
    setPostalCode(value);
    console.log(`PostalCode: ${value}`);
};

// ...

<ZipcodeField
    label="Postal Code"
    country="ca"
    onSubmitEditing={handlePostalcodeSubmit}
    helperText="Please input your postal code."
    hasHelperTextIcon={true}
        helperTextCustomIcon={
        <Image
            source={require('../images/info.png')}
            style={{ width: 12, height: 12 }}

        />
        }
/>

Props

label

Type: string
The text to use for the floating label.

value

Type: string
The value to show for the ZipcodeField.

placeholder

Type: string
Placeholder for the TextField.

country

Type: string
Default value: 'CA'
The country code for the zip code field. Changes maximum length of input text. Value needs to follow ISO 3166-1 alpha-2.

hasError

Type: boolean
Default value: false
When it is true, the ZipcodeField shows up with error style. (The color of the TextField and its helper text turns to error color)

errorColor

Type: hexColorCode (ex: #ff00ff)
Default value: #b00020
Color for error state

helperText

Type: string
Text for additional info. Can be used to show error message with hasError prop.

onChangeText

Type: Function
Callback that is called when the ZipcodeField's text changes. Changed text is passed as an argument to the callback handler.

onSubmitEditing

Type: Function
Callback that is called when the ZipcodeField's submit button (enter button on the keyboard) is pressed.

onBlur

Type: Function
Callback that is called when the ZipcodeField is blurred.

onFocus

Type: Function
Callback that is called when the ZipcodeField is focused.

disabled

Type: boolean
Default value: false
If true, user won't be able to interact with the component.

editable

Type: boolean
Default value: true
If false, text is not editable.

width

Type: string/number
Default value: '80%'
Set the width of the TextField

height

Type: string/number
Default value: 48 Set the height of the TextField

activeColor

Type: hexColorCode (ex: #ff00ff)
Default value: #9a9a9a
Outline color when it is active (focused)

inactiveColor

Type: hexColorCode (ex: #ff00ff)
Default value: #9a9a9a
Outline color when it is inactive (blurred)

backgroundColor

Type: hexColorCode (ex: #ff00ff)
Default value: #ffffff
Background color

textColor

Type: hexColorCode (ex: #ff00ff)
Default value: #000000
Text color

style

Type: object
Set style of the container part

textInputStyle

Type: object
Set style of text input part

helperTextStyle

Type: object
Set style of helper text part

hasHelperTextIcon

Type: boolean
Enable custom component (ex: helperTextCustomIcon) to place before helperText

helperTextCustomIcon

Type: jsx component
A custom component (usually svg component or Image) to place icon before helperText and can be used for errors as well.