@kizukulab/kira-ui
v0.1.0
Published
Kira's design system: a token contract, framework-free components, and seven themes that implement it.
Maintainers
Readme
Kira UI
Kira's design system, in two parts:
core/, the interface:tokens.json: the design tokens (--ui-*CSS variables) every theme must define.components.css: buttons, inputs, tabs, pills, chips, cards, meters, modals, toasts and switches. They use only the tokens.ui.js+types.d.ts: small builders that make the same markup (button(),tabs(),modal(), …). No framework.
themes/, the implementations: one CSS file per look. All seven of Kira's skins are here: Orbital (the default, light and dark), Terminal (dark and light), Glass, Memphis, Swiss, Dot Matrix (light and dark) and Clay.
A theme changes how every component looks, including its quirks: Memphis's hard offset shadows, Glass's frosted blur, Clay's puffy shadows, Terminal's square monospace controls. The components stay the same.
Use it
<link rel="stylesheet" href="themes/all.css" /> <!-- or just the one theme you want -->
<link rel="stylesheet" href="core/components.css" />
<html data-ui-theme="memphis"> <!-- pick a theme; data-ui-mode="dark" | "light" where it has modes -->import { button, tabs, toast } from "@kizukulab/kira-ui";
document.body.append(
tabs({ items: [{ id: "a", label: "Inbox" }, { id: "b", label: "Done", count: 3 }], value: "a", onChange: show }),
button({ label: "Save", variant: "primary", onClick: () => toast("Saved") }),
);Or write the markup yourself: the class names in components.css are the interface (ui-btn ui-btn--primary, ui-tabs > ui-tab[aria-selected], ui-pill ui-pill--good, …).
In Kira, widgets get all of this for free: /plugins/_sdk/kira.css includes the components, Kira switches the theme for you, and ui.js is at /plugins/_sdk/ui/ui.js.
Make your own theme
Install with npm install @kizukulab/kira-ui, copy any file from themes/, change the selector to your own id (:root[data-ui-theme="acme"]) and the values. It must define every token in core/tokens.json, no more and no fewer. Kira's tests check each built-in theme against that list, and you can run the same check on yours: npx kira-ui-check-theme my-theme.css (or node node_modules/@kizukulab/kira-ui/scripts/check-theme.js my-theme.css). A theme may also set color-scheme and keep private variables of its own (not starting with --ui-).
You can also replace components.css with your own implementation, as long as it keeps the class names and states (aria-selected, aria-pressed, disabled).
Licence
MIT. See LICENSE.
