@discourser/design-system 0.4.0 → 0.6.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.
Files changed (42) hide show
  1. package/README.md +12 -4
  2. package/dist/index.cjs +240 -260
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +67 -90
  5. package/dist/index.d.ts +67 -90
  6. package/dist/index.js +238 -258
  7. package/dist/index.js.map +1 -1
  8. package/dist/styles.css +5126 -0
  9. package/guidelines/Guidelines.md +67 -123
  10. package/guidelines/components/accordion.md +93 -0
  11. package/guidelines/components/avatar.md +70 -0
  12. package/guidelines/components/badge.md +61 -0
  13. package/guidelines/components/button.md +75 -40
  14. package/guidelines/components/card.md +84 -25
  15. package/guidelines/components/checkbox.md +88 -0
  16. package/guidelines/components/dialog.md +619 -31
  17. package/guidelines/components/drawer.md +655 -0
  18. package/guidelines/components/heading.md +71 -0
  19. package/guidelines/components/icon-button.md +92 -37
  20. package/guidelines/components/input-addon.md +685 -0
  21. package/guidelines/components/input-group.md +830 -0
  22. package/guidelines/components/input.md +92 -37
  23. package/guidelines/components/popover.md +71 -0
  24. package/guidelines/components/progress.md +63 -0
  25. package/guidelines/components/radio-group.md +95 -0
  26. package/guidelines/components/select.md +507 -0
  27. package/guidelines/components/skeleton.md +76 -0
  28. package/guidelines/components/slider.md +911 -0
  29. package/guidelines/components/spinner.md +783 -0
  30. package/guidelines/components/switch.md +105 -38
  31. package/guidelines/components/tabs.md +654 -0
  32. package/guidelines/components/textarea.md +70 -0
  33. package/guidelines/components/toast.md +77 -0
  34. package/guidelines/components/tooltip.md +80 -0
  35. package/guidelines/design-tokens/colors.md +309 -72
  36. package/guidelines/design-tokens/elevation.md +615 -45
  37. package/guidelines/design-tokens/spacing.md +654 -74
  38. package/guidelines/design-tokens/typography.md +432 -50
  39. package/guidelines/overview-components.md +9 -5
  40. package/guidelines/overview-imports.md +314 -0
  41. package/guidelines/overview-patterns.md +3852 -0
  42. package/package.json +14 -2
@@ -10,20 +10,24 @@ Before writing any code, follow these steps IN ORDER:
10
10
 
11
11
  Read ALL files with a name that starts with "overview-":
12
12
 
13
- - `overview-components.md` - Available components and usage patterns
13
+ - **[overview-components.md](overview-components.md)** - Available components with quick reference tables
14
+ - **[overview-imports.md](overview-imports.md)** - Package installation and import patterns
15
+ - **[overview-patterns.md](overview-patterns.md)** - Common UI patterns combining multiple components
14
16
 
15
17
  ### Step 2: Read Design Token Files (REQUIRED)
16
18
 
17
19
  Read ALL files in the `design-tokens/` folder:
18
20
 
19
- - `design-tokens/colors.md`
20
- - `design-tokens/typography.md`
21
- - `design-tokens/spacing.md`
22
- - `design-tokens/elevation.md`
21
+ - **[design-tokens/colors.md](design-tokens/colors.md)** - Semantic color tokens and usage
22
+ - **[design-tokens/typography.md](design-tokens/typography.md)** - Typography scale and text styles
23
+ - **[design-tokens/spacing.md](design-tokens/spacing.md)** - Spacing system and layout
24
+ - **[design-tokens/elevation.md](design-tokens/elevation.md)** - Surface elevation and shadows
23
25
 
24
26
  ### Step 3: Plan Components Needed (REQUIRED)
25
27
 
26
- Identify which components you need to use.
28
+ Identify which components you need to use based on your task.
29
+
30
+ Refer to [overview-components.md](overview-components.md) for the complete list.
27
31
 
28
32
  ### Step 4: Read Component Guidelines BEFORE Using Components (REQUIRED)
29
33
 
@@ -31,44 +35,48 @@ BEFORE using ANY component, you MUST read its guidelines file first:
31
35
 
32
36
  **Interactive Elements:**
33
37
 
