@stacksjs/components 0.2.92 → 0.2.94

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.
Files changed (188) hide show
  1. package/dist/{Sidebar-yb115a2w.stx → Sidebar-4hn7vw4n.stx} +18 -0
  2. package/dist/index.js +5 -5
  3. package/package.json +5 -6
  4. package/src/components/CodeBlock.stx +0 -54
  5. package/src/components/Footer.stx +0 -66
  6. package/src/components/Hero.stx +0 -25
  7. package/src/components/Installation.stx +0 -37
  8. package/src/components/index.ts +0 -4
  9. package/src/composables/index.ts +0 -4
  10. package/src/composables/useCopyCode.ts +0 -73
  11. package/src/composables/useDarkMode.ts +0 -100
  12. package/src/composables/useSEO.ts +0 -230
  13. package/src/composables/utilities/index.ts +0 -7
  14. package/src/composables/utilities/useClickOutside.ts +0 -72
  15. package/src/composables/utilities/useFocusTrap.ts +0 -159
  16. package/src/composables/utilities/useKeyboard.ts +0 -124
  17. package/src/composables/utilities/useLocalStorage.ts +0 -132
  18. package/src/composables/utilities/useMediaQuery.ts +0 -118
  19. package/src/index.ts +0 -99
  20. package/src/stx.d.ts +0 -4
  21. package/src/ui/accordion/Accordion.stx +0 -146
  22. package/src/ui/accordion/AccordionItem.stx +0 -37
  23. package/src/ui/accordion/index.ts +0 -47
  24. package/src/ui/audio/Audio.stx +0 -50
  25. package/src/ui/audio/README.md +0 -41
  26. package/src/ui/audio/index.ts +0 -13
  27. package/src/ui/auth/Login.stx +0 -161
  28. package/src/ui/auth/README.md +0 -142
  29. package/src/ui/auth/Signup.stx +0 -159
  30. package/src/ui/auth/TwoFactorChallenge.stx +0 -111
  31. package/src/ui/auth/index.ts +0 -32
  32. package/src/ui/avatar/Avatar.stx +0 -77
  33. package/src/ui/avatar/index.ts +0 -12
  34. package/src/ui/badge/Badge.stx +0 -62
  35. package/src/ui/badge/index.ts +0 -10
  36. package/src/ui/breadcrumb/Breadcrumb.stx +0 -79
  37. package/src/ui/breadcrumb/index.ts +0 -15
  38. package/src/ui/button/Button.stx +0 -74
  39. package/src/ui/button/README.md +0 -80
  40. package/src/ui/button/index.ts +0 -85
  41. package/src/ui/calendar/Calendar.stx +0 -189
  42. package/src/ui/calendar/README.md +0 -254
  43. package/src/ui/calendar/index.ts +0 -14
  44. package/src/ui/card/Card.stx +0 -68
  45. package/src/ui/card/index.ts +0 -13
  46. package/src/ui/checkbox/Checkbox.stx +0 -86
  47. package/src/ui/checkbox/index.ts +0 -16
  48. package/src/ui/combobox/Combobox.stx +0 -96
  49. package/src/ui/combobox/ComboboxButton.stx +0 -25
  50. package/src/ui/combobox/ComboboxInput.stx +0 -32
  51. package/src/ui/combobox/ComboboxOption.stx +0 -49
  52. package/src/ui/combobox/ComboboxOptions.stx +0 -16
  53. package/src/ui/combobox/README.md +0 -150
  54. package/src/ui/combobox/index.ts +0 -40
  55. package/src/ui/command-palette/CommandPalette.stx +0 -81
  56. package/src/ui/command-palette/CommandPaletteItem.stx +0 -27
  57. package/src/ui/command-palette/README.md +0 -42
  58. package/src/ui/command-palette/index.ts +0 -15
  59. package/src/ui/dialog/Dialog.stx +0 -41
  60. package/src/ui/dialog/DialogBackdrop.stx +0 -9
  61. package/src/ui/dialog/DialogDescription.stx +0 -11
  62. package/src/ui/dialog/DialogPanel.stx +0 -16
  63. package/src/ui/dialog/DialogTitle.stx +0 -11
  64. package/src/ui/dialog/README.md +0 -121
  65. package/src/ui/dialog/index.ts +0 -32
  66. package/src/ui/drawer/Drawer.stx +0 -120
  67. package/src/ui/drawer/README.md +0 -90
  68. package/src/ui/drawer/index.ts +0 -9
  69. package/src/ui/dropdown/Dropdown.stx +0 -82
  70. package/src/ui/dropdown/DropdownButton.stx +0 -29
  71. package/src/ui/dropdown/DropdownItem.stx +0 -35
  72. package/src/ui/dropdown/DropdownItems.stx +0 -18
  73. package/src/ui/dropdown/README.md +0 -114
  74. package/src/ui/dropdown/index.ts +0 -29
  75. package/src/ui/form/Form.stx +0 -95
  76. package/src/ui/form/index.ts +0 -67
  77. package/src/ui/heatmap/Heatmap.stx +0 -294
  78. package/src/ui/image/Image.stx +0 -165
  79. package/src/ui/image/README.md +0 -164
  80. package/src/ui/image/index.ts +0 -22
  81. package/src/ui/input/EmailInput.stx +0 -30
  82. package/src/ui/input/NumberInput.stx +0 -126
  83. package/src/ui/input/PasswordInput.stx +0 -143
  84. package/src/ui/input/SearchInput.stx +0 -44
  85. package/src/ui/input/TextInput.stx +0 -132
  86. package/src/ui/input/index.ts +0 -180
  87. package/src/ui/listbox/Listbox.stx +0 -101
  88. package/src/ui/listbox/ListboxButton.stx +0 -28
  89. package/src/ui/listbox/ListboxLabel.stx +0 -11
  90. package/src/ui/listbox/ListboxOption.stx +0 -49
  91. package/src/ui/listbox/ListboxOptions.stx +0 -16
  92. package/src/ui/listbox/README.md +0 -135
  93. package/src/ui/listbox/index.ts +0 -39
  94. package/src/ui/navigator/Navigator.stx +0 -113
  95. package/src/ui/navigator/README.md +0 -352
  96. package/src/ui/navigator/index.ts +0 -20
  97. package/src/ui/notification/Notification.stx +0 -117
  98. package/src/ui/notification/README.md +0 -114
  99. package/src/ui/notification/index.ts +0 -12
  100. package/src/ui/pagination/Pagination.stx +0 -150
  101. package/src/ui/pagination/index.ts +0 -11
  102. package/src/ui/payment/Checkout.stx +0 -31
  103. package/src/ui/payment/DefaultPaymentMethod.stx +0 -62
  104. package/src/ui/payment/PaymentMethods.stx +0 -104
  105. package/src/ui/payment/README.md +0 -345
  106. package/src/ui/payment/SubscriptionCheckout.stx +0 -323
  107. package/src/ui/payment/index.ts +0 -59
  108. package/src/ui/popover/Popover.stx +0 -60
  109. package/src/ui/popover/PopoverButton.stx +0 -29
  110. package/src/ui/popover/PopoverPanel.stx +0 -23
  111. package/src/ui/popover/README.md +0 -91
  112. package/src/ui/popover/index.ts +0 -22
  113. package/src/ui/portal/Portal.stx +0 -57
  114. package/src/ui/portal/index.ts +0 -6
  115. package/src/ui/progress/Progress.stx +0 -131
  116. package/src/ui/progress/index.ts +0 -12
  117. package/src/ui/radio/Radio.stx +0 -77
  118. package/src/ui/radio/index.ts +0 -15
  119. package/src/ui/radio-group/README.md +0 -139
  120. package/src/ui/radio-group/RadioGroup.stx +0 -60
  121. package/src/ui/radio-group/RadioGroupDescription.stx +0 -11
  122. package/src/ui/radio-group/RadioGroupLabel.stx +0 -11
  123. package/src/ui/radio-group/RadioGroupOption.stx +0 -58
  124. package/src/ui/radio-group/index.ts +0 -30
  125. package/src/ui/select/README.md +0 -180
  126. package/src/ui/select/Select.stx +0 -82
  127. package/src/ui/select/index.ts +0 -21
  128. package/src/ui/sidebar/Sidebar.stx +0 -458
  129. package/src/ui/sidebar/SidebarFooter.stx +0 -71
  130. package/src/ui/sidebar/SidebarHeader.stx +0 -103
  131. package/src/ui/sidebar/SidebarItem.stx +0 -86
  132. package/src/ui/sidebar/SidebarSection.stx +0 -83
  133. package/src/ui/sidebar/index.ts +0 -153
  134. package/src/ui/sidebar/themes.ts +0 -240
  135. package/src/ui/skeleton/Skeleton.stx +0 -48
  136. package/src/ui/skeleton/index.ts +0 -11
  137. package/src/ui/spinner/Spinner.stx +0 -109
  138. package/src/ui/spinner/index.ts +0 -9
  139. package/src/ui/stepper/README.md +0 -36
  140. package/src/ui/stepper/Stepper.stx +0 -17
  141. package/src/ui/stepper/StepperStep.stx +0 -57
  142. package/src/ui/stepper/index.ts +0 -19
  143. package/src/ui/storage/README.md +0 -193
  144. package/src/ui/storage/index.ts +0 -347
  145. package/src/ui/switch/README.md +0 -114
  146. package/src/ui/switch/Switch.stx +0 -72
  147. package/src/ui/switch/index.ts +0 -10
  148. package/src/ui/table/README.md +0 -39
  149. package/src/ui/table/Table.stx +0 -14
  150. package/src/ui/table/TableBody.stx +0 -10
  151. package/src/ui/table/TableCell.stx +0 -10
  152. package/src/ui/table/TableHead.stx +0 -10
  153. package/src/ui/table/TableHeader.stx +0 -20
  154. package/src/ui/table/TableRow.stx +0 -11
  155. package/src/ui/table/index.ts +0 -35
  156. package/src/ui/tabs/TabPanel.stx +0 -25
  157. package/src/ui/tabs/Tabs.stx +0 -202
  158. package/src/ui/tabs/index.ts +0 -50
  159. package/src/ui/teleport/Teleport.stx +0 -65
  160. package/src/ui/teleport/index.ts +0 -7
  161. package/src/ui/textarea/Textarea.stx +0 -108
  162. package/src/ui/textarea/index.ts +0 -20
  163. package/src/ui/tooltip/Tooltip.stx +0 -71
  164. package/src/ui/tooltip/index.ts +0 -10
  165. package/src/ui/transition/README.md +0 -30
  166. package/src/ui/transition/Transition.stx +0 -102
  167. package/src/ui/transition/index.ts +0 -25
  168. package/src/ui/video/README.md +0 -47
  169. package/src/ui/video/Video.stx +0 -45
  170. package/src/ui/video/index.ts +0 -16
  171. package/src/ui/virtual-list/VirtualList.stx +0 -67
  172. package/src/ui/virtual-list/index.ts +0 -10
  173. package/src/ui/virtual-table/VirtualTable.stx +0 -103
  174. package/src/ui/virtual-table/index.ts +0 -21
  175. package/src/utils/PROP_VALIDATION.md +0 -458
  176. package/src/utils/THEME_SYSTEM.md +0 -702
  177. package/src/utils/accessibility.ts +0 -841
  178. package/src/utils/animation/easing.ts +0 -368
  179. package/src/utils/animation/helpers.ts +0 -223
  180. package/src/utils/animation/index.ts +0 -5
  181. package/src/utils/animation/keyframes.ts +0 -230
  182. package/src/utils/error-handling.ts +0 -475
  183. package/src/utils/highlighter.ts +0 -93
  184. package/src/utils/i18n.ts +0 -634
  185. package/src/utils/keep-alive.ts +0 -819
  186. package/src/utils/lazy-loading.ts +0 -530
  187. package/src/utils/prop-validation.ts +0 -478
  188. package/src/utils/theme.ts +0 -626
