ant-design/components/form/demo/variant.tsx
thinkasany a8a7f31a15
Some checks failed
Publish Any Commit / build (push) Has been cancelled
✅ test v6 / lint (push) Has been cancelled
✅ test v6 / test-react-legacy (18, 1/2) (push) Has been cancelled
✅ test v6 / test-react-legacy (18, 2/2) (push) Has been cancelled
✅ test v6 / test-node (push) Has been cancelled
✅ test v6 / test-react-latest (dom, 1/2) (push) Has been cancelled
✅ test v6 / test-react-latest (dom, 2/2) (push) Has been cancelled
✅ test v6 / build (push) Has been cancelled
✅ test v6 / test lib/es module (es, 1/2) (push) Has been cancelled
✅ test v6 / test lib/es module (es, 2/2) (push) Has been cancelled
✅ test v6 / test lib/es module (lib, 1/2) (push) Has been cancelled
✅ test v6 / test lib/es module (lib, 2/2) (push) Has been cancelled
👁️ Visual Regression Persist Start / test image (push) Has been cancelled
✅ test v6 / test-react-latest-dist (dist, 1/2) (push) Has been cancelled
✅ test v6 / test-react-latest-dist (dist, 2/2) (push) Has been cancelled
✅ test v6 / test-react-latest-dist (dist-min, 1/2) (push) Has been cancelled
✅ test v6 / test-react-latest-dist (dist-min, 2/2) (push) Has been cancelled
✅ test v6 / test-coverage (push) Has been cancelled
demo(form): label set to null (#52188)
2024-12-31 22:55:34 +08:00

121 lines
2.5 KiB
TypeScript

import React from 'react';
import {
Button,
Cascader,
DatePicker,
Form,
Input,
InputNumber,
Mentions,
Select,
TreeSelect,
Segmented,
} from 'antd';
const { RangePicker } = DatePicker;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 14 },
},
};
const App: React.FC = () => {
const [form] = Form.useForm();
const variant = Form.useWatch('variant', form);
return (
<Form
{...formItemLayout}
form={form}
variant={variant || 'filled'}
style={{ maxWidth: 600 }}
initialValues={{ variant: 'filled' }}
>
<Form.Item label="Form variant" name="variant">
<Segmented options={['outlined', 'filled', 'borderless']} />
</Form.Item>
<Form.Item label="Input" name="Input" rules={[{ required: true, message: 'Please input!' }]}>
<Input />
</Form.Item>
<Form.Item
label="InputNumber"
name="InputNumber"
rules={[{ required: true, message: 'Please input!' }]}
>
<InputNumber style={{ width: '100%' }} />
</Form.Item>
<Form.Item
label="TextArea"
name="TextArea"
rules={[{ required: true, message: 'Please input!' }]}
>
<Input.TextArea />
</Form.Item>
<Form.Item
label="Mentions"
name="Mentions"
rules={[{ required: true, message: 'Please input!' }]}
>
<Mentions />
</Form.Item>
<Form.Item
label="Select"
name="Select"
rules={[{ required: true, message: 'Please input!' }]}
>
<Select />
</Form.Item>
<Form.Item
label="Cascader"
name="Cascader"
rules={[{ required: true, message: 'Please input!' }]}
>
<Cascader />
</Form.Item>
<Form.Item
label="TreeSelect"
name="TreeSelect"
rules={[{ required: true, message: 'Please input!' }]}
>
<TreeSelect />
</Form.Item>
<Form.Item
label="DatePicker"
name="DatePicker"
rules={[{ required: true, message: 'Please input!' }]}
>
<DatePicker />
</Form.Item>
<Form.Item
label="RangePicker"
name="RangePicker"
rules={[{ required: true, message: 'Please input!' }]}
>
<RangePicker />
</Form.Item>
<Form.Item label={null}>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
);
};
export default App;