Ant Design Svelte

Splitter

Resizable panels: sizes, limits, collapsing and nested areas.

When to use

Splitter divides the work area into panels, the size of which can be changed by the user. It is suitable for editor, preview and details area. The container needs certain dimensions: the vertical composition must have an accessible height.

Declare panels with Splitter.Panel inside Splitter, or pass an items array with children snippets. The array takes precedence when supplied. Panel identity follows position.

Panel dimensions

size, defaultSize, min and max accept a number in px or a percentage string. The unspecified remainder is distributed among the panels. defaultSize is read at creation; further changes can be controlled via size.

Problem Setting Example
Split restricted area Splitter.Panel, min, max Two panels with restrictions
Store dimensions in app size, onResize Managed Dimensions
Split area from top to bottom orientation="vertical" Vertical division
Create multiple levels Nested Splitter Nested areas
Apply size after release lazy, onResizeEnd Delayed resizing

If at least one panel has size, the entire group becomes manageable. Accept the suggested numbers from the callback and update the sizes of the corresponding items. Keeping the same size allows you to reject the change; For external reset, percentage values ​​can be transferred again.

resizable=false prevents changes to the adjacent border, rather than hiding the panel. For drag, both adjacent panels must allow resize. orientation takes precedence over vertical.

Changing and collapsing

A regular drag reports onResizeStart, intermediate onResize and onResizeEnd. lazy shows the preliminary line and applies the result when completed; save sizes via onResizeEnd since the intermediate onResize is not called.

collapsible panel allows collapsing at start/end and sets the visibility of buttons. General collapsible.motion includes animation, icon changes icons. onCollapse reports an array of collapsed states and sizes after change events.

onDraggerDoubleClick gets the border index. Reset example itself restores the sizes in the application; callback does not automatically replace state.

destroyOnHidden defaults to false: if size is zero, the content is stored in the DOM. This preserves local state, but the hidden field may remain in Tab order - a limitation that is also reproduced in the benchmark. Example of hidden content uses true. Keep important values ​​outside the panel being deleted; The panel's local destroyOnHidden takes precedence over the global one.

Design and availability

classNames/styles support root, panel and dragger object or function from props. styles accepts CSS strings and objects. classNames.dragger.active is used during drag, styles.dragger.active is not used yet. Semantic example shows the current settings and ConfigProvider.splitter.

theme.components.Splitter applies splitBarSize, splitTriggerSize and splitBarDraggableSize to the border and capture area. Local styles refine the design. draggerIcon changes the icon, and null/false leaves an empty custom wrapper instead of the standard content.

The border has role=separator, orientation and percentage aria-valuenow/min/max. Drag supports mouse and touch; resizing with arrows has not yet been implemented. Collapse buttons are accessible from the keyboard. Their names are fixed in the current package; the override via aria-label custom icon from the 6.7 documentation has not been carried over.

bind:nativeElement returns the root div after mount. To change the composition of panels, take into account the positional identity of items and store editor data in the application state.

A non-empty local prefixCls changes the classes of root, panels, separator, collapse buttons, preview and mask. The empty string and undefined inherit ConfigProvider.prefixCls with the -splitter suffix, defaulting to ant-splitter. Semantic callbacks receive the initial local value of prefixCls. Example of prefixes contains nested areas with one local class, separate lazy preview and saving dimensions and editor.

The preview service variable uses a common prefix without dots: --suite-splitter-bar-preview-offset. The local class and theme.cssVar.prefix have no effect on it. CSS is isolated by class/namespace pair, so nested scopes don't read each other's offset. The CSS registration order dependence is not reproduced in the reference. Changing the prefix preserves the active drag, panels and their contents; destroyOnHidden continues to control the removal of collapsed content separately.

Splitter uses design tokens from the current theme for its appearance.

Examples

First panel
Second panel
Drag the separator

Two panels with restrictions

Splitter.Panel declares panels inside Splitter. Numbers specify pixels and percentage strings specify a share of the available space. min and max constrain dragging.

First panel
Second panel
50% / 50%

Controlled dimensions

If the size of at least one panel is specified, the application takes the dimensions in onResize. The prohibition of acceptance leaves the previous geometry.

First panel
Second panel

Vertical split

orientation="vertical" places panels from top to bottom. The ARIA orientation of the separator itself becomes horizontal.

First panel
Second panel
Panels open

Rolling up panels

collapsible includes buttons at the divider. onCollapse reports an array of states and suggested sizes.

First panel
Second panel

Visibility of minimize buttons

showCollapsibleIcon accepts true, false or auto. This is the visibility of the buttons, not the state of the panels.

First panel
Second panel
Third panel

Multiple panels

A separator appears between each pair of neighbors. resizable=false for the panel prohibits changing both adjacent borders.

First panel
Second panel
Third panel

Nested areas

The horizontal splitter is combined with the vertical splitter in the second panel. Each container manages its own dimensions.

First panel
Second panel
Dimensions have not been changed yet

Delayed resizing

lazy shows the preposition line. The geometry and onResizeEnd are updated when released; onResize is not called in this mode.

First panel
Second panel

Own icons

draggerIcon and collapsible.icon accept strings or snippets. The names of the buttons of the current package remain standard Toggle start/end panel.

First panel
Second panel

Semantic slots and provider

root, panel and dragger are designed separately. ConfigProvider.splitter sets the general style, local functions refine it.

First panel
Second panel
0

Double press reset

onDraggerDoubleClick reports the border index. The application returns the managed sizes to equal shares.

Second panel

Removing hidden content

destroyOnHidden removes a hidden field from the DOM and Tab order. When expanded, the uncontrolled field is recreated; store the application state externally.

