--- order: 2 title: zh-CN: 方向 en-US: Direction --- ## zh-CN 这里列出了支持 `rtl` 方向的组件,您可以在演示中切换方向。 ## en-US Components which support rtl direction are listed here, you can toggle the direction in the demo. ```jsx import React, { useState } from 'react'; import { Input, Col, Row, Select, InputNumber, ConfigProvider, Cascader, Radio, Switch, Tree, TreeSelect, Modal, Button, Pagination, Steps, Rate, Badge, Divider, } from 'antd'; import { SearchOutlined as SearchIcon, SmileOutlined, DownloadOutlined, LeftOutlined, RightOutlined, MinusOutlined, PlusOutlined, } from '@ant-design/icons'; const InputGroup = Input.Group; const ButtonGroup = Button.Group; const { Option } = Select; const { TreeNode } = Tree; const { Search } = Input; const { Step } = Steps; const cascaderOptions = [ { value: 'tehran', label: 'تهران', children: [ { value: 'tehran-c', label: 'تهران', children: [ { value: 'saadat-abad', label: 'سعادت آیاد', }, ], }, ], }, { value: 'ardabil', label: 'اردبیل', children: [ { value: 'ardabil-c', label: 'اردبیل', children: [ { value: 'primadar', label: 'پیرمادر', }, ], }, ], }, { value: 'gilan', label: 'گیلان', children: [ { value: 'rasht', label: 'رشت', children: [ { value: 'district-3', label: 'منطقه ۳', }, ], }, ], }, ]; function Page(props) { const [state, setState] = useState({ currentStep: 0, modalVisible: false, badgeCount: 5, showBadge: true, }); const selectBefore = ( ); const selectAfter = ( ); // ==== Cascader ==== const cascaderFilter = (inputValue, path) => path.some(option => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1); const onCascaderChange = value => { console.log(value); }; // ==== End Cascader ==== // ==== Modal ==== const showModal = () => { setState({ ...state, modalVisible: true, }); }; const handleOk = e => { console.log(e); setState({ ...state, modalVisible: false, }); }; const handleCancel = e => { console.log(e); setState({ ...state, modalVisible: false, }); }; // ==== End Modal ==== const onStepsChange = currentStep => { console.log('onChange:', currentStep); setState({ ...state, currentStep, }); }; // ==== Badge ==== const increaseBadge = () => { const badgeCount = state.badgeCount + 1; setState({ ...state, badgeCount, }); }; const declineBadge = () => { let badgeCount = state.badgeCount - 1; if (badgeCount < 0) { badgeCount = 0; } setState({ ...state, badgeCount, }); }; const onChangeBadge = showBadge => { setState({ ...state, showBadge, }); }; return (
Cascader example } options={cascaderOptions} onChange={onCascaderChange} placeholder="یک مورد انتخاب کنید" popupPlacement={props.popupPlacement} />      With search: } options={cascaderOptions} onChange={onCascaderChange} placeholder="Select an item" popupPlacement={props.popupPlacement} showSearch={cascaderFilter} />
Switch example          Radio Group example تهران اصفهان فارس خوزستان
Button example

Tree example sss} key="0-0-1-0" />

Input (Input Group) example





Select example TreeSelect example
sss} key="random3" />

Modal example

نگاشته‌های خود را اینجا قراردهید

نگاشته‌های خود را اینجا قراردهید

نگاشته‌های خود را اینجا قراردهید


Steps example


Rate example

* Note: Half star not implemented in RTL direction, it will be supported after rc-rate{' '} implement rtl support.
Badge example


Pagination example
Grid System example

* Note: Every calculation in RTL grid system is from right side (offset, push, etc.)

col-8 col-8 col-6 col-offset-6 col-6 col-offset-6 col-12 col-offset-6 col-18 col-push-6 col-6 col-pull-18
); } export default () => { const [direction, setDirection] = useState('ltr'); const [popupPlacement, setPopupPlacement] = useState('bottomLeft'); const changeDirection = e => { const directionValue = e.target.value; setDirection(directionValue); if (directionValue === 'rtl') { setPopupPlacement('bottomRight'); } else { setPopupPlacement('bottomLeft'); } }; return ( <>
Change direction of components: LTR RTL
); }; ``` ```css .button-demo .ant-btn, .button-demo .ant-btn-group { margin-right: 8px; margin-bottom: 12px; } .button-demo .ant-btn-group > .ant-btn, .button-demo .ant-btn-group > span > .ant-btn { margin-right: 0; margin-left: 0; } .head-example { display: inline-block; width: 42px; height: 42px; vertical-align: middle; background: #eee; border-radius: 4px; } .ant-badge:not(.ant-badge-not-a-wrapper) { margin-right: 20px; } .ant-badge-rtl:not(.ant-badge-not-a-wrapper) { margin-right: 0; margin-left: 20px; } ```