34
- - Using Button? → Read `components/button.md` FIRST
35
- - Using IconButton? → Read `components/icon-button.md` FIRST
36
- - Using Switch? → Read `components/switch.md` FIRST
37
- - Using Checkbox? → Read `components/checkbox.md` FIRST
38
- - Using RadioGroup? → Read `components/radio-group.md` FIRST
38
+ - Using Button? → Read **[components/button.md](components/button.md)** FIRST
39
+ - Using IconButton? → Read **[components/icon-button.md](components/icon-button.md)** FIRST
40
+ - Using Switch? → Read **[components/switch.md](components/switch.md)** FIRST
41
+ - Using Checkbox? → Read **[components/checkbox.md](components/checkbox.md)** FIRST
42
+ - Using RadioGroup? → Read **[components/radio-group.md](components/radio-group.md)** FIRST
39
43
 
40
44
  **Form Elements:**
41
45
 
42
- - Using Input? → Read `components/input.md` FIRST
43
- - Using Textarea? → Read `components/textarea.md` FIRST
44
- - Using Select? → Read `components/select.md` FIRST
46
+ - Using Input? → Read **[components/input.md](components/input.md)** FIRST
47
+ - Using InputAddon? → Read **[components/input-addon.md](components/input-addon.md)** FIRST
48
+ - Using InputGroup? → Read **[components/input-group.md](components/input-group.md)** FIRST
49
+ - Using Textarea? → Read **[components/textarea.md](components/textarea.md)** FIRST
50
+ - Using Select? → Read **[components/select.md](components/select.md)** FIRST
51
+ - Using Slider? → Read **[components/slider.md](components/slider.md)** FIRST
45
52
 
46
53
  **Layout & Container:**
47
54
 
48
- - Using Card? → Read `components/card.md` FIRST
49
- - Using Accordion? → Read `components/accordion.md` FIRST
50
- - Using Tabs? → Read `components/tabs.md` FIRST
51
- - Using Drawer? → Read `components/drawer.md` FIRST
55
+ - Using Card? → Read **[components/card.md](components/card.md)** FIRST
56
+ - Using Accordion? → Read **[components/accordion.md](components/accordion.md)** FIRST
57
+ - Using Tabs? → Read **[components/tabs.md](components/tabs.md)** FIRST
58
+ - Using Drawer? → Read **[components/drawer.md](components/drawer.md)** FIRST
52
59
 
53
60
  **Overlay Elements:**
54
61
 
55
- - Using Dialog? → Read `components/dialog.md` FIRST
56
- - Using Popover? → Read `components/popover.md` FIRST
57
- - Using Tooltip? → Read `components/tooltip.md` FIRST
62
+ - Using Dialog? → Read **[components/dialog.md](components/dialog.md)** FIRST
63
+ - Using Popover? → Read **[components/popover.md](components/popover.md)** FIRST
64
+ - Using Tooltip? → Read **[components/tooltip.md](components/tooltip.md)** FIRST
58
65
 
59
66
  **Feedback & Status:**
60
67
 
61
- - Using Badge? → Read `components/badge.md` FIRST
62
- - Using Avatar? → Read `components/avatar.md` FIRST
63
- - Using Toast? → Read `components/toast.md` FIRST
64
- - Using Progress? → Read `components/progress.md` FIRST
65
- - Using Skeleton? → Read `components/skeleton.md` FIRST
68
+ - Using Badge? → Read **[components/badge.md](components/badge.md)** FIRST
69
+ - Using Avatar? → Read **[components/avatar.md](components/avatar.md)** FIRST
70
+ - Using Toast? → Read **[components/toast.md](components/toast.md)** FIRST
71
+ - Using Progress? → Read **[components/progress.md](components/progress.md)** FIRST
72
+ - Using Skeleton? → Read **[components/skeleton.md](components/skeleton.md)** FIRST
73
+ - Using Spinner? → Read **[components/spinner.md](components/spinner.md)** FIRST
66
74
 
67
75
  **Typography:**
68
76
 
69
- - Using Heading? → Read `components/heading.md` FIRST
77
+ - Using Heading? → Read **[components/heading.md](components/heading.md)** FIRST
70
78
 
71
- DO NOT write code using a component until you have read its specific guidelines.
79
+ **DO NOT write code using a component until you have read its specific guidelines.**
72
80
 
73
81
  ## Core Principles
74
82
 
@@ -77,101 +85,16 @@ DO NOT write code using a component until you have read its specific guidelines.
77
85
  - **Follow M3 patterns** for variants, sizing, and state layers
78
86
  - **Do not override styles** unless absolutely necessary
79
87
  - **Never use inline styles** with raw color values
88
+ - **Read component guidelines** before using any component
89
+ - **Follow common patterns** documented in overview-patterns.md
80
90
 