Editor
Nested panel 1
Nested panel 2
General: suite; class: project-splitter; editor revealed; dimensions: After resize After resize

Both Splitter use the same local class in different areas. Deferred resize and its preview remain independent; the draft is stored outside the panel being deleted.

Local and general prefix

Nested areas with one class, independent lazy preview and saving dimensions and editor.

First panel

Drag the separator or collapse the panel with the arrow.

Second panel

Dimensions are limited to twenty percent of the area.

Change panel sizes

Project panels

Saved review example: changing direction, restrictions and the result of resizing.

API

Themes of the ant.design live page are mapped to the public API of the installed package. Full definitions of Props are in @woodger/antd.

Topics of official examples
ThemeExample or limitation
CSS prefixesGeneral and local prefix, nested areas and independent lazy preview.
BasicTwo panels with min/max.
Control modeAcceptance of dimensions by application.
VerticalVertical division.
CollapsibleButtons, motion and callbacks.
Control collapsible iconsauto/true/false.
Multiple panelsThree adjacent panels.
Complex combinationNested division.
LazyDimensions change upon release.
CustomizeOwn icons.
Custom semantic dom stylingConfigProvider and semantic slots.
Double-clicked resetControlled aspect ratio reset.
Basic parameters of Splitter
PropertyDescriptionTypeDefault
prefixClsFull local prefix of root, panels, separator and preview. The empty string and undefined inherit the same prefix. styles/classNames get the original local prefix; namespace preview depends on ConfigProvider.prefixCls.stringConfigProvider + -splitter
itemsArray of panels with text content or snippets. When provided, items takes precedence over nested Splitter.Panel declarations.SplitterPanelProps[][]
orientationPanel axis: horizontal or vertical.horizontal | verticalhorizontal
lazyDeferred resize until the pointer is released.booleanfalse
destroyOnHiddenDeleting the contents of a collapsed panel; The panel parameter takes precedence.booleanfalse
collapsibleAnimation of icons collapsing and snippets.motion/icon config—
draggerIconYour own icon; null/false create an empty wrapper.SplitterContentSpinner
onResizeStartStart of dragging, dimensions in px.(sizes: number[]) => void—
onResizeSuggested sizes for resize and collapse; the application accepts them for controlled size.(sizes: number[]) => void—
onResizeEndCompleting the change. lazy reports suggested sizes without onResize.(sizes: number[]) => void—
onCollapseAfter onResize/onResizeEnd when collapsing.(collapsed, sizes) => void—
onDraggerDoubleClickDouble click on the border, including resizable=false.(index: number) => void—
classNamesClasses root/panel/dragger, dragger has default/active.SplitterSemantic<SplitterClassSlots>—
stylesCSS strings and objects for root, panel, and dragger.default.SplitterSemantic<SplitterStyleSlots>—
nativeElementbind:nativeElement instead of React SplitterRef.HTMLDivElement—

Panel Options

size enables controlled mode for the entire group; defaultSize specifies the initial size. min/max limit the size. resizable by default true; both adjacent panels must allow modification. collapsible - boolean or start/end/showCollapsibleIcon object. destroyOnHidden overrides the group setting. class/style refers to the panel; the content is passed to children.

Semantic DOM

root contains panel and dragger between neighbors. Semantic classNames/styles are available via local props and ConfigProvider.splitter. dragger.default sets the normal style; classNames.dragger.active is applied during dragging, styles.dragger.active is not used in the installed implementation.

The border has role="separator", aria-orientation and percentage aria-valuenow/min/max. Drag and drop supports mouse and touch; There is no resizing using keyboard arrows yet. Collapse buttons are available on Tab, Enter and Space.

In the package version, the names of the buttons are fixed as Toggle start/end panel. The ability to override the name via aria-label custom icon introduced in React 6.7 has not been carried over.

Registration tokens

There are three component tokens in the table corresponding to ant.design. theme.components.Splitter is applied to the border and capture area sizes. Additional styling of root/panel/dragger is shown through semantic styles and ConfigProvider.splitter.

Component Splitter Tokens
TokenPurpose
splitBarDraggableSizeBorder capture area.
splitBarSizeSeparator thickness.
splitTriggerSizeCollapse button size.
Common tokens of the current topic
TokenCurrent value
colorFillrgba(0,0,0,0.15)
colorPrimary#2f54eb
colorPrimaryBorder#adc6ff
colorTextrgba(0,0,0,0.88)
borderRadiusXS2
controlHeightSM24
controlItemBgActive#f0f5ff
controlItemBgActiveHover#d6e4ff
controlItemBgHoverrgba(0,0,0,0.04)
fontFamily-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSize14
fontSizeSM12
lineHeight1.5714285714285714
lineWidthFocus3
motionDurationSlow0.3s
motionEaseInOutcubic-bezier(0.645, 0.045, 0.355, 1)
zIndexPopupBase1000

FAQ

Why doesn't controlled Splitter change sizes?

Accept the proposed values ​​in onResize, and if lazy - in onResizeEnd, and update the size of the panels.

How to set dimensions?

Numbers - px, percentage lines - container share. defaultSize specifies only the initial value.

Is it possible to hide the panel using resizable=false?

No, it prohibits resizing adjacent borders. Collapse is set to collapsible, content saving is set to destroyOnHidden.

What's with the focus in the hidden panel?

When the DOM is saved, the field can remain in Tab order. destroyOnHidden=true deletes the content and its local state; Store important data in the application.

How to save dimensions in lazy?

Via onResizeEnd. The preline does not resize the panels and does not call intermediate onResize.