ktui-theming
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKtUI Theming
KtUI 主题定制
Use this skill when working with KtUI theming—colors, dark mode, and custom appearance. KtUI uses CSS variables and a background/foreground convention; prefer these over inventing custom classes.
当你处理KtUI主题相关工作(颜色、暗色模式、自定义外观)时,可使用本技能。KtUI采用CSS变量以及背景/前景命名约定;请优先使用这些约定,而非自定义类。
Convention
命名约定
- Background/foreground: KtUI follows a Shadcn-inspired convention. Background colors omit the suffix (e.g.
-backgroundusesbg-primary). Foreground colors usevar(--primary)(e.g.-foreground).text-primary-foreground - Semantic classes: Use KtUI semantic utilities (e.g. ,
bg-background,text-foreground,bg-primary,text-card,kt-btn) so theming stays consistent.kt-card
- 背景/前景: KtUI遵循Shadcn风格的命名约定。背景色省略后缀(例如
-background使用bg-primary)。前景色使用var(--primary)后缀(例如-foreground)。text-primary-foreground - 语义类: 使用KtUI语义工具类(例如、
bg-background、text-foreground、bg-primary、text-card、kt-btn),确保主题一致性。kt-card
Key CSS variables
核心CSS变量
Define or override in your Tailwind entry (e.g. ). KtUI expects at least:
style.css- Surfaces: ,
--background;--foreground,--card;--card-foreground,--popover.--popover-foreground - Brand: ,
--primary;--primary-foreground,--secondary.--secondary-foreground - Muted / accent: ,
--muted;--muted-foreground,--accent.--accent-foreground - Destructive: ,
--destructive.--destructive-foreground - Borders and inputs: ,
--border,--input.--ring - Radius: (e.g.
--radius).0.5rem
Use or any valid CSS color. Example:
oklch()css
:root {
--background: oklch(1 0 0);
--foreground: oklch(14.1% 0.005 285.823);
--primary: oklch(62.3% 0.214 259.815);
--primary-foreground: oklch(1 0 0);
--radius: 0.5rem;
}在你的Tailwind入口文件(例如)中定义或覆盖这些变量。KtUI至少需要以下变量:
style.css- 界面表层: 、
--background;--foreground、--card;--card-foreground、--popover。--popover-foreground - 品牌色: 、
--primary;--primary-foreground、--secondary。--secondary-foreground - 弱化/强调色: 、
--muted;--muted-foreground、--accent。--accent-foreground - 警示色: 、
--destructive。--destructive-foreground - 边框与输入框: 、
--border、--input。--ring - 圆角: (例如
--radius)。0.5rem
可使用或任何有效的CSS颜色格式。示例:
oklch()css
:root {
--background: oklch(1 0 0);
--foreground: oklch(14.1% 0.005 285.823);
--primary: oklch(62.3% 0.214 259.815);
--primary-foreground: oklch(1 0 0);
--radius: 0.5rem;
}Dark mode
暗色模式
- Variables: Override the same variables under a scope (or your dark-mode class). KtUI docs use
.darkfor dark theme..dark - Tailwind: Add the dark variant, e.g. in your Tailwind entry so utilities like
@custom-variant dark (&:is(.dark *));work.dark:bg-background - Theme switch: Use the KTThemeSwitch component or toggle the class on
.dark(or a wrapper) to switch between light and dark variables.<html>
- 变量覆盖: 在作用域(或你使用的暗色模式类)下覆盖相同的变量。KtUI官方文档使用
.dark类来实现暗色主题。.dark - Tailwind配置: 在你的Tailwind入口文件中添加暗色变体,例如,这样
@custom-variant dark (&:is(.dark *));这类工具类才能正常工作。dark:bg-background - 主题切换: 使用KTThemeSwitch组件,或在(或某个父容器)上切换
<html>类,实现明暗变量的切换。.dark
Documentation
官方文档
- Theming: ktui.io/docs/theming
- Dark mode: ktui.io/docs/dark-mode
- Installation (variables setup): ktui.io/docs/installation
Prefer the official variable list and examples from these pages over guessing variable names or values.
- 主题定制: ktui.io/docs/theming
- 暗色模式: ktui.io/docs/dark-mode
- 安装(变量设置):ktui.io/docs/installation
请优先参考这些页面中的官方变量列表和示例,而非自行猜测变量名称或取值。