81
- ## Package Installation
82
-
83
- ```bash
84
- npm install @discourser/design-system react react-dom
85
- ```
86
-
87
- ## Package Imports
88
-
89
- ```typescript
90
- // Simple Components (exported directly)
91
- import {
92
- Button,
93
- Card,
94
- Input,
95
- Textarea,
96
- Heading,
97
- Badge,
98
- Toaster,
99
- toaster,
100
- } from '@discourser/design-system';
101
-
102
- // Compound Components (exported as namespaces)
103
- import * as Checkbox from '@discourser/design-system';
104
- import * as RadioGroup from '@discourser/design-system';
105
- import * as Select from '@discourser/design-system';
106
- import * as Dialog from '@discourser/design-system';
107
- import * as Drawer from '@discourser/design-system';
108
- import * as Popover from '@discourser/design-system';
109
- import * as Tooltip from '@discourser/design-system';
110
- import * as Accordion from '@discourser/design-system';
111
- import * as Tabs from '@discourser/design-system';
112
- import * as Avatar from '@discourser/design-system';
113
- import * as Progress from '@discourser/design-system';
114
- import * as Skeleton from '@discourser/design-system';
115
- import * as IconButton from '@discourser/design-system';
116
- import * as Switch from '@discourser/design-system';
117
-
118
- // For advanced styling (use sparingly)
119
- import { css } from '@discourser/design-system/styled-system/css';
120
- import { button } from '@discourser/design-system/styled-system/recipes';
121
- ```
122
-
123
- ## Quick Reference
124
-
125
- **Interactive Elements:**
126
-
127
- | Component | Key Variants | Guidelines |
128
- | ---------- | --------------------------------------- | --------------------------- |
129
- | Button | filled, outlined, text, elevated, tonal | `components/button.md` |
130
- | IconButton | standard, filled, tonal, outlined | `components/icon-button.md` |
131
- | Switch | - | `components/switch.md` |
132
- | Checkbox | solid, outline, subtle | `components/checkbox.md` |
133
- | RadioGroup | solid | `components/radio-group.md` |
134
-
135
- **Form Elements:**
136
-
137
- | Component | Key Variants | Guidelines |
138
- | --------- | --------------------------------- | ------------------------ |
139
- | Input | surface, outline, subtle | `components/input.md` |
140
- | Textarea | surface, outline, subtle, flushed | `components/textarea.md` |
141
- | Select | outline, surface | `components/select.md` |
142
-
143
- **Layout & Containers:**
91
+ ## Quick Start
144
92
 
145
- | Component | Key Variants | Guidelines |
146
- | --------- | ----------------------------------- | ------------------------- |
147
- | Card | elevated, filled, outlined | `components/card.md` |
148
- | Accordion | outline, plain | `components/accordion.md` |
149
- | Tabs | line, subtle, enclosed | `components/tabs.md` |
150
- | Drawer | Placements: start, end, top, bottom | `components/drawer.md` |
151
-
152
- **Overlays:**
153
-
154
- | Component | Key Features | Guidelines |
155
- | --------- | ----------------------------- | ----------------------- |
156
- | Dialog | Sizes: sm, md, lg, fullscreen | `components/dialog.md` |
157
- | Popover | 12 positioning options | `components/popover.md` |
158
- | Tooltip | Lightweight contextual help | `components/tooltip.md` |
159
-
160
- **Feedback & Status:**
161
-
162
- | Component | Key Variants | Guidelines |
163
- | --------- | ------------------------------------------------ | ------------------------ |
164
- | Badge | subtle, solid, surface, outline | `components/badge.md` |
165
- | Avatar | Sizes: 2xs to 2xl, Shapes: full, rounded, square | `components/avatar.md` |
166
- | Toast | Types: success, error, warning, loading | `components/toast.md` |
167
- | Progress | Shapes: linear, circular | `components/progress.md` |
168
- | Skeleton | Animations: pulse, shine, none | `components/skeleton.md` |
169
-
170
- **Typography:**
171
-
172
- | Component | Key Features | Guidelines |
173
- | --------- | --------------------------------- | ----------------------- |
174
- | Heading | Sizes: xs to 7xl (M3 text styles) | `components/heading.md` |
93
+ 1. Install the package (see [overview-imports.md](overview-imports.md))
94
+ 2. Import components you need
95
+ 3. Use components with their documented variants and props
96
+ 4. Apply semantic tokens for custom styling
97
+ 5. Follow accessibility best practices from component guidelines
175
98
 
176
99
  ## Theme Support
177
100
 
@@ -187,9 +110,30 @@ The design system supports light and dark themes. The theme is controlled by the
187
110
 
