组件
标签页 Tabs
Tabs:页签导航。部件:Root、List、Trigger、Content、Indicator(由状态机定位在列表线上的墨色指示条)。
#基础用法
Content is ink — the marks that carry the words.
The ground is warm paper, never pure white.
Hierarchy is light — shadow answers to the source.
<script setup lang="ts">
import { Tabs } from "@bysages/vue";
</script>
<template>
<!-- The strip rides the full width, the way a page's own tabs do. -->
<Tabs.Root default-value="ink" class="w-full">
<Tabs.List class="w-full">
<Tabs.Trigger value="ink">Ink</Tabs.Trigger>
<Tabs.Trigger value="paper">Paper</Tabs.Trigger>
<Tabs.Trigger value="light">Light</Tabs.Trigger>
<Tabs.Indicator />
</Tabs.List>
<Tabs.Content value="ink">Content is ink — the marks that carry the words.</Tabs.Content>
<Tabs.Content value="paper">The ground is warm paper, never pure white.</Tabs.Content>
<Tabs.Content value="light">Hierarchy is light — shadow answers to the source.</Tabs.Content>
</Tabs.Root>
</template>
The brush answers the hand.
The ink remembers the grinding.
The paper holds its breath.
<script setup lang="ts">
import { Tabs } from "@bysages/vue";
</script>
<template>
<Tabs.Root variant="card" default-value="brush" class="w-full">
<Tabs.List>
<Tabs.Trigger value="brush">Brush</Tabs.Trigger>
<Tabs.Trigger value="ink">Ink</Tabs.Trigger>
<Tabs.Trigger value="paper">Paper</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="brush">The brush answers the hand.</Tabs.Content>
<Tabs.Content value="ink">The ink remembers the grinding.</Tabs.Content>
<Tabs.Content value="paper">The paper holds its breath.</Tabs.Content>
</Tabs.Root>
</template>
#属性
#Root
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
size | String as PropType<"sm" | "md" | "lg"> | "md" | 标签行的高度档位 |
variant | String as PropType<"line" | "card"> | "line" | 标签页样式:刻线式,或将选中项呈现为卡片 |
orientation | String as PropType<"horizontal" | "vertical"> | "horizontal" | tabs 的方向,可为 horizontal 或 vertical:horizontal 仅支持左右方向键,vertical 仅支持上下方向键 |
activationMode | 'manual' | 'automatic' | "automatic" | tabs 的激活模式,可为 manual 或 automatic:manual 在点击或按 enter 时激活,automatic 在获得焦点时激活 |
composite | boolean | 是否为复合组件 | |
defaultValue | string | tabs 渲染时的初始选中值;不需要控制选中值时使用 | |
deselectable | boolean | 点击当前激活标签时是否取消选中 | |
id | string | 组件内部状态机的唯一标识 | |
ids | Partial<{ root: string; trigger: (id: string) => string; content: (id: string) => string; list: string; indicator: string; }> | tabs 各元素的 id,适合组合使用 | |
loopFocus | boolean | true | 键盘导航是否从最后一个标签循环到第一个,反向同理 |
modelValue | string | tabs 的 v-model 值 | |
navigate | (details: tabs.NavigateDetails) => void | 点击标签时导航到所选标签的函数;标签触发器是锚点元素时有用 | |
translations | tabs.IntlTranslations | 无障碍元素及其状态的本地化文案 |