mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
0e591ef01c
User can align the text to the left or right with "orientation" prop, if not set it will be centered.
35 lines
954 B
TypeScript
35 lines
954 B
TypeScript
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
|
|
export interface DividerProps {
|
|
prefixCls?: string;
|
|
type?: 'horizontal' | 'vertical';
|
|
orientation?: 'left' | 'right';
|
|
className?: string;
|
|
children?: React.ReactNode;
|
|
dashed?: boolean;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
export default function Divider({
|
|
prefixCls = 'ant',
|
|
type = 'horizontal',
|
|
orientation = '',
|
|
className,
|
|
children,
|
|
dashed,
|
|
...restProps,
|
|
}: DividerProps) {
|
|
const orientationPrefix = (orientation.length > 0) ? '-' + orientation : orientation;
|
|
const classString = classNames(
|
|
className, `${prefixCls}-divider`, `${prefixCls}-divider-${type}`, {
|
|
[`${prefixCls}-divider-with-text${orientationPrefix}`]: children,
|
|
[`${prefixCls}-divider-dashed`]: !!dashed,
|
|
});
|
|
return (
|
|
<div className={classString} {...restProps}>
|
|
{children && <span className={`${prefixCls}-divider-inner-text`}>{children}</span>}
|
|
</div>
|
|
);
|
|
}
|