Ant Design Svelte

Tabs

Related sections with keyboard, overflow, editing, snippets and saving panels.

When to use

Tabs switches related views in the same area. Line is suitable for page sections, card is for visually separated panels, editable-card is for adding and closing tabs. For the sequence of required steps, use Steps.

CSS Tabs Prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. Panels, navigation and more use the Tabs prefix. General slide animations and namespace themes are independent. Changing the name keeps the active tab and draft.

Keys and contents of panels

items contains stable string key, label signatures and children-snippets. defaultActiveKey specifies the initial selection; bind:activeKey synchronizes it with the application. disabled prevents the activation of a specific header.

Problem Setting Example
Switch related views items, bind:activeKey Main scenario
Place headers on side tabPlacement Location
Open many tabs overflow and scrolling Long panel
Create and close panels type="editable-card", onEdit Editable Tabs
Save or delete content destroyOnHidden, forceRender Life cycle

onChange reports the new active key. onTabClick receives key and MouseEvent; Cancellation via preventDefault allows you to prohibit the transition, for example, with an unconfirmed draft. Do not change the key along with the signature: the key determines the identity of the panel.

Life cycle and editing

By default, the panel is created on the first visit and saved after hiding. forceRender creates it in advance. destroyOnHidden removes hidden content; the setting of an individual item takes precedence over the general one, including false.

Removing resets local state and uncontrolled fields. For a draft that needs to survive being closed or unmounted, store the data in the application. animated can include indicator and panels separately; The presence of animation does not replace data management.

onEdit only communicates the add/remove intent. The application updates items, generates a unique key and selects the adjacent available activeKey after deletion. Closable:false protects the tab; hideAdd hides the add button. Your own way of adding shows the external button without changing the items contract.

Title bar and overflow

tabPlacement uses top/bottom/start/end and takes into account RTL. indicator changes the size and alignment of the bar; tabBarGutter - distance between headings. tabBarExtraContent adds edge actions, and renderTabBar allows you to wrap the standard navigation.

If there is not enough width, the headings scroll and the more menu may appear. On a mobile device, the library can only leave native scroll. more.popupRender gets the original menu-snippet, restTabs and onClose: search tab extends this menu, preserving ARIA links and keyboard. The current more control uses visible/onVisibleChange.

Without more.openClassName open more gets the current Tabs prefix + -dropdown-open. By default, transitionName uses the provider's common prefix + -slide-up; an empty line disables CSS motion. Non-empty more.animation overrides transitionName with the current name Tabs prefix + -dropdown- + animation; empty animation doesn't override it.

When making your own panel or rearranging, save all received attributes and measurement attachments. Order example uses native HTML5 drag for desktop and separate buttons; React DnD Kit touch sensors are not included.

Availability and design

Arrows move focus, Enter or Space activate the selected title. Manual activation allows you to view titles without launching each panel. Set an accessible tablist name via aria-label or aria-labelledby; locale separately translates the add and delete buttons and the list of hidden tabs.

ConfigProvider.tabs sets general defaults and semantic design. styles accepts CSS strings and objects. The style of root takes precedence over styles.root, tabBarStyle over styles.header. Tabs design tokens are applied via theme.components.Tabs. Slots, item settings and advanced more parameters are listed in the API.

Examples

General information about the project.

Basic tabs

The tab links the header to the tabpanel. Arrows move focus, Enter and Space activate the selected tab.

General information about the project.

Inaccessible tab

disabled excludes the tab from selection and keyboard bypass. The example allows you to change the availability of settings.

General information about the project.

Center

centered centers a horizontal list of titles as long as there is enough free space.

General information about the project.

Heading icons

icon accepts Snippet. SVGs are decorative, the available tab name remains text.

General information about the project.

Indicator size and position

indicator.size takes a number or function of the header size; align uses Boolean start/center/end.

Section selected: section-1

No scrolling yet

Many tabs

Tab labels scroll and overflow into the More menu. more.prefixCls sets the popup prefix, and more.overlayClassName retains the standard styles. onTabScroll reports the scroll direction.

General information about the project.

No action

Actions next to tabs

tabBarExtraContent accepts a Snippet or a left/right pair. Actions are not tabs and have their own handlers.

General information about the project.

Tabs sizes

Local size takes precedence over the gallery setting. medium means regular size.

General information about the project.

Location and RTL

tabPlacement specifies top/bottom/start/end. The logical sides are reflected along with the direction of the interface.

General information about the project.

Card tabs

type=card is suitable for individual views. The style of the panel is set via semantic content, and the environment belongs to the example.

Open: 2; active: overview

Adding and closing

onEdit requests the application to change items. The example selects the adjacent tab when deleting the active one and protects the “Browse” via closable=false.

Open: main

Your own way of adding

