Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change form.item label font size in AntD

I'm using styled components something like this

const FormItem = styled(Form.Item)`
     font-size: 16px;
`;

Using Form Item something like this

    <FormItem label="System Pressurized">
    {getFieldDecorator('systemPressurized')(
      <Select defaultValue="" placeholder="Select Type">
        <Option value="Yiminghe">yiminghe</Option>
      </Select>,
    )}
  </FormItem>

I've tried changing font size of AntD but it doesn't seem to workout

like image 514
Afaq Ahmed Khan Avatar asked Apr 22 '19 11:04

Afaq Ahmed Khan


People also ask

What font does ant design use?

Ant Design prefers the system default font family and then also provides a set of alternative font libraries to maintain readability for screens on different platforms and browsers and to make sure it's always user friendly, stable and professional to end user.

What is wrapperCol?

wrapperCol: It is used to denote the layout for input controls. onFieldsChange: It is a callback function that is triggered when the field updated. onFinish: It is a callback function that is triggered after submitting the form and verifying data successfully.

How do you use the getFieldDecorator in ANTD?

Just use Form. Item directly: // antd v3 const Demo = ({ form: { getFieldDecorator } }) => ( <Form> <Form. Item> {getFieldDecorator('username', { rules: [{ required: true }], })(<Input />)} </Form.


1 Answers

There are multiple options to override style element.

  1. You can directly override label element from global css file like
 label { 
   font-size:16px;
}
  1. Individual element by adding script to label element.
   <FormItem label={ 
<p style={{fontSize:"16px"}}>"System Pressurized"</p>
}>
{getFieldDecorator('systemPressurized')(
<Select defaultValue="" placeholder="Select Type">
   <Option value="Yiminghe">yiminghe</Option>
</Select>
)
}
</FormItem>
like image 173
Siddharth Bagal Avatar answered Sep 20 '22 05:09

Siddharth Bagal