188
111
  All semantic color tokens automatically adapt to the current theme.
189
112
 
113
+ ## Documentation Structure
114
+
115
+ ```
116
+ guidelines/
117
+ ├── Guidelines.md (this file) # Main navigation
118
+ ├── overview-components.md # Component catalog
119
+ ├── overview-imports.md # Installation & imports
120
+ ├── overview-patterns.md # Common UI patterns
121
+ ├── design-tokens/
122
+ │ ├── colors.md # Color system
123
+ │ ├── typography.md # Type scale
124
+ │ ├── spacing.md # Spacing system
125
+ │ └── elevation.md # Elevation system
126
+ └── components/
127
+ ├── button.md # Component guidelines
128
+ ├── input.md
129
+ └── ... # (25 total components)
130
+ ```
131
+
190
132
  ## Getting Help
191
133
 
192
134
  For questions or issues, visit:
193
135
 
194
- - GitHub: https://github.com/Tasty-Maker-Studio/Discourser-Design-System
195
- - Documentation: Read the overview and component-specific guidelines in this folder
136
+ - **GitHub:** https://github.com/Tasty-Maker-Studio/Discourser-Design-System
137
+ - **Documentation:** Read the overview and component-specific guidelines in this folder
138
+ - **Component Reference:** See [overview-components.md](overview-components.md)
139
+ - **Patterns:** See [overview-patterns.md](overview-patterns.md)
@@ -2,6 +2,99 @@
2
2
 
3
3
  **Purpose:** Collapsible content panels for organizing and revealing information progressively, following Material Design 3 principles.
4
4
 
5
+ ## When to Use This Component
6
+
7
+ Use Accordion when you need to **organize and progressively disclose related content in collapsible sections** to conserve space while keeping content accessible.
8
+
9
+ ### Decision Tree
10
+
11
+ | Scenario | Use Accordion? | Alternative | Reasoning |
12
+ | --------------------------------------------------- | -------------- | ------------------------- | --------------------------------------------------------------- |
13
+ | Displaying FAQ with expandable answers | ✅ Yes | - | Perfect for progressively disclosing detailed information |
14
+ | Organizing settings into collapsible sections | ✅ Yes | - | Groups related settings while saving vertical space |
15
+ | User needs to view multiple sections simultaneously | ⚠️ Maybe | Tabs or Separate sections | Accordion with `multiple={true}` works, but tabs may be clearer |
16
+ | Navigation between different views | ❌ No | Tabs | Tabs show one view at a time with clear navigation |
17
+ | Content where all sections should be visible | ❌ No | Regular sections | Don't hide content that should always be visible |
18
+ | Quick comparison of all options | ❌ No | Table or Grid | Accordion requires clicking to see content |
19
+
20
+ ### Component Comparison
21
+
22
+ ```typescript
23
+ // ✅ Accordion - FAQs with expandable answers
24
+ <Accordion.Root defaultValue="faq-1">
25
+ <Accordion.Item value="faq-1">
26
+ <Accordion.ItemTrigger>
27
+ What is your return policy?
28
+ <Accordion.ItemIndicator />
29
+ </Accordion.ItemTrigger>
30
+ <Accordion.ItemContent>
31
+ <Accordion.ItemBody>
32
+ We accept returns within 30 days of purchase with original packaging.
33
+ </Accordion.ItemBody>
34
+ </Accordion.ItemContent>
35
+ </Accordion.Item>
36
+ <Accordion.Item value="faq-2">
37
+ <Accordion.ItemTrigger>
38
+ How long does shipping take?
39
+ <Accordion.ItemIndicator />
40
+ </Accordion.ItemTrigger>
41
+ <Accordion.ItemContent>
42
+ <Accordion.ItemBody>
43
+ Standard shipping takes 5-7 business days.
44
+ </Accordion.ItemBody>
45
+ </Accordion.ItemContent>
46
+ </Accordion.Item>
47
+ </Accordion.Root>
48
+
49
+ // ❌ Don't use Accordion for navigation - Use Tabs instead
50
+ <Accordion.Root>
51
+ <Accordion.Item value="overview">
52
+ <Accordion.ItemTrigger>Overview</Accordion.ItemTrigger>
53
+ <Accordion.ItemContent>
54
+ <Dashboard />
55
+ </Accordion.ItemContent>
56
+ </Accordion.Item>
57
+ <Accordion.Item value="analytics">
58
+ <Accordion.ItemTrigger>Analytics</Accordion.ItemTrigger>
59
+ <Accordion.ItemContent>
60
+ <AnalyticsView />
61
+ </Accordion.ItemContent>
62
+ </Accordion.Item>
63
+ </Accordion.Root>
64
+
65
+ // ✅ Better: Use Tabs for view switching
66
+ <Tabs.Root defaultValue="overview">
67
+ <Tabs.List>
68
+ <Tabs.Trigger value="overview">Overview</Tabs.Trigger>
69
+ <Tabs.Trigger value="analytics">Analytics</Tabs.Trigger>
70
+ <Tabs.Indicator />
71
+ </Tabs.List>
72
+ <Tabs.Content value="overview"><Dashboard /></Tabs.Content>
73
+ <Tabs.Content value="analytics"><AnalyticsView /></Tabs.Content>
74
+ </Tabs.Root>
75
+
76
+ // ❌ Don't use Accordion when all content should be visible
77
+ <Accordion.Root multiple defaultValue={['step1', 'step2', 'step3']}>
78
+ <Accordion.Item value="step1">
79
+ <Accordion.ItemTrigger>Step 1</Accordion.ItemTrigger>
80
+ <Accordion.ItemContent>Instructions</Accordion.ItemContent>
81
+ </Accordion.Item>
82
+ {/* If all steps need to be visible, don't hide them */}
83
+ </Accordion.Root>
84
+
85
+ // ✅ Better: Use regular sections for always-visible content
86
+ <Stack gap="4">
87
+ <Section>
88
+ <Heading>Step 1</Heading>
89
+ <Text>Instructions...</Text>
90
+ </Section>
91
+ <Section>
92
+ <Heading>Step 2</Heading>
93
+ <Text>Instructions...</Text>
94
+ </Section>
95
+ </Stack>
96
+ ```
97
+
5
98
  ## Import
