ANT Components
Forms
Example Form
import { FormInput, FormButton } from './components/common';<form onSubmit={handleSubmit}> <FormInput placeholder="Email" name="email" labelId="User Email" /> <FormButton buttonText="Submit" classType="default" disabled="false" /></form>CopyAnt Design Form
import { Form, Input, Button } from 'antd';<Form onFinish={handleSubmit}> <Form.Item label="My Input" > <Input /> </Form.Item> <Form.Item> <Button type="primary" htmlType="submit"> Submit </Button> </Form.Item></Form>Copyconst layout = { // This specifies how wide we want our form container (wrapper) to be, // where a span of 24 is equivalent to 100%. wrapperCol: { span: 8, } }; // To use our layout we can spread our layout object on our Form component: <Form onFinish={handleSubmit} {...layout}> <Form.Item label="My Input" > <Input /> </Form.Item> <Form.Item> <Button type="primary" htmlType="submit"> Submit </Button> </Form.Item></Form>Copyconst itemLayout = { wrapperCol: { offset: 4, span: 8 },}<Form onFinish={handleSubmit} {...layout}> <Form.Item label="My Input" > <Input /> </Form.Item> <Form.Item {...itemLayout}> <Button type="primary" htmlType="submit"> Submit </Button> </Form.Item></Form>Copyconst myRules = [ { required: true, message: 'Please input your email!', }, { type: 'email', message: 'Please enter a valid email', },];<Form onFinish={handleSubmit} {...layout}> <Form.Item label="Email" name="email" rules={myRules} > <Input /> </Form.Item> <Form.Item {...itemLayout}> <Button type="primary" htmlType="submit"> Submit </Button> </Form.Item></Form>CopyComponents Overview
General3
Layout4
Navigation7
Data Entry17
Data Display19
Feedback10
Other3
Last updated