Skip to content

Tabler-Vue 组件库使用技能

Tabler-Vue Component Library Skills

本文件定义一组技能(Skills),供 AI 助手在协助用户使用 @gulcc/tabler-vue 组件库时调用。每个技能对应一个常见的开发场景,描述了该场景下应使用的组件、Tabler CSS 类名和代码模式。

本文件为宏观使用指南。每个组件的详细 API 和代码示例见 <CurrentUrl />/skills/{组件名}/SKILL.md。 This file is a macro-level usage guide. For detailed API and code examples per component, see <CurrentUrl />/skills/{ComponentName}/SKILL.md.


🤖 AI 生成规则 / AI Generation Rules

#中文English
1必须使用 Vue 3 <script setup lang="ts"> + Composition API,禁止 Options APIMust use Vue 3 <script setup lang="ts"> + Composition API. Options API is prohibited.
2只使用本文件中明确列出的组件名,禁止伪造不存在的组件或 PropsOnly use component names listed here. Do not fabricate non-existent components or props.
3使用响应式解构 const { value = 0 } = defineProps<Props>(),禁止 withDefaultsUse reactive destructuring. withDefaults is prohibited.
4使用 defineModel(),禁止手写 emit('update:xxx')Use defineModel(). Manual emit('update:xxx') is prohibited.
5优先使用 Tabler CSS utility class,除过渡动画外不写 <style scoped>Prefer Tabler CSS utilities. No <style scoped> except for transitions.
6始终给 v-for 绑定 :keyAlways bind :key to v-for.
7不要引入第三方库,除非用户明确要求Do not introduce third-party libraries unless requested.

Quick Start / 项目引入

bash
pnpm add @gulcc/tabler-vue @tabler/core @tabler/icons-vue
ts
import { createApp } from 'vue'
import '@tabler/core/dist/css/tabler.min.css'
import TablerVue from '@gulcc/tabler-vue'

const app = createApp(App)
app.use(TablerVue)
app.mount('#app')

按需引入 / On-Demand Import:

vue
<script setup lang="ts">
import { TButton, TBadge, TCard } from '@gulcc/tabler-vue'
import { IconHeart } from '@tabler/icons-vue'
</script>

布局容器 / Layout Container (TContainer)

TContainer is the page-level layout skeleton. Two modes: pattern mode (12 presets) and flexible sub-component mode.

vue
<!-- Pattern mode / pattern 模式 -->
<TContainer pattern="classic" header-height="56px" aside-width="220px">
  <template #header>顶部导航 / Top Nav</template>
  <template #aside>侧边菜单 / Side Menu</template>
  主内容区 / Main Content
  <template #footer>底部版权 / Copyright</template>
</TContainer>

<!-- Flexible mode / 灵活子组件模式 -->
<TContainer>
  <TContainerHeader height="56px">Header</TContainerHeader>
  <TContainerAside width="220px">Sidebar</TContainerAside>
  <TContainerMain>Content</TContainerMain>
  <TContainerFooter height="60px">Footer</TContainerFooter>
</TContainer>

颜色系统 / Color System

类别 / Category示例值 / Example Values
品牌色 / Brandblue, azure, indigo, purple, pink, red, orange, yellow, lime, green, teal, cyan
语义色 / Statusprimary, secondary, success, danger, warning, info
中性色 / Neutraldark, light, muted
浅色变体 / Lightprimary-lt, success-lt, blue-lt
vue
<TButton color="primary">提交 / Submit</TButton>
<TBadge color="success-lt">已完成 / Completed</TBadge>
<TAlert color="danger" title="Error / 错误">Please check / 请检查</TAlert>

表单与输入 / Forms & Input

组件 / Component用途 / Purposev-model
TInput文本/数字/密码 / Text, number, passwordv-model="value"
TSelect下拉选择 / Select dropdownv-model="value"
TCheckbox / TCheckboxGroup复选框 / Checkboxv-model="value"
TRadio / TRadioGroup单选框 / Radiov-model="value"
TSwitch开关 / Toggle switchv-model="value"
TSlider滑块 / Range sliderv-model="value"
TUpload文件上传 / File uploadv-model="files"
TMaskInput掩码输入 / Masked inputv-model="value"
vue
<TInput v-model="name" placeholder="Enter name / 请输入姓名" />
<TSelect v-model="city" :options="cityOptions" />
<TCheckbox v-model="agreed">I agree / 同意</TCheckbox>

浮层与反馈 / Overlays & Feedback

组件 / Component用途 / Purpose触发 / Trigger
TModal弹窗 / Modal dialogv-model="visible"
TDropdown下拉菜单 / Dropdownclick / hover
TPopover气泡卡片 / Popoverclick / hover
TTooltip文字提示 / Tooltiphover
TOffcanvas抽屉 / Offcanvas panelv-model="visible"
toast全局通知 / Notificationtoast.success('msg')

Toast 全局通知 / Global Notifications

需在 App.vue 放置 <TToastContainer /> 组件 / Must place <TToastContainer /> in App.vue

vue
<!-- App.vue -->
<template>
  <RouterView />
  <TToastContainer placement="top-right" />
</template>

<!-- 任意组件 / Any component -->
<script setup lang="ts">
import { toast } from '@gulcc/tabler-vue'
toast.success('操作成功 / Success')
toast.error('网络错误 / Network error', { duration: 0 })
toast.warning('即将过期 / Expiring', { title: '提示 / Notice' })
</script>

数据展示 / Data Display

