diff --git a/components/divider/index.tsx b/components/divider/index.tsx index a76ddcadbc..532f527afb 100644 --- a/components/divider/index.tsx +++ b/components/divider/index.tsx @@ -14,7 +14,7 @@ export interface DividerProps { const Divider: React.FC = props => ( - {({ getPrefixCls }: ConfigConsumerProps) => { + {({ getPrefixCls, direction }: ConfigConsumerProps) => { const { prefixCls: customizePrefixCls, type = 'horizontal', @@ -29,6 +29,7 @@ const Divider: React.FC = props => ( const classString = classNames(className, prefixCls, `${prefixCls}-${type}`, { [`${prefixCls}-with-text${orientationPrefix}`]: children, [`${prefixCls}-dashed`]: !!dashed, + [`${prefixCls}-rtl`]: direction === 'rtl', }); return (
diff --git a/components/divider/style/index.less b/components/divider/style/index.less index f37d6df604..f3e2a7618d 100644 --- a/components/divider/style/index.less +++ b/components/divider/style/index.less @@ -107,3 +107,5 @@ border-width: 0 0 0 1px; } } + +@import './rtl'; diff --git a/components/divider/style/rtl.less b/components/divider/style/rtl.less new file mode 100644 index 0000000000..12bc057105 --- /dev/null +++ b/components/divider/style/rtl.less @@ -0,0 +1,36 @@ +@import '../../style/themes/index'; +@import '../../style/mixins/index'; + +@divider-prefix-cls: ~'@{ant-prefix}-divider'; + +.@{divider-prefix-cls} { + &-rtl { + direction: rtl; + } + + &-horizontal&-with-text-left { + &::before { + .@{divider-prefix-cls}-rtl& { + width: 95%; + } + } + &::after { + .@{divider-prefix-cls}-rtl& { + width: 5%; + } + } + } + + &-horizontal&-with-text-right { + &::before { + .@{divider-prefix-cls}-rtl& { + width: 5%; + } + } + &::after { + .@{divider-prefix-cls}-rtl& { + width: 95%; + } + } + } +}