JGuang

Splitter

Splitter · Ant Design

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

Splitter

Resizable split panel layout

When To Use

Can be used to separate areas horizontally or vertically. When you need to freely drag and adjust the size of each area. When you need to specify the maximum and minimum width and height of an area.

Examples

  • Basic · size
  • Control mode · control
  • Vertical · vertical
  • Collapsible · collapsible
  • Control collapsible icons · collapsibleIcon
  • Multiple panels · multiple
  • Complex combination · group
  • Lazy · lazy
  • Customize · customize
  • Custom semantic dom styling · style-class
  • Double-clicked reset · reset

API

Common props ref:Common props

The Splitter component needs to calculate the panel size through its child elements, so its child elements only support Splitter.Panel.

Splitter

PropertyDescriptionTypeDefaultVersionGlobal Config
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-6.0.06.0.0
collapsiblemotion to enable collapse animation, icon to customize collapse icons{ motion?: boolean; icon?: { start?: ReactNode; end?: ReactNode } }-6.4.0×
collapsibleIconcustom collapsible icon{start?: ReactNode; end?: ReactNode}-6.0.0×
destroyOnHiddenDestroy panel content when collapsed (size is 0). Applies to all panels, can be overridden per panelbooleanfalse6.4.0×
draggerIconcustom dragger iconReactNode-6.0.0×
layoutLayout directionhorizontal | verticalhorizontal-×
lazyLazy modebooleanfalse5.23.0×
onCollapseCallback when expanding or collapsing(collapsed: boolean[], sizes: number[]) => void-5.28.0×
orientationOrientation directionhorizontal | verticalhorizontal6.0.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.06.0.0
verticalOrientation. Simultaneously existing with orientation, orientation takes prioritybooleanfalse6.0.0×
onDraggerDoubleClickCallback triggered when the dragger is double-clicked(index: number) => void-6.3.0×
onResizePanel size change callback(sizes: number[]) => void--×
onResizeEndDrag end callback(sizes: number[]) => void--×
onResizeStartCallback before dragging starts(sizes: number[]) => void--×

Panel

PropertyDescriptionTypeDefaultVersion
collapsibleQuick foldingboolean | { start?: boolean; end?: boolean; showCollapsibleIcon?: boolean | 'auto' }falseshowCollapsibleIcon: 5.27.0
defaultSizeInitial panel size support number for px or 'percent%' usagenumber | string--
destroyOnHiddenDestroy panel content when collapsed (size is 0). Overrides Splitter's destroyOnHiddenboolean-6.4.0
maxMaximum threshold support number for px or 'percent%' usagenumber | string--
minMinimum threshold support number for px or 'percent%' usagenumber | string--
resizableWhether to enable drag and dropbooleantrue-
sizeControlled panel size support number for px or 'percent%' usagenumber | string--

Semantic DOM

Semantic nodeNative descriptionVersion
rootRoot element with flex layout, width and height, alignment and stretch styles6.0.0
panelPanel element with flex basis, grow ratio and panel container styles6.0.0
draggerDrag control element with absolute positioning, user selection, z-index, center alignment, background color, hover and active states styles6.0.0

Semantic description source: vendor/components/splitter/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
resizeSpinnerSizenumberDrag and drop the identity element size
splitBarDraggableSizenumberDrag and drop the identity element size
splitBarSizenumberDrag the element display size
splitTriggerSizenumberDrag and drop trigger area size

Declaration source: vendor/components/splitter/style/index.ts

import type { CSSObject } from '@ant-design/cssinjs';

import { genFocusOutline, resetComponent } from '../../style';

import { genNoMotionStyle } from '../../style/motion';

import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';

import { genStyleHooks } from '../../theme/internal';

import { genCssVar } from '../../theme/util/genStyleUtils';

export interface ComponentToken {
  /**
   * @desc 拖拽标识元素大小
   * @descEN Drag and drop the identity element size
   * @deprecated Please use `splitBarDraggableSize` instead.
   */
  resizeSpinnerSize: number;
  /**
   * @desc 拖拽标识元素大小
   * @descEN Drag and drop the identity element size
   */
  splitBarDraggableSize: number;
  /**
   * @desc 拖拽元素显示大小
   * @descEN Drag the element display size
   */
  splitBarSize: number;
  /**
   * @desc 拖拽触发区域大小
   * @descEN Drag and drop trigger area size
   */
  splitTriggerSize: number;
}

interface SplitterToken extends FullToken<'Splitter'> {}

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/splitter/SplitBar.tsx
  • vendor/components/splitter/Splitter.tsx
  • vendor/components/splitter/hooks/sizeUtil.ts
  • vendor/components/splitter/hooks/useItems.ts
  • vendor/components/splitter/hooks/useResizable.ts
  • vendor/components/splitter/index.tsx
  • vendor/components/splitter/interface.ts
  • vendor/components/splitter/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.