You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
46 lines
1.4 KiB
import React, { useState } from 'react';
|
|
import { InfoCircleOutlined } from '@ant-design/icons';
|
|
import { Button, Form, Input, Radio } from 'antd';
|
|
|
|
type RequiredMark = boolean | 'optional';
|
|
|
|
const App: React.FC = () => {
|
|
const [form] = Form.useForm();
|
|
const [requiredMark, setRequiredMarkType] = useState<RequiredMark>('optional');
|
|
|
|
const onRequiredTypeChange = ({ requiredMarkValue }: { requiredMarkValue: RequiredMark }) => {
|
|
setRequiredMarkType(requiredMarkValue);
|
|
};
|
|
|
|
return (
|
|
<Form
|
|
form={form}
|
|
layout="vertical"
|
|
initialValues={{ requiredMarkValue: requiredMark }}
|
|
onValuesChange={onRequiredTypeChange}
|
|
requiredMark={requiredMark}
|
|
>
|
|
<Form.Item label="Required Mark" name="requiredMarkValue">
|
|
<Radio.Group>
|
|
<Radio.Button value="optional">Optional</Radio.Button>
|
|
<Radio.Button value>Required</Radio.Button>
|
|
<Radio.Button value={false}>Hidden</Radio.Button>
|
|
</Radio.Group>
|
|
</Form.Item>
|
|
<Form.Item label="Field A" required tooltip="This is a required field">
|
|
<Input placeholder="input placeholder" />
|
|
</Form.Item>
|
|
<Form.Item
|
|
label="Field B"
|
|
tooltip={{ title: 'Tooltip with customize icon', icon: <InfoCircleOutlined /> }}
|
|
>
|
|
<Input placeholder="input placeholder" />
|
|
</Form.Item>
|
|
<Form.Item>
|
|
<Button type="primary">Submit</Button>
|
|
</Form.Item>
|
|
</Form>
|
|
);
|
|
};
|
|
|
|
export default App;
|
|
|