Component

Tabs

安装 Installation

npx timkit add tabs --yes --framework react

用法 Usage

import { Tabs } from "@/components/ui/tabs"

className 与 variant、size 可以一起用。字段以 timkit agent inspect tabs --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

20 / 20

Tabs · Basic tabs · 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

tabs

Logic

zag / tabs

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
zagState and interaction provider used by this component.
logic.machine
string
tabsUnderlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/core, @zag-js/reactRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
use-machineDependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
disabled
boolean
falseWhen true, tab changes are ignored.
value
string
-The controlled value of the tab to activate.
defaultValue
string
-The default active tab value.
orientation
enum (horizontal | vertical)
horizontalThe orientation of the tabs.

Events

PropTypeDefaultDescription
onValueChange
event
-Event handler called when the value changes.

Slots

PropTypeDefaultDescription
default
slot
-The tabs list and content

Parts

PropTypeDefaultDescription
root*
root
-The tabs container
list
part
-The tab list
trigger
part
-The tab trigger
content
part
-The tab content panel
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • ArrowRight selects the next tab and skips a disabled tab.
  • Home selects the first enabled tab.
  • End selects the last.
  • The selected tab and its panel are in the tab order.
  • The other tabs are not.
  • In static HTML, the selected panel stays in the tab order.
  • In static HTML, each tab is a button.
  • The selected tab is visible as Tab N of the tab count.
  • An empty value has no tab status.
  • An omitted name is Tabs.
  • A passed aria-label names the tab list.
  • A disabled tab is not in the tab order.
  • A disabled tab list leaves every tab out of the tab order.
  • Each tab controls its panel.
  • The panel is named by its tab.
  • On the mini program, aria-controls is set only on the selected tab.
  • On the mini program, a disabled tabs root sets aria-disabled.

行为契约

Contract

props、默认值和运行时状态。

  • Horizontal tabs move with Left and Right.
  • Vertical tabs move with Up and Down.