@lglab/compose-ui-mcp 0.0.1
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 +11 -0
- package/dist/assets/llms/accordion.md +184 -0
- package/dist/assets/llms/alert-dialog.md +306 -0
- package/dist/assets/llms/autocomplete.md +756 -0
- package/dist/assets/llms/avatar.md +166 -0
- package/dist/assets/llms/badge.md +478 -0
- package/dist/assets/llms/button.md +238 -0
- package/dist/assets/llms/card.md +264 -0
- package/dist/assets/llms/checkbox-group.md +158 -0
- package/dist/assets/llms/checkbox.md +83 -0
- package/dist/assets/llms/collapsible.md +165 -0
- package/dist/assets/llms/combobox.md +1255 -0
- package/dist/assets/llms/context-menu.md +371 -0
- package/dist/assets/llms/dialog.md +592 -0
- package/dist/assets/llms/drawer.md +437 -0
- package/dist/assets/llms/field.md +74 -0
- package/dist/assets/llms/form.md +1931 -0
- package/dist/assets/llms/input.md +47 -0
- package/dist/assets/llms/menu.md +484 -0
- package/dist/assets/llms/menubar.md +804 -0
- package/dist/assets/llms/meter.md +181 -0
- package/dist/assets/llms/navigation-menu.md +187 -0
- package/dist/assets/llms/number-field.md +243 -0
- package/dist/assets/llms/pagination.md +514 -0
- package/dist/assets/llms/popover.md +206 -0
- package/dist/assets/llms/preview-card.md +146 -0
- package/dist/assets/llms/progress.md +60 -0
- package/dist/assets/llms/radio-group.md +105 -0
- package/dist/assets/llms/scroll-area.md +132 -0
- package/dist/assets/llms/select.md +276 -0
- package/dist/assets/llms/separator.md +49 -0
- package/dist/assets/llms/skeleton.md +96 -0
- package/dist/assets/llms/slider.md +161 -0
- package/dist/assets/llms/switch.md +101 -0
- package/dist/assets/llms/table.md +1325 -0
- package/dist/assets/llms/tabs.md +327 -0
- package/dist/assets/llms/textarea.md +38 -0
- package/dist/assets/llms/toast.md +349 -0
- package/dist/assets/llms/toggle-group.md +261 -0
- package/dist/assets/llms/toggle.md +161 -0
- package/dist/assets/llms/toolbar.md +148 -0
- package/dist/assets/llms/tooltip.md +486 -0
- package/dist/assets/llms-full.txt +14515 -0
- package/dist/assets/llms.txt +65 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +161 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
A common form component for choosing a predefined value in a dropdown menu.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { SelectRoot, SelectTrigger, SelectValue, SelectIcon, SelectBackdrop, SelectPortal, SelectPositioner, SelectPopup, SelectList, SelectArrow, SelectItem, SelectItemText, SelectItemIndicator, SelectGroup, SelectGroupLabel, SelectScrollUpArrow, SelectScrollDownArrow, SelectSeparator } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Default
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { FieldLabel, FieldRoot } from '@lglab/compose-ui/field'
|
|
23
|
+
import {
|
|
24
|
+
SelectIcon,
|
|
25
|
+
SelectItem,
|
|
26
|
+
SelectItemIndicator,
|
|
27
|
+
SelectItemText,
|
|
28
|
+
SelectList,
|
|
29
|
+
SelectPopup,
|
|
30
|
+
SelectPortal,
|
|
31
|
+
SelectPositioner,
|
|
32
|
+
SelectRoot,
|
|
33
|
+
SelectScrollDownArrow,
|
|
34
|
+
SelectScrollUpArrow,
|
|
35
|
+
SelectTrigger,
|
|
36
|
+
SelectValue,
|
|
37
|
+
} from '@lglab/compose-ui/select'
|
|
38
|
+
import { Check, ChevronsUpDown } from 'lucide-react'
|
|
39
|
+
|
|
40
|
+
const apples = [
|
|
41
|
+
{ label: 'Gala', value: 'gala' },
|
|
42
|
+
{ label: 'Fuji', value: 'fuji' },
|
|
43
|
+
{ label: 'Honeycrisp', value: 'honeycrisp' },
|
|
44
|
+
{ label: 'Granny Smith', value: 'granny-smith' },
|
|
45
|
+
{ label: 'Pink Lady', value: 'pink-lady' },
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
export default function DefaultExample() {
|
|
49
|
+
return (
|
|
50
|
+
<FieldRoot className='flex flex-col gap-1'>
|
|
51
|
+
<FieldLabel nativeLabel={false} render={<div />}>
|
|
52
|
+
Apple
|
|
53
|
+
</FieldLabel>
|
|
54
|
+
<SelectRoot items={apples}>
|
|
55
|
+
<SelectTrigger>
|
|
56
|
+
<SelectValue placeholder='Select apple' />
|
|
57
|
+
<SelectIcon>
|
|
58
|
+
<ChevronsUpDown className='size-4' />
|
|
59
|
+
</SelectIcon>
|
|
60
|
+
</SelectTrigger>
|
|
61
|
+
<SelectPortal>
|
|
62
|
+
<SelectPositioner>
|
|
63
|
+
<SelectPopup>
|
|
64
|
+
<SelectScrollUpArrow />
|
|
65
|
+
<SelectList>
|
|
66
|
+
{apples.map(({ label, value }) => (
|
|
67
|
+
<SelectItem key={label} value={value}>
|
|
68
|
+
<SelectItemText>{label}</SelectItemText>
|
|
69
|
+
<SelectItemIndicator>
|
|
70
|
+
<Check className='size-3.5' />
|
|
71
|
+
</SelectItemIndicator>
|
|
72
|
+
</SelectItem>
|
|
73
|
+
))}
|
|
74
|
+
</SelectList>
|
|
75
|
+
<SelectScrollDownArrow />
|
|
76
|
+
</SelectPopup>
|
|
77
|
+
</SelectPositioner>
|
|
78
|
+
</SelectPortal>
|
|
79
|
+
</SelectRoot>
|
|
80
|
+
</FieldRoot>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Multiple Selection
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { FieldLabel, FieldRoot } from '@lglab/compose-ui/field'
|
|
89
|
+
import {
|
|
90
|
+
SelectIcon,
|
|
91
|
+
SelectItem,
|
|
92
|
+
SelectItemIndicator,
|
|
93
|
+
SelectItemText,
|
|
94
|
+
SelectList,
|
|
95
|
+
SelectPopup,
|
|
96
|
+
SelectPortal,
|
|
97
|
+
SelectPositioner,
|
|
98
|
+
SelectRoot,
|
|
99
|
+
SelectTrigger,
|
|
100
|
+
SelectValue,
|
|
101
|
+
} from '@lglab/compose-ui/select'
|
|
102
|
+
import { Check, ChevronsUpDown } from 'lucide-react'
|
|
103
|
+
|
|
104
|
+
const languages = {
|
|
105
|
+
javascript: 'JavaScript',
|
|
106
|
+
typescript: 'TypeScript',
|
|
107
|
+
python: 'Python',
|
|
108
|
+
java: 'Java',
|
|
109
|
+
csharp: 'C#',
|
|
110
|
+
php: 'PHP',
|
|
111
|
+
cpp: 'C++',
|
|
112
|
+
rust: 'Rust',
|
|
113
|
+
go: 'Go',
|
|
114
|
+
swift: 'Swift',
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
type Language = keyof typeof languages
|
|
118
|
+
|
|
119
|
+
const values = Object.keys(languages) as Language[]
|
|
120
|
+
|
|
121
|
+
function renderValue(value: Language[]) {
|
|
122
|
+
if (value.length === 0) {
|
|
123
|
+
return 'Select languages…'
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const firstLanguage = languages[value[0]]
|
|
127
|
+
const additionalLanguages = value.length > 1 ? ` (+${value.length - 1} more)` : ''
|
|
128
|
+
return firstLanguage + additionalLanguages
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default function MultipleExample() {
|
|
132
|
+
return (
|
|
133
|
+
<FieldRoot className='flex flex-col gap-1'>
|
|
134
|
+
<FieldLabel nativeLabel={false} render={<div />}>
|
|
135
|
+
Languages
|
|
136
|
+
</FieldLabel>
|
|
137
|
+
<SelectRoot multiple defaultValue={['javascript', 'typescript']}>
|
|
138
|
+
<SelectTrigger>
|
|
139
|
+
<SelectValue>{renderValue}</SelectValue>
|
|
140
|
+
<SelectIcon>
|
|
141
|
+
<ChevronsUpDown className='size-4' />
|
|
142
|
+
</SelectIcon>
|
|
143
|
+
</SelectTrigger>
|
|
144
|
+
<SelectPortal>
|
|
145
|
+
<SelectPositioner alignItemWithTrigger={false}>
|
|
146
|
+
<SelectPopup>
|
|
147
|
+
<SelectList>
|
|
148
|
+
{values.map((value) => (
|
|
149
|
+
<SelectItem key={value} value={value}>
|
|
150
|
+
<SelectItemText>{languages[value]}</SelectItemText>
|
|
151
|
+
<SelectItemIndicator>
|
|
152
|
+
<Check className='size-3.5' />
|
|
153
|
+
</SelectItemIndicator>
|
|
154
|
+
</SelectItem>
|
|
155
|
+
))}
|
|
156
|
+
</SelectList>
|
|
157
|
+
</SelectPopup>
|
|
158
|
+
</SelectPositioner>
|
|
159
|
+
</SelectPortal>
|
|
160
|
+
</SelectRoot>
|
|
161
|
+
</FieldRoot>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Object Values
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { FieldLabel, FieldRoot } from '@lglab/compose-ui/field'
|
|
170
|
+
import {
|
|
171
|
+
SelectIcon,
|
|
172
|
+
SelectItem,
|
|
173
|
+
SelectItemIndicator,
|
|
174
|
+
SelectItemText,
|
|
175
|
+
SelectList,
|
|
176
|
+
SelectPopup,
|
|
177
|
+
SelectPortal,
|
|
178
|
+
SelectPositioner,
|
|
179
|
+
SelectRoot,
|
|
180
|
+
SelectScrollDownArrow,
|
|
181
|
+
SelectScrollUpArrow,
|
|
182
|
+
SelectTrigger,
|
|
183
|
+
SelectValue,
|
|
184
|
+
} from '@lglab/compose-ui/select'
|
|
185
|
+
import { Check, ChevronsUpDown } from 'lucide-react'
|
|
186
|
+
|
|
187
|
+
interface ShippingMethod {
|
|
188
|
+
id: string
|
|
189
|
+
name: string
|
|
190
|
+
duration: string
|
|
191
|
+
price: string
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const shippingMethods: ShippingMethod[] = [
|
|
195
|
+
{
|
|
196
|
+
id: 'standard',
|
|
197
|
+
name: 'Standard',
|
|
198
|
+
duration: 'Delivers in 4-6 business days',
|
|
199
|
+
price: '$4.99',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 'express',
|
|
203
|
+
name: 'Express',
|
|
204
|
+
duration: 'Delivers in 2-3 business days',
|
|
205
|
+
price: '$9.99',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: 'overnight',
|
|
209
|
+
name: 'Overnight',
|
|
210
|
+
duration: 'Delivers next business day',
|
|
211
|
+
price: '$19.99',
|
|
212
|
+
},
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
export default function ObjectValuesExample() {
|
|
216
|
+
return (
|
|
217
|
+
<FieldRoot className='flex flex-col gap-1'>
|
|
218
|
+
<FieldLabel nativeLabel={false} render={<div />}>
|
|
219
|
+
Shipping method
|
|
220
|
+
</FieldLabel>
|
|
221
|
+
<SelectRoot<ShippingMethod>
|
|
222
|
+
defaultValue={shippingMethods[0]}
|
|
223
|
+
itemToStringValue={(item) => item.id}
|
|
224
|
+
>
|
|
225
|
+
<SelectTrigger className='min-h-10 items-start py-2'>
|
|
226
|
+
<SelectValue>
|
|
227
|
+
{(method: ShippingMethod) => (
|
|
228
|
+
<span className='flex flex-col items-start text-left'>
|
|
229
|
+
<span className='text-base font-medium'>{method.name}</span>
|
|
230
|
+
<span className='text-sm'>
|
|
231
|
+
{method.duration} ({method.price})
|
|
232
|
+
</span>
|
|
233
|
+
</span>
|
|
234
|
+
)}
|
|
235
|
+
</SelectValue>
|
|
236
|
+
<SelectIcon className='self-center'>
|
|
237
|
+
<ChevronsUpDown className='size-4' />
|
|
238
|
+
</SelectIcon>
|
|
239
|
+
</SelectTrigger>
|
|
240
|
+
<SelectPortal>
|
|
241
|
+
<SelectPositioner>
|
|
242
|
+
<SelectPopup>
|
|
243
|
+
<SelectScrollUpArrow />
|
|
244
|
+
<SelectList>
|
|
245
|
+
{shippingMethods.map((method) => (
|
|
246
|
+
<SelectItem
|
|
247
|
+
key={method.id}
|
|
248
|
+
value={method}
|
|
249
|
+
className='items-start py-2.5'
|
|
250
|
+
>
|
|
251
|
+
<SelectItemText className='flex flex-col items-start text-left'>
|
|
252
|
+
<span className='text-base font-medium'>{method.name}</span>
|
|
253
|
+
<span className='text-sm'>
|
|
254
|
+
{method.duration} ({method.price})
|
|
255
|
+
</span>
|
|
256
|
+
</SelectItemText>
|
|
257
|
+
<SelectItemIndicator className='relative top-[0.4em]'>
|
|
258
|
+
<Check className='size-3.5' />
|
|
259
|
+
</SelectItemIndicator>
|
|
260
|
+
</SelectItem>
|
|
261
|
+
))}
|
|
262
|
+
</SelectList>
|
|
263
|
+
<SelectScrollDownArrow />
|
|
264
|
+
</SelectPopup>
|
|
265
|
+
</SelectPositioner>
|
|
266
|
+
</SelectPortal>
|
|
267
|
+
</SelectRoot>
|
|
268
|
+
</FieldRoot>
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Resources
|
|
274
|
+
|
|
275
|
+
- [Base UI Select Documentation](https://base-ui.com/react/components/select)
|
|
276
|
+
- [API Reference](https://base-ui.com/react/components/select#api-reference)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Separator
|
|
2
|
+
|
|
3
|
+
A separator element accessible to screen readers.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Separator } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Basic
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Separator } from '@lglab/compose-ui/separator'
|
|
23
|
+
|
|
24
|
+
export default function DefaultExample() {
|
|
25
|
+
return (
|
|
26
|
+
<div className='space-y-2'>
|
|
27
|
+
<div>
|
|
28
|
+
<h4 className='font-medium'>Compose UI</h4>
|
|
29
|
+
<p className='text-sm text-muted-foreground'>
|
|
30
|
+
An open-source UI component library.
|
|
31
|
+
</p>
|
|
32
|
+
</div>
|
|
33
|
+
<Separator />
|
|
34
|
+
<div className='flex h-5 items-center space-x-4 text-sm'>
|
|
35
|
+
<div>Overview</div>
|
|
36
|
+
<Separator orientation='vertical' />
|
|
37
|
+
<div>Quick Start</div>
|
|
38
|
+
<Separator orientation='vertical' />
|
|
39
|
+
<div>Theming</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Resources
|
|
47
|
+
|
|
48
|
+
- [Base UI Separator Documentation](https://base-ui.com/react/components/separator)
|
|
49
|
+
- [API Reference](https://base-ui.com/react/components/separator#api-reference)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
A placeholder component for content that is loading. Use className to define custom shapes and sizes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Skeleton } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Default
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Skeleton } from '@lglab/compose-ui/skeleton'
|
|
23
|
+
|
|
24
|
+
export default function DefaultExample() {
|
|
25
|
+
return (
|
|
26
|
+
<div className='flex items-center gap-4'>
|
|
27
|
+
<Skeleton className='size-12 rounded-full' />
|
|
28
|
+
<div className='space-y-2'>
|
|
29
|
+
<Skeleton className='h-4 w-[230px]' />
|
|
30
|
+
<Skeleton className='h-4 w-[190px]' />
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Shimmer Animation
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { Skeleton } from '@lglab/compose-ui/skeleton'
|
|
41
|
+
|
|
42
|
+
export default function ShimmerExample() {
|
|
43
|
+
return (
|
|
44
|
+
<div className='flex items-center gap-4'>
|
|
45
|
+
<Skeleton animation='shimmer' className='size-12 rounded-full' />
|
|
46
|
+
<div className='space-y-2'>
|
|
47
|
+
<Skeleton animation='shimmer' className='h-4 w-[230px]' />
|
|
48
|
+
<Skeleton animation='shimmer' className='h-4 w-[190px]' />
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Card
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { CardContent, CardRoot } from '@lglab/compose-ui/card'
|
|
59
|
+
import { Skeleton } from '@lglab/compose-ui/skeleton'
|
|
60
|
+
|
|
61
|
+
export default function CardExample() {
|
|
62
|
+
return (
|
|
63
|
+
<CardRoot className='w-[300px] overflow-hidden'>
|
|
64
|
+
<Skeleton className='h-[125px] w-full' />
|
|
65
|
+
<CardContent className='space-y-2 pt-4'>
|
|
66
|
+
<Skeleton className='h-4 w-full' />
|
|
67
|
+
<Skeleton className='h-4 w-3/4' />
|
|
68
|
+
</CardContent>
|
|
69
|
+
</CardRoot>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### No Animation
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { CardContent, CardRoot } from '@lglab/compose-ui/card'
|
|
78
|
+
import { Skeleton } from '@lglab/compose-ui/skeleton'
|
|
79
|
+
|
|
80
|
+
export default function NoAnimationExample() {
|
|
81
|
+
return (
|
|
82
|
+
<CardRoot className='w-[300px] overflow-hidden'>
|
|
83
|
+
<Skeleton animation='none' className='h-[125px] w-full' />
|
|
84
|
+
<CardContent className='space-y-2 pt-4'>
|
|
85
|
+
<Skeleton animation='none' className='h-4 w-full' />
|
|
86
|
+
<Skeleton animation='none' className='h-4 w-3/4' />
|
|
87
|
+
</CardContent>
|
|
88
|
+
</CardRoot>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Resources
|
|
94
|
+
|
|
95
|
+
- [Base UI Skeleton Documentation](https://base-ui.com/react/components/skeleton)
|
|
96
|
+
- [API Reference](https://base-ui.com/react/components/skeleton#api-reference)
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Slider
|
|
2
|
+
|
|
3
|
+
A control for selecting a value or range from a continuous or discrete set of values.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { SliderRoot, SliderValue, SliderControl, SliderTrack, SliderIndicator, SliderThumb } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Basic
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import {
|
|
23
|
+
SliderControl,
|
|
24
|
+
SliderIndicator,
|
|
25
|
+
SliderRoot,
|
|
26
|
+
SliderThumb,
|
|
27
|
+
SliderTrack,
|
|
28
|
+
SliderValue,
|
|
29
|
+
} from '@lglab/compose-ui/slider'
|
|
30
|
+
|
|
31
|
+
export default function DefaultExample() {
|
|
32
|
+
return (
|
|
33
|
+
<SliderRoot
|
|
34
|
+
className='mx-auto w-full max-w-md space-y-0.5'
|
|
35
|
+
defaultValue={43}
|
|
36
|
+
thumbAlignment='edge'
|
|
37
|
+
>
|
|
38
|
+
<div className='flex items-center justify-between text-sm'>
|
|
39
|
+
<span className='font-medium'>Volume</span>
|
|
40
|
+
<SliderValue className='tabular-nums' />
|
|
41
|
+
</div>
|
|
42
|
+
<SliderControl>
|
|
43
|
+
<SliderTrack>
|
|
44
|
+
<SliderIndicator />
|
|
45
|
+
<SliderThumb aria-label='Volume' />
|
|
46
|
+
</SliderTrack>
|
|
47
|
+
</SliderControl>
|
|
48
|
+
</SliderRoot>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Range
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import {
|
|
57
|
+
SliderControl,
|
|
58
|
+
SliderIndicator,
|
|
59
|
+
SliderRoot,
|
|
60
|
+
SliderThumb,
|
|
61
|
+
SliderTrack,
|
|
62
|
+
SliderValue,
|
|
63
|
+
} from '@lglab/compose-ui/slider'
|
|
64
|
+
|
|
65
|
+
export default function RangeExample() {
|
|
66
|
+
return (
|
|
67
|
+
<SliderRoot
|
|
68
|
+
className='mx-auto w-full max-w-md space-y-0.5'
|
|
69
|
+
defaultValue={[40, 80]}
|
|
70
|
+
min={10}
|
|
71
|
+
max={120}
|
|
72
|
+
format={{ style: 'currency', currency: 'EUR' }}
|
|
73
|
+
>
|
|
74
|
+
<div className='flex items-center justify-between text-sm'>
|
|
75
|
+
<span className='font-medium'>Price Range</span>
|
|
76
|
+
<SliderValue className='tabular-nums' />
|
|
77
|
+
</div>
|
|
78
|
+
<SliderControl>
|
|
79
|
+
<SliderTrack>
|
|
80
|
+
<SliderIndicator />
|
|
81
|
+
<SliderThumb aria-label='Minimum price' />
|
|
82
|
+
<SliderThumb aria-label='Maximum price' />
|
|
83
|
+
</SliderTrack>
|
|
84
|
+
</SliderControl>
|
|
85
|
+
</SliderRoot>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Step
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import {
|
|
94
|
+
SliderControl,
|
|
95
|
+
SliderIndicator,
|
|
96
|
+
SliderRoot,
|
|
97
|
+
SliderThumb,
|
|
98
|
+
SliderTrack,
|
|
99
|
+
SliderValue,
|
|
100
|
+
} from '@lglab/compose-ui/slider'
|
|
101
|
+
|
|
102
|
+
export default function StepExample() {
|
|
103
|
+
return (
|
|
104
|
+
<SliderRoot
|
|
105
|
+
className='mx-auto w-full max-w-md space-y-0.5'
|
|
106
|
+
defaultValue={100}
|
|
107
|
+
min={25}
|
|
108
|
+
max={200}
|
|
109
|
+
step={25}
|
|
110
|
+
format={{ style: 'unit', unit: 'percent' }}
|
|
111
|
+
>
|
|
112
|
+
<div className='flex items-center justify-between text-sm'>
|
|
113
|
+
<span className='font-medium'>Zoom Level</span>
|
|
114
|
+
<SliderValue className='tabular-nums' />
|
|
115
|
+
</div>
|
|
116
|
+
<SliderControl>
|
|
117
|
+
<SliderTrack>
|
|
118
|
+
<SliderIndicator />
|
|
119
|
+
<SliderThumb aria-label='Zoom level' />
|
|
120
|
+
</SliderTrack>
|
|
121
|
+
</SliderControl>
|
|
122
|
+
</SliderRoot>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Vertical
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import {
|
|
131
|
+
SliderControl,
|
|
132
|
+
SliderIndicator,
|
|
133
|
+
SliderRoot,
|
|
134
|
+
SliderThumb,
|
|
135
|
+
SliderTrack,
|
|
136
|
+
SliderValue,
|
|
137
|
+
} from '@lglab/compose-ui/slider'
|
|
138
|
+
|
|
139
|
+
export default function VerticalExample() {
|
|
140
|
+
return (
|
|
141
|
+
<SliderRoot
|
|
142
|
+
className='mx-auto flex h-40 w-full max-w-md flex-col items-center'
|
|
143
|
+
orientation='vertical'
|
|
144
|
+
defaultValue={50}
|
|
145
|
+
>
|
|
146
|
+
<SliderValue className='mb-2 text-sm' />
|
|
147
|
+
<SliderControl className='h-full w-fit flex-col py-0 px-3'>
|
|
148
|
+
<SliderTrack className='h-full w-1.5'>
|
|
149
|
+
<SliderIndicator />
|
|
150
|
+
<SliderThumb aria-label='Value' />
|
|
151
|
+
</SliderTrack>
|
|
152
|
+
</SliderControl>
|
|
153
|
+
</SliderRoot>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Resources
|
|
159
|
+
|
|
160
|
+
- [Base UI Slider Documentation](https://base-ui.com/react/components/slider)
|
|
161
|
+
- [API Reference](https://base-ui.com/react/components/slider#api-reference)
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
A control that indicates whether a setting is on or off.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { SwitchRoot, SwitchThumb } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Default
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { SwitchRoot, SwitchThumb } from '@lglab/compose-ui/switch'
|
|
23
|
+
|
|
24
|
+
export default function DefaultExample() {
|
|
25
|
+
return (
|
|
26
|
+
<SwitchRoot>
|
|
27
|
+
<SwitchThumb />
|
|
28
|
+
</SwitchRoot>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Checked
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { SwitchRoot, SwitchThumb } from '@lglab/compose-ui/switch'
|
|
37
|
+
|
|
38
|
+
export default function CheckedExample() {
|
|
39
|
+
return (
|
|
40
|
+
<SwitchRoot defaultChecked>
|
|
41
|
+
<SwitchThumb />
|
|
42
|
+
</SwitchRoot>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Controlled
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { SwitchRoot, SwitchThumb } from '@lglab/compose-ui/switch'
|
|
51
|
+
import { useState } from 'react'
|
|
52
|
+
|
|
53
|
+
export default function ControlledExample() {
|
|
54
|
+
const [checked, setChecked] = useState(false)
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className='flex items-center gap-2'>
|
|
58
|
+
<SwitchRoot checked={checked} onCheckedChange={setChecked}>
|
|
59
|
+
<SwitchThumb />
|
|
60
|
+
</SwitchRoot>
|
|
61
|
+
<span className='text-sm font-medium'>
|
|
62
|
+
{checked ? 'Notifications enabled' : 'Notifications disabled'}
|
|
63
|
+
</span>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Disabled
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { SwitchRoot, SwitchThumb } from '@lglab/compose-ui/switch'
|
|
73
|
+
|
|
74
|
+
export default function DisabledExample() {
|
|
75
|
+
return (
|
|
76
|
+
<div className='flex flex-col gap-4'>
|
|
77
|
+
<div className='flex items-center gap-2'>
|
|
78
|
+
<SwitchRoot disabled>
|
|
79
|
+
<SwitchThumb />
|
|
80
|
+
</SwitchRoot>
|
|
81
|
+
<span className='text-sm font-medium text-muted-foreground'>
|
|
82
|
+
Disabled unchecked
|
|
83
|
+
</span>
|
|
84
|
+
</div>
|
|
85
|
+
<div className='flex items-center gap-2'>
|
|
86
|
+
<SwitchRoot disabled defaultChecked>
|
|
87
|
+
<SwitchThumb />
|
|
88
|
+
</SwitchRoot>
|
|
89
|
+
<span className='text-sm font-medium text-muted-foreground'>
|
|
90
|
+
Disabled checked
|
|
91
|
+
</span>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Resources
|
|
99
|
+
|
|
100
|
+
- [Base UI Switch Documentation](https://base-ui.com/react/components/switch)
|
|
101
|
+
- [API Reference](https://base-ui.com/react/components/switch#api-reference)
|