6
99
 
7
100
  ```typescript
@@ -2,6 +2,76 @@
2
2
 
3
3
  **Purpose:** Visual representation of users or entities through images, initials, or icons, providing identity context throughout the application.
4
4
 
5
+ ## When to Use This Component
6
+
7
+ Use Avatar when you need to **visually represent a user, person, or entity** with an image, initials, or icon to provide identity context.
8
+
9
+ ### Decision Tree
10
+
11
+ | Scenario | Use Avatar? | Alternative | Reasoning |
12
+ | ------------------------- | ----------- | --------------------------- | ------------------------------------------------ |
13
+ | User profile pictures | ✅ Yes | - | Avatar is designed for user representation |
14
+ | Comment author indicators | ✅ Yes | - | Shows who created the content |
15
+ | Team member lists | ✅ Yes | - | Visual identification of people |
16
+ | Status labels or tags | ❌ No | Badge | Badge is for status, not identity |
17
+ | Decorative icons | ❌ No | Icon component | Use semantic icons for UI elements |
18
+ | Company logos (non-user) | ⚠️ Maybe | Image with `shape="square"` | Avatar with square shape works for organizations |
19
+
20
+ ### Component Comparison
21
+
22
+ ```typescript
23
+ // ✅ Avatar - User profile representation
24
+ <Avatar.Root colorPalette="primary" size="md">
25
+ <Avatar.Fallback name="John Doe" />
26
+ <Avatar.Image src="/avatars/john.jpg" alt="John Doe" />
27
+ </Avatar.Root>
28
+
29
+ // ❌ Don't use Avatar for status indicators - Use Badge
30
+ <Avatar.Root colorPalette="success" size="sm">
31
+ <Avatar.Fallback>✓</Avatar.Fallback>
32
+ </Avatar.Root>
33
+
34
+ // ✅ Better: Use Badge for status
35
+ <Badge colorPalette="success">Active</Badge>
36
+
37
+ // ❌ Don't use Avatar for UI icons - Use Icon
38
+ <Avatar.Root size="sm">
39
+ <Avatar.Fallback>
40
+ <SettingsIcon />
41
+ </Avatar.Fallback>
42
+ </Avatar.Root>
43
+
44
+ // ✅ Better: Use IconButton for UI actions
45
+ <IconButton aria-label="Settings">
46
+ <SettingsIcon />
47
+ </IconButton>
48
+
49
+ // ✅ Avatar - Comment author with status
50
+ <HStack gap="3">
51
+ <Box position="relative">
52
+ <Avatar.Root colorPalette="primary" size="md">
53
+ <Avatar.Fallback name="Jane Smith" />
54
+ <Avatar.Image src="/avatars/jane.jpg" alt="Jane Smith" />
55
+ </Avatar.Root>
56
+ {/* Online status indicator */}
57
+ <Box
58
+ position="absolute"
59
+ bottom="0"
60
+ right="0"
61
+ width="3"
62
+ height="3"
63
+ borderRadius="full"
64
+ bg="success.solid"
65
+ border="2px solid white"
66
+ />
67
+ </Box>
68
+ <Stack gap="1">
69
+ <Text fontWeight="semibold">Jane Smith</Text>
70
+ <Text fontSize="sm" color="fg.muted">2 hours ago</Text>
71
+ </Stack>
72
+ </HStack>
73
+ ```
74
+
5
75
  ## Import
6
76
 
7
77
  ```typescript
