zabi-components 5.0.22 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -44
- package/THEME.md +473 -0
- package/THEMING.md +248 -0
- package/dist/atoms/Card.svelte +40 -67
- package/dist/atoms/Card.svelte.d.ts +3 -3
- package/dist/atoms/CardHeader.svelte +10 -1
- package/dist/atoms/CardHeader.svelte.d.ts +3 -0
- package/dist/atoms/CodeBlock.svelte +1 -1
- package/dist/atoms/ColorPicker.svelte +1 -1
- package/dist/atoms/Input.svelte +2 -2
- package/dist/atoms/Progress.svelte +1 -1
- package/dist/atoms/Select.svelte +7 -5
- package/dist/atoms/Textarea.svelte +2 -2
- package/dist/atoms/Toast.svelte +1 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/organisms/index.d.ts +1 -2
- package/dist/components/organisms/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/lib/showcase/components-catalog.d.ts +3 -0
- package/dist/lib/showcase/components-catalog.d.ts.map +1 -0
- package/dist/lib/showcase/components-showcase-constants.d.ts +63 -0
- package/dist/lib/showcase/components-showcase-constants.d.ts.map +1 -0
- package/dist/lib/showcase/docs-sidebar-helpers.d.ts +15 -0
- package/dist/lib/showcase/docs-sidebar-helpers.d.ts.map +1 -0
- package/dist/molecules/Alert.svelte +1 -1
- package/dist/molecules/ComponentDemo.svelte +53 -50
- package/dist/molecules/ContactForm.svelte +69 -64
- package/dist/molecules/Dropdown.svelte +2 -1
- package/dist/molecules/ImageUpload.svelte +1 -1
- package/dist/molecules/Modal.svelte +2 -2
- package/dist/molecules/NavigationMenuContent.svelte +1 -1
- package/dist/molecules/NavigationMenuLink.svelte +1 -1
- package/dist/molecules/NavigationMenuTrigger.svelte +1 -4
- package/dist/molecules/Section.svelte +12 -12
- package/dist/molecules/SlideUp.svelte +2 -2
- package/dist/molecules/Tabs.svelte +3 -3
- package/dist/organisms/Navbar.svelte +170 -53
- package/dist/organisms/Navbar.svelte.d.ts +31 -4
- package/dist/organisms/SidebarNavigation.svelte +209 -165
- package/dist/organisms/SidebarNavigation.svelte.d.ts +5 -0
- package/dist/organisms/{SidebarProjectPanel.svelte → SidebarPanel.svelte} +18 -17
- package/dist/organisms/{SidebarProjectPanel.svelte.d.ts → SidebarPanel.svelte.d.ts} +6 -6
- package/dist/organisms/index.d.ts +1 -2
- package/dist/organisms/index.js +1 -2
- package/dist/types/page.types.d.ts +32 -0
- package/dist/types/page.types.d.ts.map +1 -0
- package/dist/types/variants.ts +76 -0
- package/dist/zabi-components-colors.css +347 -324
- package/dist/zabi-components-theme-dark-only.css +159 -151
- package/dist/zabi-components-theme-dark.css +159 -151
- package/dist/zabi-components-theme-only.css +245 -230
- package/dist/zabi-components-theme.css +245 -230
- package/dist/zabi-components.css +437 -101
- package/docs/theme-imports.md +112 -0
- package/package.json +16 -6
- package/dist/organisms/Navigation.svelte +0 -119
- package/dist/organisms/Navigation.svelte.d.ts +0 -21
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Zabi Components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Svelte 5 UI components with TypeScript and Tailwind. Same behavior in the browser and on the server.
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> **Svelte 5** — Uses runes (`$props`, `$derived`, `$state`). Requires **Svelte 5.43.8** or newer.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Approach
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Semantic HTML, sensible defaults, and props that stay predictable—especially when you use SSR.
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
@@ -46,30 +46,28 @@ Zabi Components includes a comprehensive theme system with Tailwind CSS v4. You
|
|
|
46
46
|
|
|
47
47
|
### Quick Setup
|
|
48
48
|
|
|
49
|
-
**
|
|
49
|
+
**Canonical (recommended for Tailwind v4 apps):**
|
|
50
50
|
|
|
51
51
|
```css
|
|
52
52
|
/* app.css */
|
|
53
53
|
@import "tailwindcss";
|
|
54
|
-
@import
|
|
55
|
-
@import
|
|
54
|
+
@import "zabi-components/theme-only";
|
|
55
|
+
@import "zabi-components/theme-dark-only";
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
**
|
|
58
|
+
**Alternative (no Tailwind setup):**
|
|
59
59
|
|
|
60
60
|
```css
|
|
61
61
|
/* app.css */
|
|
62
|
-
@import
|
|
63
|
-
@import 'zabi-components/dist/zabi-components.css';
|
|
62
|
+
@import "zabi-components/colors";
|
|
64
63
|
```
|
|
65
64
|
|
|
66
65
|
### With Dark Mode
|
|
67
66
|
|
|
68
67
|
```css
|
|
69
68
|
@import "tailwindcss";
|
|
70
|
-
@import
|
|
71
|
-
@import
|
|
72
|
-
@import 'zabi-components/dist/zabi-components.css';
|
|
69
|
+
@import "zabi-components/theme-only";
|
|
70
|
+
@import "zabi-components/theme-dark-only"; /* Add dark mode support */
|
|
73
71
|
```
|
|
74
72
|
|
|
75
73
|
### Extending the Theme
|
|
@@ -86,10 +84,11 @@ You can extend the theme with custom colors and fonts:
|
|
|
86
84
|
--color-custom-primary: #ff0000;
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
@import
|
|
87
|
+
@import "zabi-components/theme-only";
|
|
90
88
|
```
|
|
91
89
|
|
|
92
|
-
> 📖 **Complete Theme Guide**: See [THEME.md](./THEME.md) for comprehensive documentation on theme usage, customization, dark mode, and advanced patterns.
|
|
90
|
+
> 📖 **Complete Theme Guide**: See [THEME.md](./THEME.md) for comprehensive documentation on theme usage, customization, dark mode, and advanced patterns.
|
|
91
|
+
> **Which CSS file to import** (`theme`, `theme-only`, `colors`, etc.): [docs/theme-imports.md](./docs/theme-imports.md)
|
|
93
92
|
|
|
94
93
|
## Import Methods
|
|
95
94
|
|
|
@@ -139,10 +138,7 @@ import {
|
|
|
139
138
|
Section,
|
|
140
139
|
Tabs
|
|
141
140
|
} from 'zabi-components/molecules';
|
|
142
|
-
import {
|
|
143
|
-
Navbar,
|
|
144
|
-
Navigation
|
|
145
|
-
} from 'zabi-components/organisms';
|
|
141
|
+
import { Navbar, SidebarNavigation, SidebarPanel } from 'zabi-components/organisms';
|
|
146
142
|
|
|
147
143
|
// Import types separately
|
|
148
144
|
import type { ButtonEvents, InputEvents } from 'zabi-components/types';
|
|
@@ -162,14 +158,13 @@ import {
|
|
|
162
158
|
|
|
163
159
|
```svelte
|
|
164
160
|
<script lang="ts">
|
|
165
|
-
// Clean Components - Less is More
|
|
166
161
|
import {
|
|
167
162
|
Card,
|
|
168
163
|
CardHeader,
|
|
169
164
|
CardContent,
|
|
170
165
|
CardFooter,
|
|
171
166
|
Form,
|
|
172
|
-
|
|
167
|
+
Navbar,
|
|
173
168
|
Button,
|
|
174
169
|
IconButton,
|
|
175
170
|
Input,
|
|
@@ -204,7 +199,7 @@ import {
|
|
|
204
199
|
<div class="min-h-screen bg-gray-50">
|
|
205
200
|
<header class="flex items-center justify-between p-4 bg-white border-b">
|
|
206
201
|
<h1 class="text-xl font-bold">My App</h1>
|
|
207
|
-
<
|
|
202
|
+
<Navbar embedded ariaLabel="Primary" navVariant="header" items={navItems} />
|
|
208
203
|
</header>
|
|
209
204
|
|
|
210
205
|
<main class="container mx-auto p-6">
|
|
@@ -314,7 +309,7 @@ import {
|
|
|
314
309
|
|
|
315
310
|
## Component Overview
|
|
316
311
|
|
|
317
|
-
### Core
|
|
312
|
+
### Core components
|
|
318
313
|
|
|
319
314
|
| Component | Category | Description | Key Features |
|
|
320
315
|
|-----------|----------|-------------|--------------|
|
|
@@ -323,7 +318,6 @@ import {
|
|
|
323
318
|
| **CardContent** | Atom | Card content section | Compound component for card structure |
|
|
324
319
|
| **CardFooter** | Atom | Card footer section | Compound component for card structure |
|
|
325
320
|
| **Form** | Molecule | Simple form wrapper | FormData handling, clean API |
|
|
326
|
-
| **Navigation** | Organism | Clean navigation | Header/sidebar variants, active state |
|
|
327
321
|
| **Button** | Atom | Action button | 6 variants (primary, secondary, danger, ghost, outline, link) |
|
|
328
322
|
| **IconButton** | Atom | Icon-only button | Icon-only, variants, sizes, accessible label |
|
|
329
323
|
| **Input** | Atom | Form input | Essential props, accessibility, semantic variants |
|
|
@@ -332,7 +326,7 @@ import {
|
|
|
332
326
|
| **Tabs** | Molecule | Tab navigation | Keyboard navigation, 2 variants |
|
|
333
327
|
| **Dropdown** | Molecule | Dropdown menu | CSS-only positioning, keyboard navigation, ARIA support |
|
|
334
328
|
| **ImageUpload** | Molecule | File upload | Direct selection, preview |
|
|
335
|
-
| **Navbar** | Organism | Navigation bar |
|
|
329
|
+
| **Navbar** | Organism | Navigation bar | Built-in links or snippets, `embedded` link strip, mobile menu |
|
|
336
330
|
| **NavigationMenu** | Molecule | Advanced navigation menu | Compound components, keyboard navigation |
|
|
337
331
|
| **Section** | Molecule | Content section wrapper | Responsive layout, variant support |
|
|
338
332
|
| **Sidebar** | Molecule | Sidebar navigation | Collapsible, responsive |
|
|
@@ -567,26 +561,30 @@ All components will automatically switch to their dark mode variants without any
|
|
|
567
561
|
- `default`: Main content
|
|
568
562
|
- `footer`: Footer content
|
|
569
563
|
|
|
570
|
-
###
|
|
564
|
+
### Navbar (built-in links)
|
|
565
|
+
|
|
566
|
+
Use `items` for a typed link list, or pass a `nav` snippet for custom markup. Set `embedded` when you only need the link row inside your own header.
|
|
571
567
|
|
|
572
568
|
```svelte
|
|
573
|
-
<
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
569
|
+
<Navbar
|
|
570
|
+
brand="My App"
|
|
571
|
+
brandHref="/"
|
|
572
|
+
items={navItems}
|
|
573
|
+
navVariant="header"
|
|
574
|
+
currentPath="/about"
|
|
575
|
+
onclick={(e) => console.log('Nav link', e)}
|
|
579
576
|
/>
|
|
580
|
-
```
|
|
581
577
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
- `items`: Navigation items array
|
|
585
|
-
- `currentPath`: Current active path
|
|
586
|
-
- `className`: Additional CSS classes
|
|
578
|
+
<Navbar embedded ariaLabel="Primary" navVariant="header" items={navItems} />
|
|
579
|
+
```
|
|
587
580
|
|
|
588
|
-
**
|
|
589
|
-
- `
|
|
581
|
+
**Props (selected):**
|
|
582
|
+
- `items`: `NavbarNavItem[]` — `label`, `href`, optional `icon` / `iconFilled`
|
|
583
|
+
- `navVariant`: `"header"` | `"sidebar"` — layout for built-in links
|
|
584
|
+
- `embedded`: render link list (or `nav` snippet) without full chrome
|
|
585
|
+
- `currentPath`: active item for built-in links
|
|
586
|
+
- `preventNavigation`: call `preventDefault` on link clicks
|
|
587
|
+
- `onclick`: invoked when a built-in link is clicked
|
|
590
588
|
|
|
591
589
|
### NavigationMenu Component
|
|
592
590
|
|
|
@@ -1336,7 +1334,7 @@ This is a **major breaking change** that affects how all components handle event
|
|
|
1336
1334
|
|
|
1337
1335
|
See the [Migration Guide](#migration-from-previous-versions) above for detailed examples.
|
|
1338
1336
|
|
|
1339
|
-
### v2.0.2
|
|
1337
|
+
### v2.0.2 — streamlined components
|
|
1340
1338
|
|
|
1341
1339
|
## Development Setup
|
|
1342
1340
|
|
|
@@ -1575,9 +1573,8 @@ See [VARIANTS.md](./docs/VARIANTS.md) for complete variant documentation.
|
|
|
1575
1573
|
|
|
1576
1574
|
## Support
|
|
1577
1575
|
|
|
1578
|
-
|
|
1576
|
+
Questions or bugs? [Open an issue on GitHub](https://github.com/sabnor/zabi-components/issues).
|
|
1579
1577
|
|
|
1580
1578
|
---
|
|
1581
1579
|
|
|
1582
|
-
|
|
1583
|
-
**Less is more** - Clean components that just work.
|
|
1580
|
+
MIT license · Svelte, TypeScript, and Tailwind CSS
|
package/THEME.md
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
# Zabi Components Theme Guide
|
|
2
|
+
|
|
3
|
+
Complete guide to using and customizing the Zabi Components theme system with Tailwind CSS v4.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Quick Start](#quick-start)
|
|
8
|
+
- [Theme Files](#theme-files)
|
|
9
|
+
- [Import Options](#import-options)
|
|
10
|
+
- [Theme Extension](#theme-extension)
|
|
11
|
+
- [Dark Mode](#dark-mode)
|
|
12
|
+
- [Color System](#color-system)
|
|
13
|
+
- [Customization Examples](#customization-examples)
|
|
14
|
+
- [Common Pitfalls](#common-pitfalls)
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### Basic Setup (Standalone)
|
|
19
|
+
|
|
20
|
+
If you don't have Tailwind CSS set up yet:
|
|
21
|
+
|
|
22
|
+
```css
|
|
23
|
+
/* app.css */
|
|
24
|
+
@import 'zabi-components/theme';
|
|
25
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Setup with Existing Tailwind
|
|
29
|
+
|
|
30
|
+
If you already have Tailwind CSS configured:
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
/* app.css */
|
|
34
|
+
@import "tailwindcss";
|
|
35
|
+
@import 'zabi-components/theme-only';
|
|
36
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### With Dark Mode
|
|
40
|
+
|
|
41
|
+
```css
|
|
42
|
+
/* app.css */
|
|
43
|
+
@import "tailwindcss";
|
|
44
|
+
@import 'zabi-components/theme-only';
|
|
45
|
+
@import 'zabi-components/theme-dark-only';
|
|
46
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Theme Files
|
|
50
|
+
|
|
51
|
+
Zabi Components provides multiple theme file variants:
|
|
52
|
+
|
|
53
|
+
| File | Description | Use Case |
|
|
54
|
+
|------|-------------|----------|
|
|
55
|
+
| `zabi-components/theme` | Full theme with Tailwind import | Standalone projects |
|
|
56
|
+
| `zabi-components/theme-only` | Theme without Tailwind import | Projects with existing Tailwind |
|
|
57
|
+
| `zabi-components/theme-dark` | Dark mode with Tailwind import | Standalone + dark mode |
|
|
58
|
+
| `zabi-components/theme-dark-only` | Dark mode without Tailwind import | Existing Tailwind + dark mode |
|
|
59
|
+
|
|
60
|
+
### Direct Path Imports
|
|
61
|
+
|
|
62
|
+
You can also import using direct paths:
|
|
63
|
+
|
|
64
|
+
```css
|
|
65
|
+
@import 'zabi-components/dist/zabi-components-theme.css';
|
|
66
|
+
@import 'zabi-components/dist/zabi-components-theme-only.css';
|
|
67
|
+
@import 'zabi-components/dist/zabi-components-theme-dark.css';
|
|
68
|
+
@import 'zabi-components/dist/zabi-components-theme-dark-only.css';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Import Options
|
|
72
|
+
|
|
73
|
+
### Option 1: Standalone (No Existing Tailwind)
|
|
74
|
+
|
|
75
|
+
Best for new projects or projects without Tailwind:
|
|
76
|
+
|
|
77
|
+
```css
|
|
78
|
+
@import 'zabi-components/theme';
|
|
79
|
+
@import 'zabi-components/theme-dark'; /* Optional: for dark mode */
|
|
80
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Pros:**
|
|
84
|
+
- Simple setup
|
|
85
|
+
- No Tailwind configuration needed
|
|
86
|
+
- Everything included
|
|
87
|
+
|
|
88
|
+
**Cons:**
|
|
89
|
+
- Less control over Tailwind configuration
|
|
90
|
+
- Slightly larger bundle if you need custom Tailwind config
|
|
91
|
+
|
|
92
|
+
### Option 2: With Existing Tailwind
|
|
93
|
+
|
|
94
|
+
Best for projects already using Tailwind CSS:
|
|
95
|
+
|
|
96
|
+
```css
|
|
97
|
+
@import "tailwindcss";
|
|
98
|
+
@import 'zabi-components/theme-only';
|
|
99
|
+
@import 'zabi-components/theme-dark-only'; /* Optional: for dark mode */
|
|
100
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Pros:**
|
|
104
|
+
- Full control over Tailwind configuration
|
|
105
|
+
- Can customize Tailwind before importing theme
|
|
106
|
+
- Smaller bundle (no duplicate Tailwind import)
|
|
107
|
+
|
|
108
|
+
**Cons:**
|
|
109
|
+
- Requires Tailwind setup
|
|
110
|
+
- Must import Tailwind first
|
|
111
|
+
|
|
112
|
+
## Theme Extension
|
|
113
|
+
|
|
114
|
+
You can extend the Zabi theme with your own customizations using additional `@theme` blocks:
|
|
115
|
+
|
|
116
|
+
```css
|
|
117
|
+
@import "tailwindcss";
|
|
118
|
+
@import 'zabi-components/theme-only';
|
|
119
|
+
|
|
120
|
+
/* Your custom theme extensions */
|
|
121
|
+
@theme {
|
|
122
|
+
/* Custom font families */
|
|
123
|
+
--font-family-title: 'Your Font', sans-serif;
|
|
124
|
+
--font-family-body: 'Another Font', sans-serif;
|
|
125
|
+
|
|
126
|
+
/* Custom colors */
|
|
127
|
+
--color-custom-primary: #ff0000;
|
|
128
|
+
--color-custom-secondary: #00ff00;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Important: Import Order
|
|
135
|
+
|
|
136
|
+
The import order is critical:
|
|
137
|
+
|
|
138
|
+
1. **First:** `@import "tailwindcss"` (if using theme-only)
|
|
139
|
+
2. **Second:** `@import 'zabi-components/theme-only'` (or theme)
|
|
140
|
+
3. **Third:** Your custom `@theme` block (extends zabi theme)
|
|
141
|
+
4. **Fourth:** `@import 'zabi-components/dist/zabi-components.css'` (uses the theme)
|
|
142
|
+
|
|
143
|
+
This order ensures:
|
|
144
|
+
- Tailwind is available for `theme()` function calls
|
|
145
|
+
- Zabi theme is defined first
|
|
146
|
+
- Your extensions override zabi defaults
|
|
147
|
+
- Components can use all theme values
|
|
148
|
+
|
|
149
|
+
## Dark Mode
|
|
150
|
+
|
|
151
|
+
Zabi Components supports dark mode through CSS custom properties in the `.dark` class.
|
|
152
|
+
|
|
153
|
+
### Automatic Dark Mode (System Preference)
|
|
154
|
+
|
|
155
|
+
```css
|
|
156
|
+
@import "tailwindcss";
|
|
157
|
+
@import 'zabi-components/theme-only';
|
|
158
|
+
@import 'zabi-components/theme-dark-only'; /* Supports system preference */
|
|
159
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The dark theme file uses `@media (prefers-color-scheme: dark)` to automatically switch based on system preference.
|
|
163
|
+
|
|
164
|
+
### Manual Dark Mode Toggle
|
|
165
|
+
|
|
166
|
+
For manual dark mode toggling, add the `.dark` class to your HTML element:
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
// Toggle dark mode
|
|
170
|
+
document.documentElement.classList.toggle('dark');
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The dark theme file also includes `.dark` class support, so both system preference and manual toggle work.
|
|
174
|
+
|
|
175
|
+
### Custom Dark Mode Colors
|
|
176
|
+
|
|
177
|
+
You can override dark mode colors in your custom theme:
|
|
178
|
+
|
|
179
|
+
```css
|
|
180
|
+
@import "tailwindcss";
|
|
181
|
+
@import 'zabi-components/theme-only';
|
|
182
|
+
@import 'zabi-components/theme-dark-only';
|
|
183
|
+
|
|
184
|
+
@theme {
|
|
185
|
+
/* Your light mode customizations */
|
|
186
|
+
--color-custom: #ff0000;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Custom dark mode overrides */
|
|
190
|
+
.dark {
|
|
191
|
+
--color-custom: #ff6666; /* Lighter red for dark mode */
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Color System
|
|
198
|
+
|
|
199
|
+
Zabi Components uses a semantic color system with the following color scales:
|
|
200
|
+
|
|
201
|
+
### Color Scales
|
|
202
|
+
|
|
203
|
+
- **Brand** - Primary brand colors (blue palette)
|
|
204
|
+
- **Citron** - Energetic/yellow colors
|
|
205
|
+
- **Pine** - Success/green colors
|
|
206
|
+
- **Iris** - Info/purple colors
|
|
207
|
+
|
|
208
|
+
Each scale includes shades from 50 (lightest) to 950 (darkest).
|
|
209
|
+
|
|
210
|
+
### Semantic Colors
|
|
211
|
+
|
|
212
|
+
Semantic colors map to specific use cases:
|
|
213
|
+
|
|
214
|
+
- `--color-background` - Main background
|
|
215
|
+
- `--color-headline` - Headings and titles
|
|
216
|
+
- `--color-body` - Body text
|
|
217
|
+
- `--color-description` - Secondary/description text
|
|
218
|
+
- `--color-caption` - Captions and labels
|
|
219
|
+
- `--color-border` - Borders and dividers
|
|
220
|
+
- `--color-surface-elevated` - Elevated surfaces (cards, modals)
|
|
221
|
+
- `--color-surface-level-0/1/2` - Surface hierarchy
|
|
222
|
+
- `--color-primary` - Primary actions
|
|
223
|
+
- `--color-secondary` - Secondary actions
|
|
224
|
+
- `--color-success` - Success states
|
|
225
|
+
- `--color-warning` - Warning states
|
|
226
|
+
- `--color-error` - Error states
|
|
227
|
+
|
|
228
|
+
### Using Colors
|
|
229
|
+
|
|
230
|
+
#### In CSS
|
|
231
|
+
|
|
232
|
+
```css
|
|
233
|
+
.my-element {
|
|
234
|
+
background-color: var(--color-primary);
|
|
235
|
+
color: var(--color-headline);
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### In Tailwind Classes
|
|
240
|
+
|
|
241
|
+
Zabi Components provides utility classes:
|
|
242
|
+
|
|
243
|
+
```html
|
|
244
|
+
<div class="bg-primary text-headline">
|
|
245
|
+
Primary background with headline text
|
|
246
|
+
</div>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### In Tailwind theme() Function
|
|
250
|
+
|
|
251
|
+
```css
|
|
252
|
+
.custom-class {
|
|
253
|
+
color: theme(colors.brand.600);
|
|
254
|
+
background: theme(colors.surface.elevated);
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Customization Examples
|
|
259
|
+
|
|
260
|
+
### Example 1: Custom Brand Colors
|
|
261
|
+
|
|
262
|
+
```css
|
|
263
|
+
@import "tailwindcss";
|
|
264
|
+
@import 'zabi-components/theme-only';
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Example 2: Custom Fonts
|
|
271
|
+
|
|
272
|
+
```css
|
|
273
|
+
@import "tailwindcss";
|
|
274
|
+
@import 'zabi-components/theme-only';
|
|
275
|
+
|
|
276
|
+
@theme {
|
|
277
|
+
--font-family-title: 'Inter', 'Helvetica', sans-serif;
|
|
278
|
+
--font-family-body: 'Inter', 'Helvetica', sans-serif;
|
|
279
|
+
--font-family-sans: 'Inter', ui-sans-serif, system-ui, sans-serif;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Example 3: Custom Semantic Colors
|
|
286
|
+
|
|
287
|
+
```css
|
|
288
|
+
@import "tailwindcss";
|
|
289
|
+
@import 'zabi-components/theme-only';
|
|
290
|
+
|
|
291
|
+
@theme {
|
|
292
|
+
/* Custom primary color */
|
|
293
|
+
--color-primary: theme(colors.purple.600);
|
|
294
|
+
--color-primary-weak: theme(colors.purple.700);
|
|
295
|
+
--color-primary-medium: theme(colors.purple.800);
|
|
296
|
+
--color-primary-strong: theme(colors.purple.900);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Example 4: Multiple Theme Variants
|
|
303
|
+
|
|
304
|
+
```css
|
|
305
|
+
@import "tailwindcss";
|
|
306
|
+
@import 'zabi-components/theme-only';
|
|
307
|
+
|
|
308
|
+
/* Default theme */
|
|
309
|
+
@theme {
|
|
310
|
+
--color-primary: theme(colors.blue.600);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* Custom variant */
|
|
314
|
+
.variant-custom {
|
|
315
|
+
--color-primary: theme(colors.purple.600);
|
|
316
|
+
--color-secondary: theme(colors.pink.600);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Common Pitfalls
|
|
323
|
+
|
|
324
|
+
### Pitfall 1: Wrong Import Order
|
|
325
|
+
|
|
326
|
+
**Wrong:**
|
|
327
|
+
```css
|
|
328
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
329
|
+
@import 'zabi-components/theme-only'; /* Too late! */
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Correct:**
|
|
333
|
+
```css
|
|
334
|
+
@import "tailwindcss";
|
|
335
|
+
@import 'zabi-components/theme-only';
|
|
336
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Pitfall 2: Double Tailwind Import
|
|
340
|
+
|
|
341
|
+
**Wrong:**
|
|
342
|
+
```css
|
|
343
|
+
@import "tailwindcss";
|
|
344
|
+
@import 'zabi-components/theme'; /* This also imports Tailwind! */
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Correct:**
|
|
348
|
+
```css
|
|
349
|
+
@import "tailwindcss";
|
|
350
|
+
@import 'zabi-components/theme-only'; /* Use theme-only */
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Pitfall 3: Theme Extension After Components
|
|
354
|
+
|
|
355
|
+
**Wrong:**
|
|
356
|
+
```css
|
|
357
|
+
@import 'zabi-components/theme-only';
|
|
358
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
359
|
+
@theme { /* Too late! */ }
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Correct:**
|
|
363
|
+
```css
|
|
364
|
+
@import "tailwindcss";
|
|
365
|
+
@import 'zabi-components/theme-only';
|
|
366
|
+
@theme { /* Extend before components */ }
|
|
367
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Pitfall 4: Missing Dark Mode Import
|
|
371
|
+
|
|
372
|
+
If you want dark mode support, you must import the dark theme file:
|
|
373
|
+
|
|
374
|
+
```css
|
|
375
|
+
@import "tailwindcss";
|
|
376
|
+
@import 'zabi-components/theme-only';
|
|
377
|
+
@import 'zabi-components/theme-dark-only'; /* Don't forget this! */
|
|
378
|
+
@import 'zabi-components/dist/zabi-components.css';
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Pitfall 5: Using theme() Before Theme is Defined
|
|
382
|
+
|
|
383
|
+
**Wrong:**
|
|
384
|
+
```css
|
|
385
|
+
@theme {
|
|
386
|
+
--color-custom: theme(colors.brand.600); /* Works */
|
|
387
|
+
--color-other: theme(colors.custom.500); /* Fails - custom not defined yet */
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Correct:**
|
|
392
|
+
```css
|
|
393
|
+
@theme {
|
|
394
|
+
--color-custom: theme(colors.brand.600);
|
|
395
|
+
/* Define custom colors first, then reference them */
|
|
396
|
+
--color-custom-500: #ff0000;
|
|
397
|
+
--color-other: var(--color-custom-500); /* Use var() for custom colors */
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## Troubleshooting
|
|
402
|
+
|
|
403
|
+
### Theme Variables Not Working
|
|
404
|
+
|
|
405
|
+
1. Check import order (theme must come before components CSS)
|
|
406
|
+
2. Verify you're using the correct theme file variant
|
|
407
|
+
3. Ensure Tailwind is imported if using `theme-only`
|
|
408
|
+
4. Check browser console for CSS errors
|
|
409
|
+
|
|
410
|
+
### Dark Mode Not Working
|
|
411
|
+
|
|
412
|
+
1. Ensure dark theme file is imported
|
|
413
|
+
2. Check that `.dark` class is applied to `<html>` or root element
|
|
414
|
+
3. Verify system preference detection (if using automatic mode)
|
|
415
|
+
4. Check that dark mode CSS custom properties are defined
|
|
416
|
+
|
|
417
|
+
### Colors Not Updating
|
|
418
|
+
|
|
419
|
+
1. Clear browser cache
|
|
420
|
+
2. Restart dev server
|
|
421
|
+
3. Check for CSS specificity issues
|
|
422
|
+
4. Verify theme extension is after zabi theme import
|
|
423
|
+
|
|
424
|
+
## Advanced Usage
|
|
425
|
+
|
|
426
|
+
### Programmatic Theme Switching
|
|
427
|
+
|
|
428
|
+
```javascript
|
|
429
|
+
// Switch to dark mode
|
|
430
|
+
document.documentElement.classList.add('dark');
|
|
431
|
+
|
|
432
|
+
// Switch to light mode
|
|
433
|
+
document.documentElement.classList.remove('dark');
|
|
434
|
+
|
|
435
|
+
// Toggle
|
|
436
|
+
document.documentElement.classList.toggle('dark');
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Theme with Svelte
|
|
440
|
+
|
|
441
|
+
```svelte
|
|
442
|
+
<script>
|
|
443
|
+
import { onMount } from 'svelte';
|
|
444
|
+
|
|
445
|
+
let isDark = $state(false);
|
|
446
|
+
|
|
447
|
+
onMount(() => {
|
|
448
|
+
// Check system preference
|
|
449
|
+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
450
|
+
isDark = prefersDark;
|
|
451
|
+
updateTheme();
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
function updateTheme() {
|
|
455
|
+
if (isDark) {
|
|
456
|
+
document.documentElement.classList.add('dark');
|
|
457
|
+
} else {
|
|
458
|
+
document.documentElement.classList.remove('dark');
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
</script>
|
|
462
|
+
|
|
463
|
+
<button on:click={() => { isDark = !isDark; updateTheme(); }}>
|
|
464
|
+
Toggle Theme
|
|
465
|
+
</button>
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## Additional Resources
|
|
469
|
+
|
|
470
|
+
- [Tailwind CSS v4 Documentation](https://tailwindcss.com/docs)
|
|
471
|
+
- [CSS Custom Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)
|
|
472
|
+
- [Zabi Components GitHub](https://github.com/zabi-components/zabi-components)
|
|
473
|
+
|