logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
YouMindTRACTIANLobeHubCodeRabbit
6.4.5
  • Components Overview
  • Changelog
    v6.4.5
  • General
    • Button
    • FloatButton
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
    • Grid
    • Layout
    • Masonry
      6.0.0
    • Space
    • Splitter
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
      DEPRECATED
    • Popover
    • QRCode
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • App
    • BorderBeam
      6.4.0
    • ConfigProvider
    • Util
Examples
Basic
Disabled
Centered
Icon
Indicator
Slide
Extra content
Size
Placement
Card type tab
Add & close tab
Customized trigger of new tab
Customized bar of tab
Draggable Tabs
Custom semantic dom styling
API
Tabs
TabItemType
MoreProps
Semantic DOM
Design Token

Tabs

Tabs make it easy to explore and switch between different views.
Importimport { Tabs } from 'antd';
GitHub
components/tabsIssueOpen issues
Docs
Edit this pageLLMs.md
StepsAutoComplete

Resources

Ant Design X
Ant Design Charts
Ant Design Pro
Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Web3
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
X
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
For Agents
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
WeaveFox logoWeaveFox-AI Development with WeaveFox 🦊
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

When To Use

Ant Design has 3 types of Tabs for different situations.

  • Card Tabs: for managing too many closeable views.
  • Normal Tabs: for functional aspects of a page.
  • Radio.Button: for secondary tabs.

Examples

API

Common props ref:Common props

Tabs

PropertyDescriptionTypeDefaultVersionGlobal Config
activeKeyCurrent TabPane's keystring-×
addIconCustomize add icon, only works with type="editable-card"ReactNode<PlusOutlined />4.4.05.14.0
animatedWhether to change tabs with animation.boolean | { inkBar: boolean, tabPane: boolean }{ inkBar: true, tabPane: false }×
centeredCenters tabsbooleanfalse4.4.0×
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-6.0.0
defaultActiveKeyInitial active TabPane's key, if activeKey is not setstringThe key of first tab×
hideAddHide plus icon or not. Only works while type="editable-card"booleanfalse×
indicatorCustomize size and align of indicator{ size?: number | (origin: number) => number; align: start | center | end; }-5.13.05.13.0
itemsConfigure tab contentTabItemType[]4.23.0×
moreCustomize the collapse menuMoreProps{ icon: <EllipsisOutlined /> , trigger: 'hover' }5.17.0
removeIconThe custom icon of remove, only works with type="editable-card"ReactNode<CloseOutlined />5.15.05.15.0
popupClassNameclassName for more dropdown, please use classNames.popup insteadstring-4.21.0×
renderTabBarReplace the TabBar(props: DefaultTabBarProps, DefaultTabBar: React.ComponentClass) => React.ReactElement-×
sizePreset tab bar sizelarge | medium | smallmedium×
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
tabBarExtraContentExtra content in tab barReactNode | {left?: ReactNode, right?: ReactNode}-object: 4.6.0×
tabBarGutterThe gap between tabsnumber-×
tabBarStyleTab bar style objectCSSProperties-×
tabPlacementPlacement of tabstop | end | bottom | starttop×
tabPositionPosition of tabstop | right | bottom | left, please use tabPlacement insteadtop×
destroyInactiveTabPaneWhether destroy inactive TabPane when change tab, use destroyOnHidden insteadbooleanfalse×
destroyOnHiddenWhether destroy inactive TabPane when change tabbooleanfalse5.25.0×
typeBasic style of tabsline | card | editable-cardline×
onChangeCallback executed when active tab is changed(activeKey: string) => void-×
onEditCallback executed when tab is added or removed. Only works while type="editable-card"(action === 'add' ? event : targetKey, action) => void-×
onTabClickCallback executed when tab is clicked(key: string, event: MouseEvent) => void-×
onTabScrollTrigger when tab scroll({ direction: left | right | top | bottom }) => void-4.3.0×

More option at @rc-component/tabs

TabItemType