@@ -2,6 +2,67 @@
2
2
 
3
3
  **Purpose:** Compact visual indicator for displaying status, labels, counts, or categories following Material Design 3 patterns.
4
4
 
5
+ ## When to Use This Component
6
+
7
+ Use Badge when you need to **display compact visual indicators for status, counts, labels, or categories** as non-interactive elements.
8
+
9
+ ### Decision Tree
10
+
11
+ | Scenario | Use Badge? | Alternative | Reasoning |
12
+ | ------------------------------------------------ | ---------- | -------------- | ---------------------------------------------- |
13
+ | Displaying status labels (Active, Pending, etc.) | ✅ Yes | - | Badge provides clear visual categorization |
14
+ | Notification counts on icons or buttons | ✅ Yes | - | Perfect for unread messages, alerts |
15
+ | Category tags or labels | ✅ Yes | - | Compact visual grouping |
16
+ | Clickable filters or selections | ❌ No | Button or Chip | Badge is non-interactive |
17
+ | Primary call-to-action | ❌ No | Button | Button is designed for actions |
18
+ | User profile images | ❌ No | Avatar | Avatar is specifically for user representation |
19
+
20
+ ### Component Comparison
21
+
22
+ ```typescript
23
+ // ✅ Badge - Status indicator
24
+ <Stack gap="2" direction="row">
25
+ <Badge colorPalette="success">Active</Badge>
26
+ <Badge colorPalette="warning">Pending</Badge>
27
+ <Badge colorPalette="error">Expired</Badge>
28
+ </Stack>
29
+
30
+ // ❌ Don't use Badge for interactive elements - Use Button
31
+ <Badge onClick={handleClick} colorPalette="primary">
32
+ Click me
33
+ </Badge>
34
+
35
+ // ✅ Better: Use Button for clickable actions
36
+ <Button size="sm" variant="outlined">
37
+ Click me
38
+ </Button>
39
+
40
+ // ❌ Don't use Badge for user avatars - Use Avatar
41
+ <Badge colorPalette="primary" size="2xl">
42
+ JD
43
+ </Badge>
44
+
45
+ // ✅ Better: Use Avatar for user representation
46
+ <Avatar.Root colorPalette="primary" size="md">
47
+ <Avatar.Fallback name="John Doe" />
48
+ <Avatar.Image src="/avatar.jpg" alt="John Doe" />
49
+ </Avatar.Root>
50
+
51
+ // ✅ Badge - Notification count on icon
52
+ <Box position="relative">
53
+ <IconButton><BellIcon /></IconButton>
54
+ <Badge
55
+ position="absolute"
56
+ top="-1"
57
+ right="-1"
58
+ colorPalette="error"
59
+ size="sm"
60
+ >
61
+ 5
62
+ </Badge>
63
+ </Box>
64
+ ```
65
+
5
66
  ## Import
6
67
 