@@ -1,702 +0,0 @@
1
- # Theme System
2
-
3
- A comprehensive theming system for customizing colors, typography, spacing, and component styles across the entire component library.
4
-
5
- ## Quick Start
6
-
7
- ```ts
8
- import { createTheme, applyTheme } from '@stacksjs/components'
9
-
10
- // Create a custom theme
11
- const myTheme = createTheme({
12
- colors: {
13
- primary: '#3b82f6',
14
- secondary: '#8b5cf6'
15
- }
16
- })
17
-
18
- // Apply the theme
19
- applyTheme(myTheme)
20
- ```
21
-
22
- ## Table of Contents
23
-
24
- - [Core Concepts](#core-concepts)
25
- - [Theme Structure](#theme-structure)
26
- - [Creating Themes](#creating-themes)
27
- - [Applying Themes](#applying-themes)
28
- - [Using Themes](#using-themes)
29
- - [Theme Presets](#theme-presets)
30
- - [CSS Custom Properties](#css-custom-properties)
31
- - [Advanced Usage](#advanced-usage)
32
-
33
- ## Core Concepts
34
-
35
- The theme system uses CSS custom properties (CSS variables) to provide real-time theming without recompiling styles. All theme values are converted to CSS variables and applied to the `:root` element (or a specific container).
36
-
37
- ### Benefits
38
-
39
- - **No compilation required** - Changes apply immediately
40
- - **Runtime switching** - Switch themes dynamically
41
- - **Scoped themes** - Apply different themes to different sections
42
- - **Type-safe** - Full TypeScript support
43
- - **Extendable** - Easy to add custom properties
44
-
45
- ## Theme Structure
46
-
47
- A complete theme object has the following structure:
48
-
49
- ```ts
50
- interface Theme {
51
- colors: ColorPalette
52
- typography: Typography
53
- spacing: Spacing
54
- borderRadius: BorderRadius
55
- shadows: Shadows
56
- components?: ComponentOverrides
57
- }
58
- ```
59
-
60
- ### Colors
61
-
62
- ```ts
63
- colors: {
64
- primary: '#3b82f6', // Primary brand color
65
- secondary: '#8b5cf6', // Secondary brand color
66
- success: '#10b981', // Success states
67
- warning: '#f59e0b', // Warning states
68
- danger: '#ef4444', // Error/danger states
69
- info: '#06b6d4', // Informational states
70
- gray: '#6b7280', // Neutral color
71
- white: '#ffffff', // White
72
- black: '#000000', // Black
73
- }
74
- ```
75
-
76
- ### Typography
77
-
78
- ```ts
79
- typography: {
80
- fontFamily: {
81
- sans: 'Inter, system-ui, sans-serif',
82
- serif: 'Georgia, serif',
83
- mono: 'Monaco, monospace'
84
- },
85
- fontSize: {
86
- xs: '0.75rem',
87
- sm: '0.875rem',
88
- base: '1rem',
89
- lg: '1.125rem',
90
- xl: '1.25rem',
91
- '2xl': '1.5rem',
92
- '3xl': '1.875rem',
93
- '4xl': '2.25rem'
94
- },
95
- fontWeight: {
96
- light: '300',
97
- normal: '400',
98
- medium: '500',
99
- semibold: '600',
100
- bold: '700'
101
- },
102
- lineHeight: {
103
- tight: '1.25',
104
- normal: '1.5',
105
- relaxed: '1.75'
106
- }
107
- }
108
- ```
109
-
110
- ### Spacing
111
-
112
- ```ts
113
- spacing: {
114
- xs: '0.25rem',
115
- sm: '0.5rem',
116
- md: '1rem',
117
- lg: '1.5rem',
118
- xl: '2rem',
119
- '2xl': '3rem',
120
- '3xl': '4rem',
121
- '4xl': '6rem'
122
- }
123
- ```
124
-
125
- ### Border Radius
126
-
127
- ```ts
128
- borderRadius: {
129
- none: '0',
130
- sm: '0.125rem',
131
- md: '0.375rem',
132
- lg: '0.5rem',
133
- full: '9999px'
134
- }
135
- ```
136
-
137
- ### Shadows
138
-
139
- ```ts
140
- shadows: {
141
- sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
142
- md: '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
143
- lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
144
- xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1)',
145
- '2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
146
- none: 'none'
147
- }
148
- ```
149
-
150
- ### Component Overrides
151
-
152
- ```ts
153
- components: {
154
- button: {
155
- borderRadius: '0.375rem',
156
- padding: '0.5rem 1rem',
157
- fontSize: '0.875rem',
158
- fontWeight: '500'
159
- },
160
- input: {
161
- borderRadius: '0.375rem',
162
- padding: '0.5rem 0.75rem',
163
- fontSize: '0.875rem',
164
- borderWidth: '1px'
165
- },
166
- card: {
167
- borderRadius: '0.5rem',
168
- padding: '1.5rem',
169
- shadow: '0 1px 3px 0 rgba(0, 0, 0, 0.1)'
170
- }
171
- }
172
- ```
173
-
174
- ## Creating Themes
175
-
176
- ### Basic Theme
177
-
178
- ```ts
179
- import { createTheme } from '@stacksjs/components'
180
-
181
- const myTheme = createTheme({
182
- colors: {
183
- primary: '#3b82f6',
184
- secondary: '#8b5cf6'
185
- }
186
- })
187
- ```
188
-
189
- ### Complete Custom Theme
190
-
191
- ```ts
192
- const customTheme = createTheme({
193
- colors: {
194
- primary: '#3b82f6',
195
- secondary: '#8b5cf6',
196
- success: '#10b981',
197
- warning: '#f59e0b',
198
- danger: '#ef4444',
199
- info: '#06b6d4'
200
- },
201
- typography: {
202
- fontFamily: {
203
- sans: 'Inter, sans-serif',
204
- mono: 'Fira Code, monospace'
205
- },
206
- fontSize: {
207
- base: '1rem',
208
- lg: '1.25rem'
209
- }
210
- },
211
- spacing: {
212
- md: '1rem',
213
- lg: '2rem'
214
- },
215
- borderRadius: {
216
- md: '0.5rem',
217
- lg: '1rem'
218
- },
219
- components: {
220
- button: {
221
- borderRadius: '0.5rem',
222
- padding: '0.75rem 1.5rem'
223
- }
224
- }
225
- })
226
- ```
227
-
228
- ### Brand Theme
229
-
230
- ```ts
231
- const brandTheme = createTheme({
232
- colors: {
233
- primary: '#ff6b6b', // Your brand color
234
- secondary: '#4ecdc4',
235
- success: '#95e1d3',
236
- danger: '#ff6b6b'
237
- },
238
- typography: {
239
- fontFamily: {
240
- sans: 'Montserrat, sans-serif'
241
- },
242
- fontWeight: {
243
- normal: '400',
244
- bold: '700'
245
- }
246
- },
247
- borderRadius: {
248
- md: '1rem',
249
- lg: '2rem'
250
- }
251
- })
252
- ```
253
-
254
- ## Applying Themes
255
-
256
- ### Apply to Entire Application
257
-
258
- ```ts
259
- import { applyTheme, createTheme } from '@stacksjs/components'
260
-
261
- const theme = createTheme({
262
- colors: { primary: '#3b82f6' }
263
- })
264
-
265
- applyTheme(theme)
266
- ```
267
-
268
- ### Apply to Specific Container
269
-
270
- ```ts
271
- const container = document.getElementById('my-container')
272
- applyTheme(theme, container)
273
- ```
274
-
275
- ### Dynamic Theme Switching
276
-
277
- ```ts
278
- const themes = {
279
- light: createTheme({
280
- colors: {
281
- primary: '#3b82f6',
282
- white: '#ffffff',
283
- black: '#000000'
284
- }
285
- }),
286
- dark: createTheme({
287
- colors: {
288
- primary: '#60a5fa',
289
- white: '#1f2937',
290
- black: '#f9fafb'
291
- }
292
- })
293
- }
294
-
295
- function switchTheme(themeName: 'light' | 'dark') {
296
- applyTheme(themes[themeName])
297
- }
298
- ```
299
-
300
- ## Using Themes
301
-
302
- ### In JavaScript/TypeScript
303
-
304
- ```ts
305
- import { useTheme, getThemeValue } from '@stacksjs/components'
306
-
307
- // Get entire theme object
308
- const theme = useTheme()
309
- console.log(theme.colors.primary)
310
-
311
- // Get specific value by path
312
- const primaryColor = getThemeValue('colors.primary')
313
- const baseFontSize = getThemeValue('typography.fontSize.base')
314
- ```
315
-
316
- ### In CSS
317
-
318
- After applying a theme, use CSS custom properties:
319
-
320
- ```css
321
- .my-component {
322
- color: var(--color-primary);
323
- font-family: var(--font-sans);
324
- font-size: var(--text-base);
325
- padding: var(--spacing-md);
326
- border-radius: var(--radius-md);
327
- box-shadow: var(--shadow-md);
328
- }
329
-
330
- .my-button {
331
- border-radius: var(--button-border-radius);
332
- padding: var(--button-padding);
333
- font-size: var(--button-font-size);
334
- }
335
- ```
336
-
337
- ### In Inline Styles
338
-
339
- ```html
340
- <div style="color: var(--color-primary); padding: var(--spacing-lg)">
341
- Themed content
342
- </div>
343
- ```
344
-
345
- ## Theme Presets
346
-
347
- The library includes several predefined theme presets:
348
-
349
- ### Default (Blue)
350
-
351
- ```ts
352
- import { themePresets, applyTheme } from '@stacksjs/components'
353
-
354
- applyTheme(themePresets.default)
355
- ```
356
-
357
- ### Purple
358
-
359
- ```ts
360
- applyTheme(themePresets.purple)
361
- ```
362
-
363
- ### Green
364
-
365
- ```ts
366
- applyTheme(themePresets.green)
367
- ```
368
-
369
- ### Orange
370
-
371
- ```ts
372
- applyTheme(themePresets.orange)
373
- ```
374
-
375
- ### Dark
376
-
377
- ```ts
378
- applyTheme(themePresets.dark)
379
- ```
380
-
381
- ### Minimal
382
-
383
- Reduced shadows and border radius for a cleaner look:
384
-
385
- ```ts
386
- applyTheme(themePresets.minimal)
387
- ```
388
-
389
- ## CSS Custom Properties
390
-
391
- All theme values are exposed as CSS custom properties:
392
-
393
- ### Color Variables
394
-
395
- ```css
396
- --color-primary
397
- --color-secondary
398
- --color-success
399
- --color-warning
400
- --color-danger
401
- --color-info
402
- --color-gray
403
- --color-white
404
- --color-black
405
- ```
406
-
407
- ### Typography Variables
408
-
409
- ```css
410
- --font-sans
411
- --font-serif
412
- --font-mono
413
- --text-xs
414
- --text-sm
415
- --text-base
416
- --text-lg
417
- --text-xl
418
- --text-2xl
419
- --text-3xl
420
- --text-4xl
421
- --font-weight-light
422
- --font-weight-normal
423
- --font-weight-medium
424
- --font-weight-semibold
425
- --font-weight-bold
426
- --leading-tight
427
- --leading-normal
428
- --leading-relaxed
429
- ```
430
-
431
- ### Spacing Variables
432
-
433
- ```css
434
- --spacing-xs
435
- --spacing-sm
436
- --spacing-md
437
- --spacing-lg
438
- --spacing-xl
439
- --spacing-2xl
440
- --spacing-3xl
441
- --spacing-4xl
442
- ```
443
-
444
- ### Border Radius Variables
445
-
446
- ```css
447
- --radius-none
448
- --radius-sm
449
- --radius-md
450
- --radius-lg
451
- --radius-full
452
- ```
453
-
454
- ### Shadow Variables
455
-
456
- ```css
457
- --shadow-sm
458
- --shadow-md
459
- --shadow-lg
460
- --shadow-xl
461
- --shadow-2xl
462
- --shadow-none
463
- ```
464
-
465
- ### Component Variables
466
-
467
- ```css
468
- --button-border-radius
469
- --button-padding
470
- --button-font-size
471
- --button-font-weight
472
-
473
- --input-border-radius
474
- --input-padding
475
- --input-font-size
476
- --input-border-width
477
-
478
- --card-border-radius
479
- --card-padding
480
- --card-shadow
481
- ```
482
-
483
- ## Advanced Usage
484
-
485
- ### Generate CSS File
486
-
487
- ```ts
488
- import { generateThemeCSS, createTheme } from '@stacksjs/components'
489
-
490
- const theme = createTheme({
491
- colors: { primary: '#3b82f6' }
492
- })
493
-
494
- const cssContent = generateThemeCSS(theme)
495
- // Write to file or inject into page
496
- ```
497
-
498
- ### Extend Existing Theme
499
-
500
- ```ts
501
- import { getTheme, createTheme } from '@stacksjs/components'
502
-
503
- const currentTheme = getTheme()
504
- const extendedTheme = createTheme({
505
- ...currentTheme,
506
- colors: {
507
- ...currentTheme.colors,
508
- primary: '#ff6b6b' // Override just primary color
509
- }
510
- })
511
- ```
512
-
513
- ### Theme with CSS-in-JS
514
-
515
- ```ts
516
- import { useTheme } from '@stacksjs/components'
517
-
518
- function MyComponent() {
519
- const theme = useTheme()
520
-
521
- const styles = {
522
- container: {
523
- backgroundColor: theme.colors.primary,
524
- padding: theme.spacing.lg,
525
- borderRadius: theme.borderRadius.md
526
- }
527
- }
528
-
529
- return <div style={styles.container}>Themed content</div>
530
- }
531
- ```
532
-
533
- ### Scoped Theme Sections
534
-
535
- ```ts
536
- const headerTheme = createTheme({
537
- colors: { primary: '#3b82f6' }
538
- })
539
-
540
- const footerTheme = createTheme({
541
- colors: { primary: '#8b5cf6' }
542
- })
543
-
544
- applyTheme(headerTheme, document.getElementById('header'))
545
- applyTheme(footerTheme, document.getElementById('footer'))
546
- ```
547
-
548
- ### Responsive Themes
549
-
550
- ```ts
551
- function applyResponsiveTheme() {
552
- const isMobile = window.matchMedia('(max-width: 768px)').matches
553
-
554
- const theme = createTheme({
555
- typography: {
556
- fontSize: {
557
- base: isMobile ? '0.875rem' : '1rem',
558
- lg: isMobile ? '1rem' : '1.125rem'
559
- }
560
- },
561
- spacing: {
562
- md: isMobile ? '0.75rem' : '1rem',
563
- lg: isMobile ? '1rem' : '1.5rem'
564
- }
565
- })
566
-
567
- applyTheme(theme)
568
- }
569
-
570
- window.addEventListener('resize', applyResponsiveTheme)
571
- ```
572
-
573
- ### Theme Persistence
574
-
575
- ```ts
576
- import { createTheme, applyTheme } from '@stacksjs/components'
577
-
578
- function saveTheme(theme: Theme) {
579
- localStorage.setItem('app-theme', JSON.stringify(theme))
580
- }
581
-
582
- function loadTheme(): Theme | null {
583
- const saved = localStorage.getItem('app-theme')
584
- return saved ? JSON.parse(saved) : null
585
- }
586
-
587
- // On app init
588
- const savedTheme = loadTheme()
589
- if (savedTheme) {
590
- applyTheme(savedTheme)
591
- }
592
-
593
- // When user changes theme
594
- const newTheme = createTheme({ colors: { primary: '#3b82f6' } })
595
- applyTheme(newTheme)
596
- saveTheme(newTheme)
597
- ```
598
-
599
- ## Examples
600
-
601
- ### E-commerce Theme
602
-
603
- ```ts
604
- const ecommerceTheme = createTheme({
605
- colors: {
606
- primary: '#f97316', // Orange for CTAs
607
- secondary: '#0ea5e9', // Blue for links
608
- success: '#10b981', // Green for success
609
- danger: '#ef4444' // Red for errors
610
- },
611
- typography: {
612
- fontFamily: {
613
- sans: 'Poppins, sans-serif'
614
- }
615
- },
616
- borderRadius: {
617
- md: '0.5rem',
618
- lg: '1rem'
619
- },
620
- components: {
621
- button: {
622
- borderRadius: '0.5rem',
623
- padding: '0.75rem 1.5rem',
624
- fontWeight: '600'
625
- }
626
- }
627
- })
628
- ```
629
-
630
- ### SaaS Dashboard Theme
631
-
632
- ```ts
633
- const dashboardTheme = createTheme({
634
- colors: {
635
- primary: '#3b82f6',
636
- secondary: '#6366f1',
637
- gray: '#6b7280'
638
- },
639
- typography: {
640
- fontFamily: {
641
- sans: 'Inter, sans-serif',
642
- mono: 'JetBrains Mono, monospace'
643
- },
644
- fontSize: {
645
- xs: '0.75rem',
646
- sm: '0.875rem',
647
- base: '0.875rem' // Smaller base for dashboards
648
- }
649
- },
650
- spacing: {
651
- sm: '0.5rem',
652
- md: '1rem',
653
- lg: '1.5rem'
654
- },
655
- shadows: {
656
- md: '0 1px 3px 0 rgba(0, 0, 0, 0.1)',
657
- lg: '0 4px 6px -1px rgba(0, 0, 0, 0.1)'
658
- }
659
- })
660
- ```
661
-
662
- ### Marketing Site Theme
663
-
664
- ```ts
665
- const marketingTheme = createTheme({
666
- colors: {
667
- primary: '#8b5cf6',
668
- secondary: '#ec4899'
669
- },
670
- typography: {
671
- fontFamily: {
672
- sans: 'Montserrat, sans-serif',
673
- serif: 'Playfair Display, serif'
674
- },
675
- fontSize: {
676
- '2xl': '2rem',
677
- '3xl': '2.5rem',
678
- '4xl': '3.5rem'
679
- }
680
- },
681
- borderRadius: {
682
- lg: '1rem',
683
- full: '9999px'
684
- },
685
- shadows: {
686
- lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
687
- xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1)',
688
- '2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)'
689
- }
690
- })
691
- ```
692
-
693
- ## Best Practices
694
-
695
- 1. **Start with presets** - Use theme presets as a starting point
696
- 2. **Override selectively** - Only customize what you need
697
- 3. **Use semantic colors** - Stick to primary, secondary, success, etc.
698
- 4. **Maintain contrast** - Ensure text is readable on backgrounds
699
- 5. **Test responsiveness** - Check themes on different screen sizes
700
- 6. **Document custom themes** - Keep track of your theme decisions
701
- 7. **Use CSS variables** - Leverage the generated CSS custom properties
702
- 8. **Type safety** - Use TypeScript for theme definitions