PropertyDescriptionTypeDefaultVersion
closeIconCustomize close icon in TabPane's head. Only works while type="editable-card". 5.7.0: close button will be hidden when setting to null or falseReactNode-
destroyInactiveTabPaneWhether destroy inactive TabPane when change tab, use destroyOnHidden insteadbooleanfalse5.11.0
destroyOnHiddenWhether destroy inactive TabPane when change tabbooleanfalse5.25.0
disabledSet TabPane disabledbooleanfalse
forceRenderForced render of content in tabs, not lazy render after clicking on tabsbooleanfalse
keyTabPane's keystring-
labelTab header text elementReactNode-
iconTab header icon elementReactNode-5.12.0
childrenTab content elementReactNode-
closableWhether a close (x) button is visible, Only works while type="editable-card"booleantrue

MoreProps

PropertyDescriptionTypeDefaultVersion
iconThe custom iconReactNode-
DropdownProps

Semantic DOM

Design Token

Component TokenHow to use?
Token NameDescriptionTypeDefault Value
cardBgBackground color of card tabstringrgba(0,0,0,0.02)
cardGutterGutter of card tabnumber2
cardHeightHeight of card tabnumber40
cardHeightLGHeight of large card tabnumber48
cardHeightSMHeight of small card tabnumber32
cardPaddingPadding of card tabstring8px 16px
cardPaddingLGPadding of large card tabstring11px 16px
cardPaddingSMPadding of small card tabstring4px 8px
horizontalItemGutterHorizontal gutter of horizontal tabnumber32
horizontalItemMarginHorizontal margin of horizontal tab itemstring
horizontalItemMarginRTLHorizontal margin of horizontal tab item (RTL)string
horizontalItemPaddingHorizontal padding of horizontal tab itemstring12px 0
horizontalItemPaddingLGHorizontal padding of large horizontal tab itemstring16px 0
horizontalItemPaddingSMHorizontal padding of small horizontal tab itemstring8px 0
horizontalMarginHorizontal margin of horizontal tabstring0 0 16px 0
inkBarColorColor of indicatorstring#1677ff
itemActiveColorText color of active tabstring#0958d9
itemColorText color of tabstringrgba(0,0,0,0.88)
itemHoverColorText color of hover tabstring#4096ff
itemSelectedColorText color of selected tabstring#1677ff
titleFontSizeFont size of titlenumber14
titleFontSizeLGFont size of large titlenumber16
titleFontSizeSMFont size of small titlenumber14
verticalItemMarginVertical margin of vertical tab itemstring16px 0 0 0
verticalItemPaddingVertical padding of vertical tab itemstring8px 24px
zIndexPopupz-index of dropdown menunumber1050
Global TokenHow to use?
Token NameDescriptionTypeDefault Value
colorBgContainerContainer background color, e.g: default button, input box, etc. Be sure not to confuse this with `colorBgElevated`.string#ffffff
colorBorderDefault border color, used to separate different elements, such as: form separator, card separator, etc.string#d9d9d9
colorBorderSecondarySlightly lighter than the default border color, this color is the same as `colorSplit`. Solid color is used.string#f0f0f0
colorIconWeak action. Such as `allowClear` or Alert close buttonstringrgba(0,0,0,0.45)
colorPrimaryBorderThe stroke color under the main color gradient, used on the stroke of components such as Slider.string#91caff
colorTextDefault text color which comply with W3C standards, and this color is also the darkest neutral color.stringrgba(0,0,0,0.88)
colorTextDisabledControl the color of text in disabled state.stringrgba(0,0,0,0.25)
colorTextHeadingControl the font color of heading.stringrgba(0,0,0,0.88)
borderRadiusBorder radius of base componentsnumber6
borderRadiusLGLG size border radius, used in some large border radius components, such as Card, Modal and other components.number8
boxShadowSecondaryControl the secondary box shadow style of an element.string 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)
controlHeightThe height of the basic controls such as buttons and input boxes in Ant Designnumber32
controlHeightLGLG component heightnumber40
controlItemBgHoverControl the background color of control component item when hovering.stringrgba(0,0,0,0.04)
fontFamilyThe font family of Ant Design prioritizes the default interface font of the system, and provides a set of alternative font libraries that are suitable for screen display to maintain the readability and readability of the font under different platforms and browsers, reflecting the friendly, stable and professional characteristics.string-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'
fontSizeThe most widely used font size in the design system, from which the text gradient will be derived.number14
fontSizeSMSmall font sizenumber12
lineHeightLine height of text.number1.5714285714285714
lineHeightLGLine height of large text.number1.5
lineTypeBorder style of base componentsstringsolid
lineWidthBorder width of base componentsnumber1
lineWidthBoldThe default line width of the outline class components, such as Button, Input, Select, etc.number2
lineWidthFocusControl the width of the line when the component is in focus state.number3
marginControl the margin of an element, with a medium size.number16
marginSMControl the margin of an element, with a medium-small size.number12
marginXSControl the margin of an element, with a small size.number8
marginXXSControl the margin of an element, with the smallest size.number4
motionDurationMidMotion speed, medium speed. Used for medium element animation interaction.string0.2s
motionDurationSlowMotion speed, slow speed. Used for large element animation interaction.string0.3s
motionEaseInOutPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.645, 0.045, 0.355, 1)External Link Icon
motionEaseInQuintPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.755, 0.05, 0.855, 0.06)External Link Icon
motionEaseOutQuintPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.23, 1, 0.32, 1)External Link Icon
paddingLGControl the large padding of the element.number24
paddingSMControl the small padding of the element.number12
paddingXXSControl the extra extra small padding of the element.number4
Basic

