Tabs 标签页

选项卡切换组件。

何时使用

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

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

  • 卡片式的页签,提供可关闭的样式,常用于容器顶部。
  • 标准线条式页签,用于容器内部的主功能切换,这是最常用的 Tabs。
  • RadioButton 可作为更次级的页签来使用。

代码演示

Content of Tab Pane 1

基本用法

默认选中第一项。

expand code expand code
Tab 1

禁用

禁用某一项。

expand code expand code
Tab 2

图标

有图标的标签。

expand code expand code
Content of tab 1

滑动

可以左右、上下滑动,容纳更多标签。

expand code expand code
Content of tab 1

附加内容

可以在页签右边添加附加操作。

expand code expand code
Content of tab 2

大小

大号页签用在页头区域,小号用在弹出框等较狭窄的容器内。

expand code expand code
Content of Tab 1

位置

有四个位置,tabPosition="left|right|top|bottom"

expand code expand code
Content of Tab Pane 1

卡片式页签

另一种样式的页签,不提供对应的垂直样式。

expand code expand code
Content of Tab 1

新增和关闭页签

只有卡片样式的页签支持新增和关闭选项。
使用 closable={false} 禁止关闭。

expand code expand code

Content of Tab Pane 1

Content of Tab Pane 1

Content of Tab Pane 1

卡片式页签容器

用于容器顶部,需要一点额外的样式覆盖。

expand code expand code
Content of Tab 1

自定义新增页签触发器

隐藏默认的页签增加图标,给自定义触发器绑定事件。

expand code expand code
Content of Tab Pane 1

自定义页签头

自定义页签头

expand code expand code

API

Tabs

参数 说明 类型 默认值
activeKey(v-model) 当前激活 tab 面板的 key string
animated 是否使用动画切换 Tabs,在 tabPosition=top|bottom 时有效 boolean | {inkBar:boolean, tabPane:boolean} true, 当 type="card" 时为 false
defaultActiveKey 初始化选中面板的 key,如果没有设置 activeKey string 第一个面板
hideAdd 是否隐藏加号图标,在 type="editable-card" 时有效 boolean false
size 大小,提供 large defaultsmall 三种大小 string 'default'
tabBarExtraContent tab bar 上额外的元素 slot
tabBarStyle tab bar 的样式对象 object -
tabPosition 页签位置,可选值有 top right bottom left string 'top'
type 页签的基本样式,可选 linecard editable-card 类型 string 'line'
tabBarGutter tabs 之间的间隙 number

事件

事件名称 说明 回调参数
change 切换面板的回调 Function(activeKey) {}
edit 新增和删除页签的回调,在 type="editable-card" 时有效 (targetKey, action): void
nextClick next 按钮被点击的回调 Function
prevClick prev 按钮被点击的回调 Function
tabClick tab 被点击的回调 Function

Tabs.TabPane

参数 说明 类型 默认值
forceRender 被隐藏时是否渲染 DOM 结构 boolean false
key 对应 activeKey string
tab 选项卡头显示文字 string|slot
  Table 表格Tag 标签