7
68
  ```typescript
@@ -2,6 +2,41 @@
2
2
 
3
3
  **Purpose:** Primary interactive element for user actions following Material Design 3 patterns.
4
4
 
5
+ ## When to Use This Component
6
+
7
+ Use Button when you need a clickable element that **triggers an action** (submit, save, cancel, etc.).
8
+
9
+ **Decision Tree:**
10
+
11
+ | Scenario | Use This | Why |
12
+ | ---------------------------------------- | ----------------------------- | ------------------------------------------------- |
13
+ | Trigger an action (submit, save, delete) | Button ✅ | Semantic action element |
14
+ | Navigate to a different page/route | `<a>` tag or Next.js `<Link>` | Navigation should use links for SEO/accessibility |
15
+ | Icon-only action (close, menu, settings) | IconButton | Better for icon-only affordances |
16
+ | Toggle state (on/off, enable/disable) | Switch | Visual metaphor for state changes |
17
+ | Select from options (exclusive choice) | RadioGroup | For mutually exclusive selections |
18
+ | Select multiple options | Checkbox | For multiple selections |
19
+
20
+ **Component Comparison:**
21
+
22
+ ```typescript
23
+ // ✅ Use Button for actions
24
+ <Button onClick={handleSave}>Save</Button>
25
+ <Button onClick={handleDelete}>Delete</Button>
26
+
27
+ // ❌ Don't use Button for navigation - use Link
28
+ <Button onClick={() => router.push('/page')}>Go to Page</Button> // Wrong
29
+ <Link href="/page">Go to Page</Link> // Correct
30
+
31
+ // ❌ Don't use Button for icon-only - use IconButton
32
+ <Button><CloseIcon /></Button> // Wrong
33
+ <IconButton aria-label="Close"><CloseIcon /></IconButton> // Correct
34
+
35
+ // ❌ Don't use Button for toggles - use Switch
36
+ <Button onClick={toggleDarkMode}>Dark Mode</Button> // Wrong
37
+ <Switch checked={isDarkMode} onCheckedChange={setDarkMode}>Dark Mode</Switch> // Correct
38
+ ```
39
+
5
40
  ## Import
6
41
 
7
42
  ```typescript
@@ -12,13 +47,13 @@ import { Button } from '@discourser/design-system';
12
47
 
13
48
  The Button component supports 5 Material Design 3 variants, each with specific use cases:
14
49
 
15
- | Variant | Visual Style | Usage | When to Use |
16
- |---------|-------------|-------|-------------|
17
- | `filled` | Solid background with primary color | Primary actions | Submit forms, confirm dialogs, main CTAs |
18
- | `outlined` | Transparent background with border | Secondary actions | Cancel buttons, back navigation, alternative options |
19
- | `text` | Transparent background, no border | Tertiary actions | Links, less prominent actions, dialog actions |
20
- | `elevated` | Elevated surface with subtle shadow | Floating actions | FAB-like buttons, actions that need emphasis but not primary color |
21
- | `tonal` | Filled with secondary container color | Medium emphasis | Secondary CTAs, soft highlights, supportive actions |
50
+ | Variant | Visual Style | Usage | When to Use |
51
+ | ---------- | ------------------------------------- | ----------------- | ------------------------------------------------------------------ |
52
+ | `filled` | Solid background with primary color | Primary actions | Submit forms, confirm dialogs, main CTAs |
53
+ | `outlined` | Transparent background with border | Secondary actions | Cancel buttons, back navigation, alternative options |
54
+ | `text` | Transparent background, no border | Tertiary actions | Links, less prominent actions, dialog actions |
55
+ | `elevated` | Elevated surface with subtle shadow | Floating actions | FAB-like buttons, actions that need emphasis but not primary color |
56
+ | `tonal` | Filled with secondary container color | Medium emphasis | Secondary CTAs, soft highlights, supportive actions |
22
57
 
23
58
  ### Visual Characteristics
24
59
 
@@ -30,27 +65,27 @@ The Button component supports 5 Material Design 3 variants, each with specific u
30
65
 
31
66
  ## Sizes
32
67
 
33
- | Size | Height | Padding (Horizontal) | Font Size | Usage |
34
- |------|--------|---------------------|-----------|-------|
35
- | `sm` | 32px | 16px (md) | labelMedium | Compact UI, dense layouts, small dialogs |
36
- | `md` | 40px | 24px (lg) | labelLarge | Default, most use cases |
37
- | `lg` | 48px | 32px (xl) | labelLarge | Touch targets, mobile emphasis, hero sections |
68
+ | Size | Height | Padding (Horizontal) | Font Size | Usage |
69
+ | ---- | ------ | -------------------- | ----------- | --------------------------------------------- |
70
+ | `sm` | 32px | 16px (md) | labelMedium | Compact UI, dense layouts, small dialogs |
71
+ | `md` | 40px | 24px (lg) | labelLarge | Default, most use cases |
72
+ | `lg` | 48px | 32px (xl) | labelLarge | Touch targets, mobile emphasis, hero sections |
38
73
 
39
74
  **Recommendation:** Use `md` for most cases. Use `lg` for mobile-first designs or prominent CTAs.
40
75
 
41
76
  ## Props
42
77
 