Default activate first tab.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Disabled

Disabled a tab.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Centered

Centered tabs.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Icon

The Tab with Icon.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Indicator

Set indicator prop to custom indicator size and align.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Slide

In order to fit in more tabs, they can slide left and right (or up and down).

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Extra content

You can add extra actions to the right or left or even both side of Tabs.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Size

Large size tabs are usually used in page header, and small size could be used in Modal.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Placement

Tab's placement: start, end, top or bottom. Will auto switch to top in mobile.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Card type tab

Another type of Tabs, which doesn't support vertical mode.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Add & close tab

Only card type Tabs support adding & closable. +Use closable={false} to disable close.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Customized trigger of new tab

Hide default plus icon, and bind event for customized trigger.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Customized bar of tab

Use react-sticky-box and renderTabBar.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Draggable Tabs

Use dnd-kit to make tabs draggable.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom semantic dom styling

You can customize the semantic dom style of Tabs by passing objects/functions through classNames and styles.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
6.0.0
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
Tab 1
Tab 2
Tab 3
Tab 1
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
Tab 1
Tab 2
Tab 2
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
Tab-0
Tab-1
Tab-2
Tab-3
Tab-4
Tab-5
Tab-6
Tab-7
Tab-8
Tab-9
Tab-10
Tab-11
Tab-12
Tab-13
Tab-14
Tab-15
Tab-16
Tab-17
Tab-18
Tab-19
Tab-20
Tab-21
Tab-22
Tab-23
Tab-24
Tab-25
Tab-26
Tab-27
Tab-28
Tab-29
Content of tab 1
Tab 1
Tab 2
Tab 3
Content of tab 1



You can also specify its direction or both side


Tab 1
Tab 2
Tab 3
Content of tab 1
Tab 1
Tab 2
Tab 3
Content of tab 1
Card Tab 1
Card Tab 2
Card Tab 3
Content of card tab 1
Tab 1
Tab 2
Tab 3
Content of editable tab 1
Tab placement:
Tab 1
Tab 2
Tab 3
Content of Tab 1
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
Tab 1
Tab 2
Tab 3
Content of Tab 1
Tab 1
Tab 2
Content of Tab Pane 1
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
Tab-0
Tab-1
Tab-2
Tab-3
Tab-4
Tab-5
Tab-6
Tab-7
Tab-8
Tab-9
Tab-10
Tab-11
Tab-12
Tab-13
Tab-14
Tab-15
Tab-16
Tab-17
Tab-18
Tab-19
Tab-20
Tab-21
Tab-22
Tab-23
Tab-24
Tab-25
Tab-26
Tab-27
Tab-28
Tab-29
Content of tab 1
  • root
    Root element with basic tab container styles, layout and direction control
  • header
    Root element with basic tab container styles, layout and direction control
  • item
    Item element with relative positioning, padding, colors, text ellipsis, border-radius, transitions and other tab item styles and interactive effects
  • remove
    6.4.0
    Remove button element with editable tab close button size, color, hover state and other interactive feedback styles
  • indicator
    Indicator element with indicator bar color, position, dimensions, transitions and other active state indication styles
  • content
    Content element with tab content panel layout, padding and other content display styles
  • popup.root
    Popup menu element with dropdown absolute positioning, z-index, display control, max-height, scrolling and other styles