Field

Install

import React from 'react';
import { Field } from 'vant-react';

Usage

Basic Usage

<Field />

Require Field

<Field label='Required' required />

Custom Types

<Field label='Text' type='text' />
<Field label='Phone' type='tel' />
<Field label='Digit' type='digit' />
<Field label='Number' type='number' />
<Field label='Password' type='password' />

Disabled

Colon

ShowIcon

Field Events

Field Ref

Auto Focus

Error Info

Max Length Word Limit

Field With Button

Formatter

Label Utilities

Label Input Alignment

Auto Resize

API

Props

Attribute

Description

Type

Default

Required

value

Filed value

string

-

optional

type

Can be set to text tel digit number password

string

text

optional

label

Field label

string

-

optional

name

Name

string

-

optional

placeholder

Placeholder

string

-

optional

readonly

Whether to be readonly

boolean

false

optional

disabled

Whether to display colon after label

boolean

false

optional

colon

Whether to be readonly

boolean

false

optional

labelIcon

Label icon that appears on the left

string

-

optional

leftIcon

Left side icon name

string

-

optional

rightIcon

Right side icon name

string

-

optional

clearable

Whether to be clearable

boolean

false

optional

clickable

Whether to show click feedback when clicked

boolean

false

optional

autofocus

Whether to auto focus

boolean

false

optional

error

Whether to show error info

boolean

false

optional

error-message

Error message

string

-

optional

maxLength

Max length of value

number

-

optional

showWordLimit

Whether to show word limit, need to set maxLength prop

boolean

false

optional

formatter

Input value formatter

Function

true

optional

labelClass

Label className

string

-

optional

labelWidth

Label width

string

-

optional

labelAlign

Label align, can be set tocenter right

TAlignment

left

optional

inputAlign

Input align, can be set tocenter right

TAlignment

left

optional

errorAlign

Error message align, can be set tocenter right

TAlignment

left

optional

required

Whether to show required mark

boolean

false

optional

border

Whether to show inner border

boolean

true

optional

Event

Event

Description

Arguments

input

Triggered when input value changed

value: String

clear

Triggered when click clear icon

event: Event

click

Triggered when click Field

event: Event

clickInput

Triggered when click input

event: Event

focus

Triggered when input gets focus

event: Event

blur

Triggered when input loses focus

event: Event

clickLeftIcon

Triggered when click the left icon of Field

event: Event

clickRightIcon

Triggered when click the right icon of Field

event: Event

getContainerRef

Triggered when container ref is not undefined nor null

event: Event

getFieldRef

Triggered when Field ref is not undefined nor null

event: Event

focus

Triggered when input gets focus

event: Event

Last updated

Was this helpful?