--- order: 3.1 title: zh-CN: 必选样式 en-US: Required style --- ## zh-CN 通过 `requiredMark` 切换必选与可选样式。 ## en-US Switch required or optional style with `requiredMark`. ```tsx import React, { useState } from 'react'; import { Form, Input, Button, Radio } from 'antd'; import { InfoCircleOutlined } from '@ant-design/icons'; type RequiredMark = boolean | 'optional'; const FormLayoutDemo = () => { const [form] = Form.useForm(); const [requiredMark, setRequiredMarkType] = useState('optional'); const onRequiredTypeChange = ({ requiredMarkValue }: { requiredMarkValue: RequiredMark }) => { setRequiredMarkType(requiredMarkValue); }; return (
Optional Required Hidden }} >
); }; ReactDOM.render(, mountNode); ```