ktui-components
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKtUI Components
KtUI组件
Use this skill when working with KtUI—free Tailwind UI components by Keenthemes. It ensures correct package usage, initialization, and reference to official docs.
当你使用KtUI——Keenthemes推出的免费Tailwind UI组件库——进行开发时,可使用本技能。它能确保你正确使用相关包、完成初始化操作,并引导你参考官方文档。
Package and imports
包与导入
- Package: (npm install
@keenthemes/ktui).@keenthemes/ktui - Import pattern (ESM): Import components and/or the init helper from the package root:
- Single component:
import { KTModal } from '@keenthemes/ktui'; - Init all: then call
import { KTComponents } from '@keenthemes/ktui';after DOM ready.KTComponents.init()
- Single component:
- Types (TypeScript): Types are exported from the same entry; use the package root (e.g. ) for types, not deep
@keenthemes/ktuipaths.lib/esm - Styles: Include KtUI CSS (e.g. from the package or built ) and ensure Tailwind and CSS variables are set up as in the installation docs.
dist/styles.css
- 包: (通过npm安装
@keenthemes/ktui)。@keenthemes/ktui - 导入模式(ESM): 从包的根目录导入组件和/或初始化助手:
- 单个组件:
import { KTModal } from '@keenthemes/ktui'; - 初始化全部组件:,然后在DOM加载完成后调用
import { KTComponents } from '@keenthemes/ktui';。KTComponents.init()
- 单个组件:
- 类型(TypeScript): 类型从同一入口导出;请使用包的根目录(例如)获取类型,而非深层的
@keenthemes/ktui路径。lib/esm - 样式: 引入KtUI CSS(例如从包中引入或使用构建后的),并确保按照安装文档中的说明配置Tailwind和CSS变量。
dist/styles.css
Initialization
初始化
- Call once after the DOM is ready so that data-attribute–driven components (dropdowns, modals, tabs, etc.) are initialized.
KTComponents.init() - Frameworks (React, Vue, Next): Run init after the root is mounted (e.g. with empty deps, or
useEffect) so the DOM withonMountedattributes exists before init.data-kt-* - For dynamically added markup (e.g. after route change or lazy load), run again or use per-component init (e.g.
KTComponents.init()on the new container).KTModal.init() - SSR: Call init only on the client (e.g. inside or when
useEffect), never during server render.typeof document !== 'undefined' - Per-component init is also available (e.g. ) when not using the full init.
KTModal.init()
- 在DOM加载完成后调用一次,这样基于data属性驱动的组件(如下拉菜单、模态框、标签页等)就能完成初始化。
KTComponents.init() - 框架(React、Vue、Next): 在根组件挂载完成后执行初始化(例如使用空依赖数组的,或
useEffect钩子),确保带有onMounted属性的DOM在初始化前已存在。data-kt-* - 对于动态添加的标记(例如路由切换或懒加载后),再次调用,或者使用单个组件的初始化方法(例如在新容器上调用
KTComponents.init())。KTModal.init() - SSR: 仅在客户端调用初始化(例如在内部,或当
useEffect时),绝不能在服务端渲染期间调用。typeof document !== 'undefined' - 当不使用全量初始化时,也可以使用单个组件的初始化方法(例如)。
KTModal.init()
Documentation
文档
- Official docs: https://ktui.io — use for component APIs, examples, and markup.
- Doc paths: Getting started: ,
ktui.io/docs/installation,ktui.io/docs/theming,ktui.io/docs/typescript,ktui.io/docs/dark-mode,ktui.io/docs/rtl. Components:ktui.io/docs/changelog(e.g.ktui.io/docs/<component>,ktui.io/docs/modal,ktui.io/docs/tooltip,ktui.io/docs/datatable,ktui.io/docs/dropdown).ktui.io/docs/repeater - Prefer docs and examples from ktui.io over inferring markup or options.
- 官方文档: https://ktui.io——可用于查阅组件API、示例和标记代码。
- 文档路径: 入门指南:、
ktui.io/docs/installation、ktui.io/docs/theming、ktui.io/docs/typescript、ktui.io/docs/dark-mode、ktui.io/docs/rtl。组件文档:ktui.io/docs/changelog(例如ktui.io/docs/<component>、ktui.io/docs/modal、ktui.io/docs/tooltip、ktui.io/docs/datatable、ktui.io/docs/dropdown)。ktui.io/docs/repeater - 优先参考ktui.io上的文档和示例,而非自行推断标记或配置选项。
Common pitfalls
常见问题
- Components not opening or reacting: Ensure ran after the relevant DOM was in the page; for SPAs, run init after navigation or after injecting KtUI markup.
KTComponents.init() - Styles missing or wrong: Confirm KtUI CSS and CSS variables are loaded (see installation, theming).
- SSR/hydration: Do not call init during server render; run it only in the browser after mount.
Component list (reference)
组件列表(参考)
Components exported from include: KTDropdown, KTModal, KTDrawer, KTCollapse, KTDismiss, KTTabs, KTAccordion, KTScrollspy, KTScrollable, KTScrollto, KTSticky, KTReparent, KTToggle, KTTooltip, KTStepper, KTThemeSwitch, KTImageInput, KTTogglePassword, KTDataTable, KTSelect, KTToast, KTRating, KTRepeater. See the package exports or ktui.io for the full list and usage.
@keenthemes/ktui从导出的组件包括:KTDropdown、KTModal、KTDrawer、KTCollapse、KTDismiss、KTTabs、KTAccordion、KTScrollspy、KTScrollable、KTScrollto、KTSticky、KTReparent、KTToggle、KTTooltip、KTStepper、KTThemeSwitch、KTImageInput、KTTogglePassword、KTDataTable、KTSelect、KTToast、KTRating、KTRepeater。完整列表及使用方法请查看包的导出内容或ktui.io官网。
@keenthemes/ktui