hideAdd removes the standard plus. The outer button updates items and activeKey, closing remains the standard onEdit.

Contents of the first section.

Own panel shell

renderTabBar gets allowed props and DefaultTabBar. The example preserves the original navigation and adds styling to it.

Первая → Вторая → Третья

Tab order

Native desktop drag and drop uses renderTabBar and native attributes. Buttons move the active tab from the keyboard; DnD Kit animations do not play.

General information about the project.

Semantic styles and ConfigProvider

Global tabs configuration is created by root; the local styles function complements the header and panels. The provider and component classes are preserved.

General information about the project.

Component tokens

Local theme changes the header spacing and color of the selected tab. The numeric control updates the horizontalItemGutter.

Saving and deleting panels

By default, a visited panel remains in the DOM and retains an uncontrolled field. destroyOnHidden removes it; after returning, a new field is created.

General information about the project.

Panel animation

animated controls the indicator and panels separately. Panel animation is enabled at the user's discretion; reduced motion is taken into account by the library.

General information about the project.

No events

Events and transition cancellation

onTabClick reports a selection attempt, onChange reports a change in the active key. preventDefault in onTabClick leaves the current tab.

General information about the project.

RTL and logic sides

direction changes the tab direction and keyboard navigation order. tabPlacement="start" places the tabs at the logical start.

Enable reset to compare behavior: unsaved changes to a hidden panel will be lost.

Tabs in the card

Tabs maintain the natural Tab order within the window.

Member Profile

Saved review example: profile drafts, settings, history and tabs inside Modal.

General: suite; local: project-tabs

Panels, navigation and More use the Tabs prefix. General slide animations and namespace themes are independent. Changing the name keeps the active tab and draft.

CSS prefixes Tabs

Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.

API

Examples are checked against the current ant.design page and the public API of the installed package. Full definitions of Props are in @woodger/antd.

Topics of official examples
ThemeExample or limitation
BasicRelated tab and tabpanel, keyboard.
DisabledDynamic availability.
CenteredCentering.
IconDecorative icon-snippets.
IndicatorSize and logical alignment.
SlideScrolling, more and onTabScroll.
Extra contentIndependent actions left/right.
SizeComponent size.
PlacementLogical sides and RTL.
Custom Popup SearchSearch restTabs and go to match; the original list is retained in its entirety; in-place list filtering is not shown.
Card type tabCards and panel design.
Add & close tabChanging items via onEdit.
Customized trigger of new tabExternal button and hideAdd.
Customized bar of tabDefaultTabBar in its shell.
Draggable TabsPublic wrapper and native desktop drag and drop instead of React DnD Kit; buttons provide keyboard control.
Custom semantic dom stylingConfigProvider.tabs and local styles.
Main parameters Tabs
PropertyDescriptionTypeDefault
prefixClsFull CSS prefix of the component and its parts. A non-empty local prop takes precedence; empty string and undefined inherit ConfigProvider. The namespace of the topic is set separately.stringConfigProvider.prefixCls + "-tabs"
directionDirection of the tabs and keyboard navigation. The local value takes precedence over the provider."ltr" | "rtl"From ConfigProvider
itemsKeyed headers and panels. children and icon are passed to Snippet.readonly TabsItem[][]
activeKeybind:activeKey binds the selected key to the application.string | undefinedFirst available item
defaultActiveKeyRead when created, does not reinitialize state after change.stringFirst available item
typeTabs view; editable-card adds onEdit requests.'line' | 'card' | 'editable-card'line
onChangeEffective change of the active key.(key: string) => void—
onTabClickAttempting to activate. preventDefault cancels selections, including from the keyboard.(key: string, event: MouseEvent) => void—
onEditApplication changes items; add receives the event, remove receives the key.(target: MouseEvent | KeyboardEvent | string, action: 'add' | 'remove') => void—
hideAddRemoves the standard add button to editable-card.booleanfalse
tabPlacementLogical sides are reflected in RTL.'top' | 'bottom' | 'start' | 'end'top
sizemedium indicates regular size.'small' | 'medium' | 'large'From ConfigProvider
centeredCenters horizontal headings when there is sufficient space.booleanfalse
indicatorNumeric/functional size and logical align.TabsIndicator—
tabBarGutterHeading spacing in px.numberFrom topic
tabBarExtraContentContent next to the list of titles.TabsContent | { left?, right? }—
tabBarStyleCSS title bars; overrides styles.header.CSSStyle—
animatedThe indicator and panels are configured separately.boolean | TabsAnimatedConfiginkBar: true, tabPane: false
destroyOnHiddenRemoves hidden panels; item may override the setting.booleanfalse
moreThe More menu supports prefixCls, popupRender, visible, and onVisibleChange.TabsMorePropstrigger: hover
renderTabBarUser panel. DefaultTabBar supports children-wrapper with original attributes.Snippet<[TabsTabBarProps, TabsDefaultTabBar]>—
onTabScrollPhysical direction of native scroll headers.(info: TabsScrollInfo) => void—
localeAvailable names add/remove and listbox; the tablist name is given by aria-label.TabsLocaleAdd tab / remove / expanded dropdown
classNamesSemantic classes object or function.TabsSemantic—
stylesCSS strings and objects for tab parts. The root style takes precedence over styles.root.TabsSemantic<CSSStyle>—
nativeElementbind:nativeElement returns the root after mount.HTMLDivElement—

