跳转到内容

Tabs 标签页

何时使用

提供平级的区域将大块内容进行收纳和展现,保持界面整洁。

Ant Design 依次提供了三级选项卡,分别用于不同的场景。

  • 卡片式的页签,提供可关闭的样式,常用于容器顶部。
  • 既可用于容器顶部,也可用于容器内部,是最通用的 Tabs。
  • Radio.Button 可作为更次级的页签来使用。

代码演示

基本

loading

禁用

loading

居中

loading

图标

loading

指示条

loading

滑动

loading

附加内容

loading

大小

loading

位置

loading

API

Tabs

参数说明类型默认值版本
activeKey当前激活 tab 面板的 keystring-
addIcon自定义添加按钮,设置 type="editable-card" 时有效VNode<PlusOutlined />4.4.0
animated是否使用动画切换 Tabsboolean| { inkBar: boolean, tabPane: boolean }{ inkBar: true, tabPane: false }
centered标签居中展示booleanfalse4.4.0
defaultActiveKey初始化选中面板的 key,如果没有设置 activeKeystring第一个面板的 key
hideAdd是否隐藏加号图标,在 type="editable-card" 时有效booleanfalse
indicator自定义指示条的长度和对齐方式{ size?: number | (origin: number) => number; align: start|center|end; }-5.13.0
items配置选项卡内容TabItemType[]4.23.0
more自定义折叠菜单属性MoreProps{ icon: <EllipsisOutlined /> , trigger: 'hover' }
removeIcon自定义删除按钮,设置 type="editable-card" 时有效VNode<CloseOutlined />5.15.0
renderTabBar替换 TabBar,用于二次封装标签头(props: DefaultTabBarProps, DefaultTabBar: React.ComponentClass) => React.ReactElement-
size大小,提供 large middlesmall 三种大小stringmiddle
tabBarExtraContenttab bar 上额外的元素VNode | {left?: VNode, right?: VNode}-object: 4.6.0
tabBarGuttertabs 之间的间隙number-
tabBarStyletab bar 的样式对象CSSProperties-
tabPlacement页签位置,可选值有 top end bottom startstringtop
destroyOnHidden被隐藏时是否销毁 DOM 结构booleanfalse5.25.0
type页签的基本样式,可选 linecard editable-card 类型stringline
onChange切换面板的回调(activeKey: string) => void-
onEdit新增和删除页签的回调,在 type="editable-card" 时有效(action === 'add' ? event : targetKey, action) => void-
onTabClicktab 被点击的回调(key: string, event: MouseEvent) => void-
onTabScrolltab 滚动时触发({ direction: left | right | top | bottom }) => void-4.3.0

TabItemType

参数说明类型默认值版本
closeIcon自定义关闭图标,在 type="editable-card" 时有效。5.7.0:设置为 nullfalse 时隐藏关闭按钮VNode-
destroyOnHidden被隐藏时是否销毁 DOM 结构booleanfalse5.25.0
disabled禁用某一项booleanfalse
forceRender被隐藏时是否渲染 DOM 结构booleanfalse
key对应 activeKeystring-
label选项卡头显示文字VNode-
icon选项卡头显示图标VNode-5.12.0
children选项卡头显示内容VNode-
closable是否显示选项卡的关闭按钮,在 type="editable-card" 时有效booleantrue

MoreProps

参数说明类型默认值版本
icon自定义折叠图标VNode-
DropdownProps

基于 MIT 许可发布