Divider
A divider line separates different content.
When To Use
- Divide sections of an article.
- Divide inline text and links such as the operation column of table.
Examples
-
Horizontal ·
horizontal -
Divider with title ·
with-text -
Set the spacing size of the divider ·
size -
Text without heading style ·
plain -
Vertical ·
vertical -
Variant ·
variant -
Custom semantic dom styling ·
style-class
API
Common props ref:Common props
| Property | Description | Type | Default | Version | Global Config |
|---|---|---|---|---|---|
| children | The wrapped title | ReactNode | - | × | |
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> | - | 6.0.0 | |
| dashed | Whether line is dashed | boolean | false | × | |
| orientation | Whether line is horizontal or vertical | horizontal | vertical | horizontal | - | × |
The margin-left/right between the title and its closest border, while the titlePlacement should not be center, If a numeric value of type string is provided without a unit, it is assumed to be in pixels (px) by default. | string | number | - | × | ||
| plain | Divider text show as plain style | boolean | false | 4.2.0 | × |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> | - | 6.0.0 | |
| size | The size of divider. Only valid for horizontal layout | small | medium | large | - | 5.25.0 | × |
| titlePlacement | The position of title inside divider | start | end | center | center | - | × |
| The direction type of divider | horizontal | vertical | horizontal | - | × | |
| variant | Whether line is dashed, dotted or solid | dashed | dotted | solid | solid | 5.20.0 | × |
| vertical | Orientation, Simultaneously configure with orientation and prioritize orientation | boolean | false | - | × |
Semantic DOM
| Semantic node | Native description | Version |
|---|---|---|
root | Root element with border-top style, divider styling and other basic divider container styles | — |
rail | Background rail element with border-top style and other divider connection line styles | — |
content | Content element with inline-block display, padding and other divider text content styles | — |
Semantic description source: vendor/components/divider/demo/_semantic.tsx
Design Token
Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.
| Token | Type | Native description |
|---|---|---|
textPaddingInline | CSSProperties['paddingInline'] | Horizontal padding of text |
orientationMargin? | number | Distance between text and edge, which should be a number between 0 and 1. |
verticalMarginInline | CSSProperties['marginInline'] | Horizontal margin of vertical Divider |
Declaration source: vendor/components/divider/style/index.ts
import type { CSSProperties } from 'react';
import type { CSSObject } from '@ant-design/cssinjs';
import { unit } from '@ant-design/cssinjs';
import { resetComponent } from '../../style';
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
import { genStyleHooks, mergeToken } from '../../theme/internal';
/** Component only token. Which will handle additional calculation of alias token */
export interface ComponentToken {
/**
* @desc 文本横向内间距
* @descEN Horizontal padding of text
*/
textPaddingInline: CSSProperties['paddingInline'];
/**
* @desc 文本与边缘距离,取值 0 ~ 1
* @descEN Distance between text and edge, which should be a number between 0 and 1.
*/
orientationMargin?: number;
/**
* @desc 纵向分割线的横向外间距
* @descEN Horizontal margin of vertical Divider
*/
verticalMarginInline: CSSProperties['marginInline'];
}
/**
* @desc Divider 组件的 Token
* @descEN Token for Divider component
*/
interface DividerToken extends FullToken<'Divider'> {
/**
* @desc 尺寸边距
* @descEN Size padding edge horizontal
*/
sizePaddingEdgeHorizontal: number | string;
/**
* @desc 带文本的水平分割线的外边距
* @descEN Horizontal margin of divider with text
*/
dividerHorizontalWithTextGutterMargin: number | string;
}
Shared native props
Tips: The following generic properties apply to most antd components; those not supported are described separately.
| Property | Description | Type | Default |
|---|---|---|---|
| style | The additional style | CSSProperties | - |
| className | The additional css class | string | - |
| rootClassName | ClassName on the root element | string | - |
| autoFocus | Auto focus when component mounted, only effective for focusable elements like forms, links, etc. | boolean | false |
Install and reproduce an example
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23
Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.
Native type references
The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.
vendor/components/divider/index.tsxvendor/components/divider/style/index.ts
Source and license
https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd
Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.