JGuang

Divider

Divider · Ant Design

Preview
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

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

PropertyDescriptionTypeDefaultVersionGlobal Config
childrenThe wrapped titleReactNode-×
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-6.0.0
dashedWhether line is dashedbooleanfalse×
orientationWhether line is horizontal or verticalhorizontal | verticalhorizontal-×
orientationMarginThe 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-×
plainDivider text show as plain stylebooleanfalse4.2.0×
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-6.0.0
sizeThe size of divider. Only valid for horizontal layoutsmall | medium | large-5.25.0×
titlePlacementThe position of title inside dividerstart | end | centercenter-×
typeThe direction type of dividerhorizontal | verticalhorizontal-×
variantWhether line is dashed, dotted or soliddashed | dotted | solidsolid5.20.0×
verticalOrientation, Simultaneously configure with orientation and prioritize orientationbooleanfalse-×

Semantic DOM

Semantic nodeNative descriptionVersion
rootRoot element with border-top style, divider styling and other basic divider container styles—
railBackground rail element with border-top style and other divider connection line styles—
contentContent 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.

TokenTypeNative description
textPaddingInlineCSSProperties['paddingInline']Horizontal padding of text
orientationMargin?numberDistance between text and edge, which should be a number between 0 and 1.
verticalMarginInlineCSSProperties['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.

PropertyDescriptionTypeDefault
styleThe additional styleCSSProperties-
classNameThe additional css classstring-
rootClassNameClassName on the root elementstring-
autoFocusAuto focus when component mounted, only effective for focusable elements like forms, links, etc.booleanfalse

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.tsx
  • vendor/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.