组件 / Component用途 / Purpose
TTable表格 / Table (sort/filter/pagination/expand)
TTree / TTreeNode树形控件 / Tree control
TTreeMenu树形导航菜单 / Tree navigation
TTimeline时间轴 / Timeline
TTransfer穿梭框 / Transfer
TCarousel走马灯 / Carousel
TCalendar日历 / Calendar

通用原子组件 / Atomic Components

组件 / Component用途 / Purpose常用 Props / Common Props
TButton按钮 / Buttoncolor, size, outline, ghost, loading, disabled
TBadge徽章 / Badgecolor
TAvatar头像 / Avatarsrc, size, color, initials
TCard卡片 / Cardtitle, bg, imgSrc, size
TDivider分割线 / Divider
TProgress进度条 / Progressvalue, color, striped
TSpinner加载圈 / Spinnersize, color
TPlaceholder骨架屏 / Skeleton
TEmpty空状态 / Empty statetitle, description
TTag标签 / Tagcolor

导航组件 / Navigation

组件 / Component用途 / Purpose
TTabs / TTabPane标签页 / Tabs
TBreadcrumb面包屑 / Breadcrumb
TPagination分页 / Pagination
TSteps步骤条 / Steps
TAccordion / TAccordionItem折叠面板 / Accordion

配色辅助 / Color Usage Rules

变体 / Variant处理 / Handling
实色 bg-* / Solid必须搭配 text-*-fg,如 bg-red text-red-fg
浅色 bg-*-lt / Light无需 text-*-fg,Tabler 自动处理 / Auto-handled

图标使用 / Icon Usage

图标来自 @tabler/icons-vue,作为 Vue 组件直接渲染 / Icons render as Vue components directly:

vue
<script setup lang="ts">
import { IconHeart, IconSettings } from '@tabler/icons-vue'
</script>

<template>
  <IconHeart :size="32" color="red" />
  <TButton color="primary">
    <IconHeart class="me-1" /> Like / 喜欢
  </TButton>
</template>

图标放在文字左侧加 me-1,右侧加 ms-1 / Use me-1 when icon is left of text, ms-1 when right.


表单校验 / Form Validation

本库没有 TForm / TFormItem 包裹组件 / This library does NOT have TForm wrapper:

vue
<TInput
  v-model="email"
  label="Email / 邮箱"
  :error="!isValid"
  error-message="Invalid / 格式不正确"
  wrapper-class="mb-3"
/>

复杂组件数据接口 / Data Interfaces

TTable

ts
interface TableColumn {
  key: string
  title: string
  width?: string | number
  align?: 'left' | 'center' | 'right'
  sortable?: boolean
  filters?: { text: string; value: any }[]
  render?: (text: any, record: T, index: number) => any
  fixed?: 'left' | 'right'
}

TSelect

ts
interface SelectOption {
  label: string
  value: any
  disabled?: boolean
}

高频组件事件与插槽 / Events & Slots

组件 / Component事件 / Events插槽 / Slots
TModal@update:modelValue, @close, @opendefault, header, title, footer
TDropdown@selectdefault, item
TTable@page-change, @sort-change, @filter-change#cell(key) 自定义列渲染
TPagination@update:page, @update:page-size
TAccordion@change#title, #icon, default
TUpload@update:modelValue, @change

表格自定义列插槽示例 / Custom Table Column Slot:

vue
<TTable :columns="columns" :data="tableData">
  <template #cell(name)="{ row }">
    <strong>{{ row.name }}</strong>
  </template>
  <template #cell(action)="{ row }">
    <TButton size="sm" color="danger" @click="handleDelete(row)">删除 / Delete</TButton>
  </template>
</TTable>

各组件详细 SKILL 文件 / Per-Component SKILL Files

本文件提供整体概览。每个组件的详细 Props、Events、Slots、基础用法和进阶场景,可在独立的组件 SKILL 文件中查阅,AI 助手会在需要时自动引用。

每个组件的 SKILL 文件位于:{当前URL}/skills/{组件名}/SKILL.md

分类组件 SKILL
基础TButton · TBadge · TSpinner · TTag · TTagList · TAvatar · TAvatarList
布局TCard · TDivider · TRibbon · TContainer · TPlaceholder · TButtonGroup · TButtonList · TButtonActions
导航TTabs · TTabPane · TBreadcrumb · TPagination · TSteps · TAccordion · TNavbar · TNavbarBrand · TNavMenu · TTreeMenu · TTreeMenuItem
数据展示TTable · TTree · TTreeNode · TTimeline · TTimelineItem · TTransfer · TCarousel · TCalendar · TTracking · TScrollSpy
反馈TAlert · TModal · TDropdown · TPopover · TTooltip · TOffcanvas · TSlidedown · TDelete
表单TInput · TSelect · TCheckbox · TRadio · TSwitch · TSlider · TUpload · TMaskInput · TAutosize · TInputOtp · TSwitchIcon
选择TCombobox · TTreeSelect · TTreeSelectNode · TColorCheck · TColorPicker · TColorPickerPanel · TImageCheck · TImageCheckItem · TSelectboxes · TSelectboxItem · TSegmentedControl · TTimeZone
状态TStatus · TStatusDot · TStatusIndicator · TProgress · TProgressBar · TEmpty · TCountup · TStarRating
其他TSignaturePad · TBytes · TCronPicker · TOtpCountdown · TPrivacyMask

文件中涉及的组件 Props、Events、Slots 均基于组件源码生成,AI 引用时可确保类型正确。 All component APIs in these files are generated from the actual source code, ensuring type accuracy.