I am using Ant Design React and I want to create a form where the label of a Form.Item is displayed to the right of the input field.
By default, the label is displayed to the left of the input field. I tried to set the labelAlign property to "right", but that only changes the text alignment of the label. How can I change the position of the label?
<Form.Item
name={"isPickup"}
label={t("booking.field.isPickup")}
colon={false}
valuePropName="checked"
>
<Switch />
</Form.Item>
2
Answers
To display the label to the right of the input field, you can use the labelCol and wrapperCol properties to adjust the columns. This also includes the
style
attribute, where you can set the CSS propertyorder: 2
to thelabelCol
to change the order in the flex row that theForm.Item
creates.For example:
To display the label of an Antd Form.Item to the right of the input field, you can make use of the Antd Grid system.