Skip to content

简介 ​

thl-ui 是一个与框架无关的设计系统,拥有自己的 CSS(不依赖 Bootstrap,也不依赖 jQuery),并提供 React、Vue 和 Angular 的原生组件。

架构 ​

            ┌────────────────────────── @thl-ui/core ──────────────────────────┐
            │  createThl()  →  config store · i18n · applyToDocument()          │
            │  headless: tabs · table · select · toast · upload · calendar …    │
            │  utils: bem() · cx() · focusTrap · scrollLock · clickOutside      │
            └───────────────▲──────────────────▲──────────────────▲────────────┘
                            │                  │                  │
   @thl-ui/tokens ──► @thl-ui/styles (CSS vars, .thl-* BEM, 12 skins, dark)
                            │                  │                  │
                  @thl-ui/react         @thl-ui/vue        @thl-ui/angular
               ThlProvider + hooks   plugin + composables  provideThlUI + signals
包用途
@thl-ui/tokens设计 token(调色板、间距、圆角、皮肤)→ CSS 自定义属性
@thl-ui/styles与框架无关的 CSS(thl-ui.css、按组件拆分的 CSS、SCSS 源码)
@thl-ui/localesen、vi、ja、zh 的文案 + 类型
@thl-ui/core配置、i18n、无头状态机、工具函数
@thl-ui/icons图标注册表(lucide 子集,可扩展字体图标)
@thl-ui/charts无依赖的 SVG 图表几何计算
@thl-ui/react · @thl-ui/vue · @thl-ui/angular原生适配器

同一套 API,三个框架 ​

每个适配器都渲染完全相同的标记(由共享的 bem() 辅助函数生成),并暴露相同的 prop 名称,因此组件在任何地方的外观和行为都一致:

vue
<ThlButton variant="primary" icon="download" rounded>下载</ThlButton>
tsx
<Button variant="primary" icon="download" rounded>下载</Button>
html
<button thl-button variant="primary" icon="download" rounded>下载</button>

差异仅在于各框架自身的惯用写法:

概念VueReactAngular
安装app.use(ThlUI, config)<ThlProvider config>provideThlUI(config)
双向绑定v-modelvalue + onChange[(value)]、formControlName、ngModel
翻译useI18n().t / $tuseT()ThlI18nService.t / | thlT
配置useThlConfig()useThlConfig()ThlConfigService
ToastuseToast()useToast()ThlToastService
Confirmconfirm()confirm()ThlModalService.confirm()
组件名称ThlButtonButtonThlButtonComponent / thl-* 选择器

下一步 ​