@projectdiscoveryio/design-system 1.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 ADDED
@@ -0,0 +1,841 @@
1
+ # @pd-design/system
2
+
3
+ Production-grade design system with adapter layer support. Built for teams who need a flexible, type-safe component library that can work with different UI engines without changing application code.
4
+
5
+ ## About PD Design System
6
+
7
+ - **3 Lines to Get Started** - No complex setup, just works
8
+ - **System Mode Built-In** - Automatically follows OS dark/light preference
9
+ - **Zero-Config Persistence** - Pass `storageKey` prop, localStorage sync is automatic
10
+ - **Cross-Tab Sync** - Theme changes sync across browser tabs instantly
11
+ - **Type-Safe** - Full TypeScript with autocomplete for all props
12
+ - **Accessible** - WCAG 2.1 AA compliant, built on Radix UI
13
+ - **Style Isolation** - Works with Tailwind, MUI, AntD, Bootstrap, or plain CSS
14
+ - **Extensible Adapters** - Switch between UI engines (shadcn, Material, AntD, etc.)
15
+ - **Flexible Theming** - Base theme with support for custom brand themes
16
+ - **1000+ Icons** - All Lucide icons with TypeScript autocomplete
17
+
18
+ ## Table of Contents
19
+
20
+ - [Installation](#installation)
21
+ - [Quick Start](#quick-start)
22
+ - [Implementation Guide](#implementation-guide)
23
+ - [Design System Architecture](#design-system-architecture)
24
+ - [Adapters](#adapters)
25
+ - [Theming System](#theming-system)
26
+ - [Mode System](#mode-system)
27
+ - [Component Usage](#component-usage)
28
+ - [API Reference](#api-reference)
29
+ - [Advanced Usage](#advanced-usage)
30
+
31
+ ## Installation
32
+
33
+ Install the package using npm, yarn, or pnpm:
34
+
35
+ ```bash
36
+ npm install @pd-design/system
37
+ # or
38
+ yarn add @pd-design/system
39
+ # or
40
+ pnpm add @pd-design/system
41
+ ```
42
+
43
+ ### Peer Dependencies
44
+
45
+ The design system requires React 18+:
46
+
47
+ ```bash
48
+ npm install react@^18.0.0 react-dom@^18.0.0
49
+ ```
50
+
51
+ ## Quick Start
52
+
53
+ Get started in 3 simple steps:
54
+
55
+ ### Step 1: Import Styles
56
+
57
+ Import the design system styles in your application entry point (e.g., `main.tsx`, `App.tsx`, or `_app.tsx`):
58
+
59
+ ```tsx
60
+ import '@pd-design/system/styles.css';
61
+ ```
62
+
63
+ ### Step 2: Wrap Your App with ThemeProvider
64
+
65
+ Wrap your application with `ThemeProvider` to enable theming and component functionality:
66
+
67
+ ```tsx
68
+ import { ThemeProvider } from '@pd-design/system';
69
+
70
+ function App() {
71
+ return (
72
+ <ThemeProvider>
73
+ {/* Your application components */}
74
+ </ThemeProvider>
75
+ );
76
+ }
77
+ ```
78
+
79
+ **That's it!** The `ThemeProvider` uses sensible defaults:
80
+ - **Adapter**: `'shadcn'` (Radix UI + Tailwind CSS)
81
+ - **Theme**: `'base'` (Neutral, professional design)
82
+ - **Mode**: `'system'` (Automatically follows OS dark/light preference)
83
+
84
+ #### Optional Configuration
85
+
86
+ You can customize the theme, mode, adapter, and enable persistence:
87
+
88
+ ```tsx
89
+ import { ThemeProvider } from '@pd-design/system';
90
+
91
+ function App() {
92
+ return (
93
+ <ThemeProvider
94
+ adapter="shadcn" // Optional: 'shadcn' | 'material' (default: 'shadcn')
95
+ theme="base" // Optional: 'base' | 'brand' (default: 'base')
96
+ mode="system" // Optional: 'light' | 'dark' | 'system' (default: 'system')
97
+ storageKey="my-app-theme" // Optional: enables localStorage persistence
98
+ >
99
+ {/* Your application components */}
100
+ </ThemeProvider>
101
+ );
102
+ }
103
+ ```
104
+
105
+ ### Step 3: Use Components
106
+
107
+ Now you can use any component from the design system:
108
+
109
+ ```tsx
110
+ import { Button } from '@pd-design/system';
111
+
112
+ function MyComponent() {
113
+ return (
114
+ <Button>
115
+ Click me
116
+ </Button>
117
+ );
118
+ }
119
+ ```
120
+
121
+ That's it! 🎉 The `ThemeProvider` automatically handles:
122
+ - **System preference detection** - Follows OS dark/light mode
123
+ - **localStorage persistence** - Remembers user's theme choice (when `storageKey` is provided)
124
+ - **Cross-tab sync** - Theme changes sync across browser tabs
125
+ - **Class management** - Automatically adds `pd-root` and `pd-dark` classes
126
+ - **CSS variables** - Sets all theme variables automatically
127
+
128
+ ## Implementation Guide
129
+
130
+ ### Complete Example: Using Button Component
131
+
132
+ Here's a complete example showing how to set up and use the Button component:
133
+
134
+ ```tsx
135
+ import { ThemeProvider, Button, useTheme } from '@pd-design/system';
136
+ import '@pd-design/system/styles.css';
137
+
138
+ function App() {
139
+ return (
140
+ <ThemeProvider>
141
+ <MyComponent />
142
+ </ThemeProvider>
143
+ );
144
+ }
145
+
146
+ function MyComponent() {
147
+ const { config, setConfig } = useTheme();
148
+
149
+ return (
150
+ <div>
151
+ {/* Basic Button */}
152
+ <Button variant="primary" size="md">
153
+ Primary Button
154
+ </Button>
155
+
156
+ {/* Button with Icons (must be valid Lucide icons - see https://lucide.dev/icons/) */}
157
+ <Button
158
+ variant="secondary"
159
+ size="lg"
160
+ startIcon="Download"
161
+ endIcon="ArrowRight"
162
+ >
163
+ Download File
164
+ </Button>
165
+
166
+ {/* Button States */}
167
+ <Button variant="primary" loading={true}>
168
+ Loading...
169
+ </Button>
170
+
171
+ <Button variant="primary" disabled={true}>
172
+ Disabled
173
+ </Button>
174
+
175
+ {/* Button Variants */}
176
+ <Button variant="primary">Primary</Button>
177
+ <Button variant="secondary">Secondary</Button>
178
+ <Button variant="ghost">Ghost</Button>
179
+ <Button variant="destructive">Delete</Button>
180
+
181
+ {/* Button Sizes */}
182
+ <Button size="sm">Small</Button>
183
+ <Button size="md">Medium</Button>
184
+ <Button size="lg">Large</Button>
185
+
186
+ {/* Theme Toggle Example */}
187
+ <Button onClick={() => {
188
+ const nextMode = config.mode === 'dark' ? 'light' : 'dark';
189
+ setConfig({ mode: nextMode });
190
+ }}>
191
+ Switch to {config.mode === 'dark' ? 'Light' : 'Dark'} Mode
192
+ </Button>
193
+ </div>
194
+ );
195
+ }
196
+ ```
197
+
198
+ ### Button Component API
199
+
200
+ The Button component accepts the following props:
201
+
202
+ | Prop | Type | Default | Description |
203
+ |------|------|---------|-------------|
204
+ | `variant` | `'primary' \| 'secondary' \| 'ghost' \| 'destructive'` | `'primary'` | Visual style variant |
205
+ | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button size |
206
+ | `loading` | `boolean` | `false` | Shows loading state |
207
+ | `disabled` | `boolean` | `false` | Disables the button |
208
+ | `fullWidth` | `boolean` | `false` | Makes button full width |
209
+ | `startIcon` | `string` | `-` | Icon name to show before text (must be a valid [Lucide icon](https://lucide.dev/icons/)) |
210
+ | `endIcon` | `string` | `-` | Icon name to show after text (must be a valid [Lucide icon](https://lucide.dev/icons/)) |
211
+ | `loadingText` | `string` | `-` | Text to show during loading state |
212
+ | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Button type for forms |
213
+ | `href` | `string` | `-` | Renders as link when provided |
214
+ | `target` | `'_blank' \| '_self' \| '_parent' \| '_top'` | `undefined` | Link target (when href is provided) |
215
+ | `asChild` | `boolean` | `false` | Render as child element (Radix UI pattern) |
216
+
217
+ **Example Usage:**
218
+
219
+ ```tsx
220
+ // Form submission button
221
+ <form onSubmit={handleSubmit}>
222
+ <Button type="submit" variant="primary">
223
+ Submit Form
224
+ </Button>
225
+ <Button type="reset" variant="secondary">
226
+ Reset
227
+ </Button>
228
+ </form>
229
+
230
+ // Button with icons (must be valid Lucide icons - see https://lucide.dev/icons/)
231
+ <Button startIcon="Download" variant="primary">
232
+ Download
233
+ </Button>
234
+
235
+ <Button endIcon="ArrowRight" variant="secondary">
236
+ Next Step
237
+ </Button>
238
+
239
+ // Loading state
240
+ <Button loading={isLoading} loadingText="Processing...">
241
+ Save Changes
242
+ </Button>
243
+
244
+ // Link button
245
+ <Button href="/dashboard" variant="ghost">
246
+ Go to Dashboard
247
+ </Button>
248
+ ```
249
+
250
+ ## Design System Architecture
251
+
252
+ The PD Design System follows a **headless-first, adapter-based architecture**:
253
+
254
+ ```
255
+ ┌─────────────────────────────────────────────────────────┐
256
+ │ Your Application │
257
+ │ (Uses components with props-only API, no className) │
258
+ └──────────────────────┬──────────────────────────────────┘
259
+
260
+
261
+ ┌─────────────────────────────────────────────────────────┐
262
+ │ Design System Components │
263
+ │ (Button, Input, Select, etc. - Type-safe props API) │
264
+ └──────────────────────┬──────────────────────────────────┘
265
+
266
+
267
+ ┌─────────────────────────────────────────────────────────┐
268
+ │ Adapter Layer │
269
+ │ (shadcn, Material, AntD, etc. - Switchable engines) │
270
+ └──────────────────────┬──────────────────────────────────┘
271
+
272
+
273
+ ┌─────────────────────────────────────────────────────────┐
274
+ │ UI Engine Primitives │
275
+ │ (Radix UI, Material UI, Ant Design, etc.) │
276
+ └─────────────────────────────────────────────────────────┘
277
+ ```
278
+
279
+ ### Key Principles
280
+
281
+ 1. **Props-only API**: Consumers use only props and variants, no `className` required
282
+ 2. **Full TypeScript**: Complete autocomplete and type safety for all props
283
+ 3. **Adapter Layer**: Switch between UI engines without changing application code
284
+ 4. **Semantic Tokens**: Design tokens that work across themes and adapters
285
+ 5. **Framework Agnostic**: Design tokens and semantics are framework-agnostic
286
+ 6. **Zero-Config Theming**: Automatic system detection and localStorage sync
287
+ 7. **Style Isolation**: Scoped styles prevent conflicts with consumer CSS
288
+
289
+ ### Style Isolation
290
+
291
+ The design system uses **scoped styling** to prevent style conflicts:
292
+
293
+ - **All Tailwind classes are prefixed with `pd-`** - No collision with consumer Tailwind
294
+ - **All CSS variables are scoped under `.pd-root`** - No token leakage
295
+ - **Preflight is disabled** - Consumer styles are never reset
296
+ - **Works with any consumer setup** - Tailwind, MUI, AntD, Bootstrap, or plain CSS
297
+
298
+ **Always wrap your components with `ThemeProvider`** to create the scoped boundary:
299
+
300
+ ```tsx
301
+ <ThemeProvider storageKey="my-theme">
302
+ {/* Your design system components */}
303
+ </ThemeProvider>
304
+ ```
305
+
306
+ The `ThemeProvider` automatically adds the `pd-root` class to your body element, so all tokens are properly scoped.
307
+
308
+ ## Adapters
309
+
310
+ The adapter layer allows you to switch between different UI engines without changing your application code. This provides flexibility to use the underlying UI library that best fits your needs.
311
+
312
+ ### Supported Adapters
313
+
314
+ #### 1. Shadcn Adapter (Default)
315
+
316
+ Built on Radix UI primitives and Tailwind CSS. This is the default adapter.
317
+
318
+ ```tsx
319
+ <ThemeProvider adapter="shadcn">
320
+ <Button variant="primary">Click me</Button>
321
+ </ThemeProvider>
322
+ ```
323
+
324
+ **Features:**
325
+ - Radix UI primitives for accessibility
326
+ - Tailwind CSS for styling
327
+ - Fully customizable via design tokens
328
+ - Zero runtime dependencies for styling
329
+
330
+ #### 2. Material Adapter (Coming Soon)
331
+
332
+ Built on Material UI components.
333
+
334
+ ```tsx
335
+ <ThemeProvider adapter="material">
336
+ <Button variant="primary">Click me</Button>
337
+ </ThemeProvider>
338
+ ```
339
+
340
+ **Note:** Material adapter is planned for future releases. When available, you can switch adapters without changing your component code.
341
+
342
+ #### 3. Ant Design Adapter (Planned)
343
+
344
+ Built on Ant Design components.
345
+
346
+ ```tsx
347
+ <ThemeProvider adapter="antd">
348
+ <Button variant="primary">Click me</Button>
349
+ </ThemeProvider>
350
+ ```
351
+
352
+ **Note:** Ant Design adapter is planned for future releases.
353
+
354
+ ### Switching Adapters
355
+
356
+ You can switch adapters at any time without changing your component code:
357
+
358
+ ```tsx
359
+ // Switch from shadcn to material (when available)
360
+ <ThemeProvider adapter="material" theme="base" mode="system">
361
+ <Button variant="primary">Same Button, Different Engine</Button>
362
+ </ThemeProvider>
363
+ ```
364
+
365
+ The component API remains the same regardless of the adapter used. This allows you to:
366
+ - Test different UI engines
367
+ - Migrate between engines gradually
368
+ - Use different engines for different parts of your application
369
+ - Choose the engine that best fits your performance and bundle size requirements
370
+
371
+ ### Adapter Configuration
372
+
373
+ By default, the `shadcn` adapter is used. You can optionally specify a different adapter:
374
+
375
+ ```tsx
376
+ // Default (no adapter prop needed)
377
+ <ThemeProvider>
378
+ <Button variant="primary">Click me</Button>
379
+ </ThemeProvider>
380
+
381
+ // Optional: Specify adapter explicitly
382
+ <ThemeProvider
383
+ adapter="shadcn" // Optional: 'shadcn' | 'material' | 'antd' (when available)
384
+ >
385
+ <Button variant="primary">Click me</Button>
386
+ </ThemeProvider>
387
+ ```
388
+
389
+ **Default:** `'shadcn'`
390
+
391
+ ## Theming System
392
+
393
+ The design system supports **themes** and **modes** as separate concepts:
394
+
395
+ - **Theme** (`theme`): The design theme name - defines brand colors and styling
396
+ - **Mode** (`mode`): The color scheme - light, dark, or system preference
397
+
398
+ ### Themes
399
+
400
+ Themes define the overall design language, including brand colors, typography, and styling preferences.
401
+
402
+ #### Base Theme (Default)
403
+
404
+ The `base` theme provides a neutral, professional design suitable for most applications. This is the default theme:
405
+
406
+ ```tsx
407
+ // Default (no theme prop needed)
408
+ <ThemeProvider>
409
+ <Button variant="primary">Base Theme Button</Button>
410
+ </ThemeProvider>
411
+ ```
412
+
413
+ #### Brand Theme (Optional)
414
+
415
+ The `brand` theme extends the base theme with custom brand colors:
416
+
417
+ ```tsx
418
+ // Optional: Use brand theme
419
+ <ThemeProvider theme="brand">
420
+ <Button variant="primary">Brand Theme Button</Button>
421
+ </ThemeProvider>
422
+ ```
423
+
424
+ **Note:** Brand theme customization is available for extending with your own brand colors.
425
+
426
+ ### Custom Theme Extension
427
+
428
+ You can extend themes with custom brand colors using CSS variables:
429
+
430
+ ```tsx
431
+ <ThemeProvider
432
+ theme="base"
433
+ mode="light"
434
+ className="pd-root [--pd-primary:220_80%_50%]"
435
+ >
436
+ {/* Custom primary color */}
437
+ <Button variant="primary">Custom Brand Color</Button>
438
+ </ThemeProvider>
439
+ ```
440
+
441
+ Or via CSS:
442
+
443
+ ```css
444
+ .pd-root {
445
+ --pd-primary: 220 80% 50%;
446
+ --pd-primary-foreground: 0 0% 98%;
447
+ /* Add more custom tokens as needed */
448
+ }
449
+ ```
450
+
451
+ ### Theme Configuration
452
+
453
+ By default, the `base` theme is used. You can optionally specify a different theme:
454
+
455
+ ```tsx
456
+ // Default (no theme prop needed)
457
+ <ThemeProvider>
458
+ <Button variant="primary">Base Theme</Button>
459
+ </ThemeProvider>
460
+
461
+ // Optional: Use brand theme
462
+ <ThemeProvider theme="brand">
463
+ <Button variant="primary">Brand Theme</Button>
464
+ </ThemeProvider>
465
+ ```
466
+
467
+ **Default:** `'base'`
468
+
469
+ ## Mode System
470
+
471
+ The mode system controls the color scheme (light/dark) of your application. It supports three modes:
472
+
473
+ ### 1. System Mode (Default)
474
+
475
+ Automatically follows the OS dark/light preference. This is the default mode:
476
+
477
+ ```tsx
478
+ // Default (no mode prop needed)
479
+ <ThemeProvider>
480
+ {/* Automatically follows OS preference */}
481
+ <Button variant="primary">System Mode</Button>
482
+ </ThemeProvider>
483
+ ```
484
+
485
+ **Behavior:**
486
+ - Detects OS preference on mount
487
+ - Updates automatically when OS preference changes
488
+ - Works seamlessly with localStorage persistence
489
+ - Recommended for most applications
490
+
491
+ ### 2. Light Mode
492
+
493
+ Always uses light mode, ignoring system preference:
494
+
495
+ ```tsx
496
+ <ThemeProvider mode="light">
497
+ <Button variant="primary">Always Light</Button>
498
+ </ThemeProvider>
499
+ ```
500
+
501
+ ### 3. Dark Mode
502
+
503
+ Always uses dark mode, ignoring system preference:
504
+
505
+ ```tsx
506
+ <ThemeProvider mode="dark">
507
+ <Button variant="primary">Always Dark</Button>
508
+ </ThemeProvider>
509
+ ```
510
+
511
+ ### Mode Configuration
512
+
513
+ By default, `system` mode is used. You can optionally specify a different mode:
514
+
515
+ ```tsx
516
+ // Default (no mode prop needed - follows OS preference)
517
+ <ThemeProvider>
518
+ <Button variant="primary">System Mode</Button>
519
+ </ThemeProvider>
520
+
521
+ // Optional: Force light mode
522
+ <ThemeProvider mode="light">
523
+ <Button variant="primary">Always Light</Button>
524
+ </ThemeProvider>
525
+
526
+ // Optional: Force dark mode
527
+ <ThemeProvider mode="dark">
528
+ <Button variant="primary">Always Dark</Button>
529
+ </ThemeProvider>
530
+ ```
531
+
532
+ **Default:** `'system'`
533
+
534
+ ### localStorage Persistence
535
+
536
+ Pass `storageKey` to enable automatic theme persistence:
537
+
538
+ ```tsx
539
+ <ThemeProvider storageKey="my-app-theme">
540
+ {/*
541
+ Reads saved preference on mount
542
+ Saves changes automatically
543
+ Syncs across browser tabs
544
+ Works with system mode
545
+ */}
546
+ </ThemeProvider>
547
+ ```
548
+
549
+ **What gets saved:**
550
+ - User's manual selection (`'light'` | `'dark'`)
551
+ - `'system'` preference (so it knows to follow OS)
552
+
553
+ **Example flow:**
554
+ 1. User selects "Dark" → Saved to localStorage
555
+ 2. User refreshes page → Reads "Dark" from localStorage
556
+ 3. User opens new tab → Reads "Dark" from localStorage (synced)
557
+ 4. User changes to "System" → Saved, now follows OS preference
558
+
559
+ ### Theme Toggle Component
560
+
561
+ Here's an example of how to create a theme toggle:
562
+
563
+ ```tsx
564
+ import { useTheme, Button } from '@pd-design/system';
565
+
566
+ function ThemeToggle() {
567
+ const { config, setConfig } = useTheme();
568
+
569
+ const toggle = () => {
570
+ const modes = ['light', 'dark', 'system'] as const;
571
+ const currentIndex = modes.indexOf(config.mode);
572
+ const nextIndex = (currentIndex + 1) % modes.length;
573
+ setConfig({ mode: modes[nextIndex] });
574
+ };
575
+
576
+ return (
577
+ <Button onClick={toggle} variant="ghost">
578
+ {config.mode === 'system' && '🌓 System'}
579
+ {config.mode === 'light' && '☀️ Light'}
580
+ {config.mode === 'dark' && '🌙 Dark'}
581
+ </Button>
582
+ );
583
+ }
584
+ ```
585
+
586
+ ## Component Usage
587
+
588
+ ### Available Components
589
+
590
+ The design system provides a growing set of components. Here are some examples:
591
+
592
+ #### Button
593
+
594
+ ```tsx
595
+ import { Button } from '@pd-design/system';
596
+
597
+ <Button variant="primary" size="md">Click me</Button>
598
+ <Button variant="secondary" startIcon="Download">Download</Button>
599
+ <Button variant="destructive" loading={true}>Delete</Button>
600
+ ```
601
+
602
+ Browse all available icons: [https://lucide.dev/icons/](https://lucide.dev/icons/)
603
+
604
+ ### Component Variants
605
+
606
+ All components follow a consistent variant system:
607
+
608
+ - **variant**: `primary` | `secondary` | `ghost` | `destructive`
609
+ - **size**: `sm` | `md` | `lg`
610
+ - **state**: `loading` | `disabled`
611
+
612
+ No arbitrary strings or raw class overrides are allowed. This ensures consistency and type safety.
613
+
614
+ ## API Reference
615
+
616
+ ### ThemeProvider Props
617
+
618
+ | Prop | Type | Default | Description |
619
+ |------|------|---------|-------------|
620
+ | `adapter` | `'shadcn' \| 'material'` | `'shadcn'` | UI engine adapter |
621
+ | `theme` | `'base' \| 'brand'` | `'base'` | Theme name |
622
+ | `mode` | `'light' \| 'dark' \| 'system'` | `'system'` | Color mode (system follows OS) |
623
+ | `storageKey` | `string?` | `undefined` | localStorage key for persistence (enables sync) |
624
+ | `children` | `ReactNode` | Required | Your application components |
625
+
626
+ ### Exports
627
+
628
+ ```tsx
629
+ // Components
630
+ import {
631
+ Button,
632
+ Input,
633
+ Select,
634
+ Checkbox,
635
+ Radio,
636
+ Switch,
637
+ Modal,
638
+ Tooltip,
639
+ Dropdown,
640
+ Toast,
641
+ PdThemeProvider,
642
+ Icons
643
+ } from '@pd-design/system';
644
+
645
+ // Theme (Recommended: ThemeProvider with storageKey)
646
+ import {
647
+ ThemeProvider, // Full-featured provider with localStorage sync
648
+ useTheme, // Hook to access/update theme
649
+ setDesignSystemConfig,
650
+ getDesignSystemConfig
651
+ } from '@pd-design/system';
652
+
653
+ // Types
654
+ import type {
655
+ Variant,
656
+ Size,
657
+ ButtonType,
658
+ ThemeName,
659
+ ThemeMode,
660
+ AdapterType,
661
+ LucideIconName
662
+ } from '@pd-design/system';
663
+
664
+ // Styles (required)
665
+ import '@pd-design/system/styles.css';
666
+ ```
667
+
668
+ ## Advanced Usage
669
+
670
+ ### Per-Widget Theming
671
+
672
+ You can wrap only part of your page with `PdThemeProvider` for widget-level theming:
673
+
674
+ ```tsx
675
+ <div>
676
+ {/* Consumer styles */}
677
+ <PdThemeProvider theme="base" mode="dark">
678
+ {/* Design system widget with dark theme */}
679
+ <Button variant="primary">Dark Widget</Button>
680
+ </PdThemeProvider>
681
+ </div>
682
+ ```
683
+
684
+ ### Manual Configuration
685
+
686
+ For advanced use cases, you can configure the design system globally:
687
+
688
+ ```tsx
689
+ import { setDesignSystemConfig } from '@pd-design/system';
690
+
691
+ // Set adapter, theme, and mode
692
+ setDesignSystemConfig({
693
+ adapter: 'shadcn',
694
+ theme: 'base',
695
+ mode: 'light',
696
+ });
697
+ ```
698
+
699
+ **Note:** When using `ThemeProvider` with `storageKey`, you don't need to call `setDesignSystemConfig` manually - it's handled automatically.
700
+
701
+ ### PdThemeProvider vs ThemeProvider
702
+
703
+ - **`PdThemeProvider`**: Lightweight wrapper that creates the `.pd-root` scoped boundary. Use for simple theming needs without context.
704
+ - **`ThemeProvider`**: Full-featured provider with React context, system preference detection, localStorage sync, and CSS variable management. **Recommended for most use cases.**
705
+
706
+ Both support the same `theme` and `mode` props.
707
+
708
+ ## Common Use Cases
709
+
710
+ ### Use Case 1: Basic Setup (Default)
711
+
712
+ ```tsx
713
+ <ThemeProvider>
714
+ <App />
715
+ </ThemeProvider>
716
+ ```
717
+
718
+ **What you get:**
719
+ - Default adapter (`shadcn`)
720
+ - Default theme (`base`)
721
+ - System mode detection (follows OS)
722
+ - Zero configuration
723
+
724
+ **Optional: Add Persistence**
725
+
726
+ ```tsx
727
+ <ThemeProvider storageKey="my-app-theme">
728
+ <App />
729
+ </ThemeProvider>
730
+ ```
731
+
732
+ **Additional benefits:**
733
+ - Theme persistence (remembers user choice)
734
+ - Cross-tab sync
735
+
736
+ ### Use Case 2: Force Light Mode
737
+
738
+ ```tsx
739
+ <ThemeProvider mode="light">
740
+ <App />
741
+ </ThemeProvider>
742
+ ```
743
+
744
+ **What you get:**
745
+ - Always light mode
746
+ - Ignores system preference
747
+ - No localStorage (no storageKey)
748
+
749
+ ### Use Case 3: Custom Theme with System Mode
750
+
751
+ ```tsx
752
+ <ThemeProvider
753
+ theme="brand"
754
+ storageKey="my-brand-theme"
755
+ >
756
+ <App />
757
+ </ThemeProvider>
758
+ ```
759
+
760
+ **What you get:**
761
+ - Brand theme
762
+ - System mode with persistence
763
+ - User can override system preference
764
+
765
+ ### Use Case 4: Different Adapters
766
+
767
+ ```tsx
768
+ // Main app with shadcn
769
+ <ThemeProvider adapter="shadcn" storageKey="my-theme">
770
+ <MainApp />
771
+ </ThemeProvider>
772
+
773
+ // Widget with material (when available)
774
+ <PdThemeProvider adapter="material" theme="base" mode="dark">
775
+ <Widget />
776
+ </PdThemeProvider>
777
+ ```
778
+
779
+ ## Browser Support
780
+
781
+ - Chrome (latest)
782
+ - Firefox (latest)
783
+ - Safari (latest)
784
+ - Edge (latest)
785
+ - Mobile browsers (iOS Safari, Chrome Mobile)
786
+
787
+ ## Storybook
788
+
789
+ View all components and variants in Storybook:
790
+
791
+ ```bash
792
+ npm run storybook
793
+ ```
794
+
795
+ Storybook includes:
796
+ - All component variants with live examples
797
+ - Interactive controls for all props
798
+ - **Theme switcher** (base/brand) - See components in different themes
799
+ - **Mode switcher** (light/dark/system) - Test system mode detection
800
+ - **Adapter switcher** (shadcn/material) - Switch UI engines
801
+ - **Icons browser** with search - Browse 1000+ Lucide icons
802
+ - **Accessibility panel** - WCAG compliance checks
803
+ - **Code snippets** - Copy-paste ready examples
804
+ - **Design tokens showcase** - See all color primitives and semantic tokens
805
+
806
+ ## TypeScript
807
+
808
+ Full TypeScript support with autocomplete for all props:
809
+
810
+ ```tsx
811
+ <Button
812
+ variant="primary" // Autocomplete: primary | secondary | ghost | destructive
813
+ size="md" // Autocomplete: sm | md | lg
814
+ startIcon="Download" // Autocomplete: All Lucide icon names
815
+ endIcon="ArrowRight" // Autocomplete: All Lucide icon names
816
+ />
817
+
818
+ <ThemeProvider
819
+ theme="base" // Autocomplete: base | brand
820
+ mode="system" // Autocomplete: light | dark | system
821
+ adapter="shadcn" // Autocomplete: shadcn | material
822
+ />
823
+ ```
824
+
825
+ ## Accessibility
826
+
827
+ - Radix UI primitives for ARIA compliance
828
+ - Keyboard navigation support (Tab, Enter, Space, Arrow keys)
829
+ - Focus ring standards (visible focus indicators)
830
+ - Screen reader labels (aria-label, aria-describedby)
831
+ - Contrast-safe tokens (WCAG AA compliant)
832
+ - Disabled state handling (aria-disabled, pointer-events)
833
+ - Loading state indicators (aria-busy)
834
+
835
+ ## Contributing
836
+
837
+ This is an internal design system. For contributions, please follow the architecture guidelines in `ARCHITECTURE.md`.
838
+
839
+ ## License
840
+
841
+ MIT