Panel Options

TabsItem specifies the required key/label, children, icon, disabled, closable, closeIcon, forceRender and destroyOnHidden. className/style refers to the panel. children/icon - Snippet; label also accepts text and a number. forceRender creates the content without the first selection.

Semantic DOM

Headings form a tablist with native tab buttons. Panels have role:tabpanel and aria-controls/aria-labelledby connections. Arrows, Home and End move focus between available headings; Enter and Space activate the selected one. A hidden visited panel preserves the DOM and is excluded from the accessible tree via hidden/aria-hidden; it also gets inert for the duration of the output animation.

Semantic slots: root, header, item, remove, indicator, body, content, popup.root. content refers to the panel, item refers to the header. Functions receive normalized props: tabPlacement - physical side, size stores information about an explicitly specified size.

ConfigProvider.tabs defines common classes, styles, indicator, add/remove icons and more.icon. The remaining global more fields do not change trigger, as in the pinned 6.6.8; set them locally. The nested provider replaces the entire record tabs.

Registration tokens

Component tokens work through ConfigProvider theme.components.Tabs. The card changes the title spacing, selected color, and indicator; shared tokens inherit the partition theme.

Component tokens
TokenPurpose
cardBgCard header background.
cardGutterCard interval.
cardHeightRegular card height.
cardHeightLGLarge card height.
cardHeightSMLow card height.
cardPaddingNormal card indents.
cardPaddingLGLarge card indents.
cardPaddingSMSmall card indents.
horizontalItemGutterHorizontal header spacing.
horizontalItemMarginHorizontal margins of the header.
horizontalItemMarginRTLHorizontal margins in RTL.
horizontalItemPaddingHorizontal header indents.
horizontalItemPaddingLGLarge header indents.
horizontalItemPaddingSMSmall header indents.
horizontalMarginTitle bar indent.
inkBarColorIndicator color.
itemActiveColorColor when pressed.
itemColorNormal title color.
itemHoverColorHover color.
itemSelectedColorColor of the selected title.
titleFontSizeRegular font size.
titleFontSizeLGLarge font.
titleFontSizeSMSmall font.
verticalItemMarginVertical margins.
verticalItemPaddingVertical header indents.
zIndexPopupOverflow menu layer.
Common tokens of the current topic
TokenCurrent value
colorBgContainer#ffffff
colorBorder#d9d9d9
colorBorderSecondary#f0f0f0
colorIconrgba(0,0,0,0.45)
colorPrimaryBorder#adc6ff
colorTextrgba(0,0,0,0.88)
colorTextDisabledrgba(0,0,0,0.25)
colorTextHeadingrgba(0,0,0,0.88)
borderRadius6
borderRadiusLG8
boxShadowSecondary 0 6px 16px 0 rgba(0,0,0,0.08), 0 3px 6px -4px rgba(0,0,0,0.12), 0 9px 28px 8px rgba(0,0,0,0.05)
controlHeight32
controlHeightLG40
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
lineHeightLG1.5
lineTypesolid
lineWidth1
lineWidthBold2
lineWidthFocus3
margin16
marginSM12
marginXS8
marginXXS4
motionDurationMid0.2s
motionDurationSlow0.3s
motionEaseInOutcubic-bezier(0.645, 0.045, 0.355, 1)
motionEaseInQuintcubic-bezier(0.755, 0.05, 0.855, 0.06)
motionEaseOutQuintcubic-bezier(0.23, 1, 0.32, 1)
paddingLG24
paddingSM12
paddingXXS4

FAQ

Why doesn't the arrow switch the panel?

Manual activation is used. After moving focus, press Enter or Space.

How to save a draft?

The visited panel is saved when destroyOnHidden:false. For DOM independence, store data in application state.

Who adds and closes tabs?

The application processes onEdit and updates items/activeKey. Use stable keys.

Why save the original menu in popupRender?

It contains keyboard logic and ARIA connections. Snippet can be supplemented with search, as in the example, without cloning the React element.

How to transfer a draggable example?

Save node, item and all attributes of the standard renderer. The local example extends desktop drag with rearrangement buttons.

Why is more not visible on the phone?

Mobile mode can hide the button while keeping scrolling titles.