43
- | Prop | Type | Default | Description |
44
- |------|------|---------|-------------|
45
- | `variant` | `'filled' \| 'outlined' \| 'text' \| 'elevated' \| 'tonal'` | `'filled'` | Visual style variant |
46
- | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button size |
47
- | `leftIcon` | `ReactNode` | - | Icon or element before button text |
48
- | `rightIcon` | `ReactNode` | - | Icon or element after button text |
49
- | `disabled` | `boolean` | `false` | Disable button interaction |
50
- | `onClick` | `(event: MouseEvent) => void` | - | Click handler |
51
- | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | HTML button type |
52
- | `className` | `string` | - | Additional CSS classes (use sparingly) |
53
- | `children` | `ReactNode` | Required | Button text content |
78
+ | Prop | Type | Default | Description |
79
+ | ----------- | ----------------------------------------------------------- | ---------- | -------------------------------------- |
80
+ | `variant` | `'filled' \| 'outlined' \| 'text' \| 'elevated' \| 'tonal'` | `'filled'` | Visual style variant |
81
+ | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button size |
82
+ | `leftIcon` | `ReactNode` | - | Icon or element before button text |
83
+ | `rightIcon` | `ReactNode` | - | Icon or element after button text |
84
+ | `disabled` | `boolean` | `false` | Disable button interaction |
85
+ | `onClick` | `(event: MouseEvent) => void` | - | Click handler |
86
+ | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | HTML button type |
87
+ | `className` | `string` | - | Additional CSS classes (use sparingly) |
88
+ | `children` | `ReactNode` | Required | Button text content |
54
89
 
55
90
  **Note:** Button extends `ButtonHTMLAttributes<HTMLButtonElement>`, so all standard HTML button attributes are supported.
56
91
 
@@ -242,26 +277,26 @@ The Button component follows WCAG 2.1 Level AA standards:
242
277
 
243
278
  ## Variant Selection Guide
244
279
 
245
- | Scenario | Recommended Variant | Reasoning |
246
- |----------|-------------------|-----------|
247
- | Form submission | `filled` | Primary action, needs highest emphasis |
248
- | Cancel/Back | `outlined` or `text` | Secondary action, lower emphasis |
249
- | Dialog confirmation | `filled` | Primary action in dialog |
250
- | Dialog dismiss | `text` | Tertiary action, minimal emphasis |
251
- | Save draft | `tonal` | Medium emphasis, not primary action |
252
- | Delete/Destructive | `filled` or `tonal` | High attention, but consider error colors |
253
- | Filter/Sort | `text` or `outlined` | Lower emphasis, frequent use |
254
- | Floating action button | `elevated` | Needs to float above content |
255
- | Link-like actions | `text` | Minimal emphasis, inline with text |
280
+ | Scenario | Recommended Variant | Reasoning |
281
+ | ---------------------- | -------------------- | ----------------------------------------- |
282
+ | Form submission | `filled` | Primary action, needs highest emphasis |
283
+ | Cancel/Back | `outlined` or `text` | Secondary action, lower emphasis |
284
+ | Dialog confirmation | `filled` | Primary action in dialog |
285
+ | Dialog dismiss | `text` | Tertiary action, minimal emphasis |
286
+ | Save draft | `tonal` | Medium emphasis, not primary action |
287
+ | Delete/Destructive | `filled` or `tonal` | High attention, but consider error colors |
288
+ | Filter/Sort | `text` or `outlined` | Lower emphasis, frequent use |
289
+ | Floating action button | `elevated` | Needs to float above content |
290
+ | Link-like actions | `text` | Minimal emphasis, inline with text |
256
291
 
257
292
  ## State Behaviors
258
293
 
259
- | State | Visual Change | Behavior |
260
- |-------|---------------|----------|
261
- | **Hover** | Opacity change or shadow | `filled`: 92% opacity + level1 shadow<br />`outlined`: 8% primary background<br />`elevated`: Increase shadow to level2 |
262
- | **Active** | Further opacity/shadow change | `filled`: 88% opacity<br />`outlined`: 12% primary background |
263
- | **Focus** | 2px outline | Primary color outline, 2px offset |
264
- | **Disabled** | 38% opacity, no interaction | Cannot be clicked, greyed out appearance |
294
+ | State | Visual Change | Behavior |
295
+ | ------------ | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
296
+ | **Hover** | Opacity change or shadow | `filled`: 92% opacity + level1 shadow<br />`outlined`: 8% primary background<br />`elevated`: Increase shadow to level2 |
297
+ | **Active** | Further opacity/shadow change | `filled`: 88% opacity<br />`outlined`: 12% primary background |
298
+ | **Focus** | 2px outline | Primary color outline, 2px offset |
299
+ | **Disabled** | 38% opacity, no interaction | Cannot be clicked, greyed out appearance |
265
300
 
266
301
  ## Responsive Considerations
267
302