@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,181 @@
|
|
|
1
|
+
# Meter
|
|
2
|
+
|
|
3
|
+
A graphical display of a numeric value within a defined range.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { MeterRoot, MeterTrack, MeterIndicator, MeterValue, MeterLabel } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Basic
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import {
|
|
23
|
+
MeterIndicator,
|
|
24
|
+
MeterLabel,
|
|
25
|
+
MeterRoot,
|
|
26
|
+
MeterTrack,
|
|
27
|
+
MeterValue,
|
|
28
|
+
} from '@lglab/compose-ui/meter'
|
|
29
|
+
|
|
30
|
+
export default function BasicExample() {
|
|
31
|
+
return (
|
|
32
|
+
<div className='space-y-6 w-full max-w-md mx-auto'>
|
|
33
|
+
<MeterRoot value={24}>
|
|
34
|
+
<div className='flex items-center justify-between mb-2'>
|
|
35
|
+
<MeterLabel>Storage Used</MeterLabel>
|
|
36
|
+
<MeterValue />
|
|
37
|
+
</div>
|
|
38
|
+
<MeterTrack>
|
|
39
|
+
<MeterIndicator />
|
|
40
|
+
</MeterTrack>
|
|
41
|
+
</MeterRoot>
|
|
42
|
+
|
|
43
|
+
<MeterRoot value={65}>
|
|
44
|
+
<div className='flex items-center justify-between mb-2'>
|
|
45
|
+
<MeterLabel>CPU Usage</MeterLabel>
|
|
46
|
+
<MeterValue />
|
|
47
|
+
</div>
|
|
48
|
+
<MeterTrack>
|
|
49
|
+
<MeterIndicator />
|
|
50
|
+
</MeterTrack>
|
|
51
|
+
</MeterRoot>
|
|
52
|
+
|
|
53
|
+
<MeterRoot value={90}>
|
|
54
|
+
<div className='flex items-center justify-between mb-2'>
|
|
55
|
+
<MeterLabel>Memory Usage</MeterLabel>
|
|
56
|
+
<MeterValue />
|
|
57
|
+
</div>
|
|
58
|
+
<MeterTrack>
|
|
59
|
+
<MeterIndicator />
|
|
60
|
+
</MeterTrack>
|
|
61
|
+
</MeterRoot>
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Animated
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import {
|
|
71
|
+
MeterIndicator,
|
|
72
|
+
MeterLabel,
|
|
73
|
+
MeterRoot,
|
|
74
|
+
MeterTrack,
|
|
75
|
+
MeterValue,
|
|
76
|
+
} from '@lglab/compose-ui/meter'
|
|
77
|
+
|
|
78
|
+
export default function AnimatedExample() {
|
|
79
|
+
return (
|
|
80
|
+
<div className='space-y-6 w-full max-w-md mx-auto'>
|
|
81
|
+
<MeterRoot value={24} animated>
|
|
82
|
+
<div className='flex items-center justify-between mb-2'>
|
|
83
|
+
<MeterLabel>Storage Used</MeterLabel>
|
|
84
|
+
<MeterValue />
|
|
85
|
+
</div>
|
|
86
|
+
<MeterTrack>
|
|
87
|
+
<MeterIndicator />
|
|
88
|
+
</MeterTrack>
|
|
89
|
+
</MeterRoot>
|
|
90
|
+
|
|
91
|
+
<MeterRoot value={65} animated>
|
|
92
|
+
<div className='flex items-center justify-between mb-2'>
|
|
93
|
+
<MeterLabel>CPU Usage</MeterLabel>
|
|
94
|
+
<MeterValue />
|
|
95
|
+
</div>
|
|
96
|
+
<MeterTrack>
|
|
97
|
+
<MeterIndicator />
|
|
98
|
+
</MeterTrack>
|
|
99
|
+
</MeterRoot>
|
|
100
|
+
|
|
101
|
+
<MeterRoot value={90} animated>
|
|
102
|
+
<div className='flex items-center justify-between mb-2'>
|
|
103
|
+
<MeterLabel>Memory Usage</MeterLabel>
|
|
104
|
+
<MeterValue />
|
|
105
|
+
</div>
|
|
106
|
+
<MeterTrack>
|
|
107
|
+
<MeterIndicator />
|
|
108
|
+
</MeterTrack>
|
|
109
|
+
</MeterRoot>
|
|
110
|
+
</div>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Custom Format
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import {
|
|
119
|
+
MeterIndicator,
|
|
120
|
+
MeterLabel,
|
|
121
|
+
MeterRoot,
|
|
122
|
+
MeterTrack,
|
|
123
|
+
MeterValue,
|
|
124
|
+
} from '@lglab/compose-ui/meter'
|
|
125
|
+
|
|
126
|
+
export default function CustomFormatExample() {
|
|
127
|
+
return (
|
|
128
|
+
<div className='space-y-6 w-full max-w-md mx-auto'>
|
|
129
|
+
<MeterRoot
|
|
130
|
+
value={2500}
|
|
131
|
+
min={0}
|
|
132
|
+
max={5000}
|
|
133
|
+
format={{ style: 'currency', currency: 'USD', maximumFractionDigits: 0 }}
|
|
134
|
+
>
|
|
135
|
+
<div className='flex items-center justify-between mb-2'>
|
|
136
|
+
<MeterLabel>Budget Used</MeterLabel>
|
|
137
|
+
<MeterValue />
|
|
138
|
+
</div>
|
|
139
|
+
<MeterTrack>
|
|
140
|
+
<MeterIndicator />
|
|
141
|
+
</MeterTrack>
|
|
142
|
+
</MeterRoot>
|
|
143
|
+
|
|
144
|
+
<MeterRoot
|
|
145
|
+
value={3.5}
|
|
146
|
+
min={0}
|
|
147
|
+
max={5}
|
|
148
|
+
format={{ style: 'decimal', minimumFractionDigits: 1, maximumFractionDigits: 1 }}
|
|
149
|
+
>
|
|
150
|
+
<div className='flex items-center justify-between mb-2'>
|
|
151
|
+
<MeterLabel>Rating</MeterLabel>
|
|
152
|
+
<MeterValue />
|
|
153
|
+
</div>
|
|
154
|
+
<MeterTrack>
|
|
155
|
+
<MeterIndicator />
|
|
156
|
+
</MeterTrack>
|
|
157
|
+
</MeterRoot>
|
|
158
|
+
|
|
159
|
+
<MeterRoot
|
|
160
|
+
value={75}
|
|
161
|
+
min={0}
|
|
162
|
+
max={100}
|
|
163
|
+
getAriaValueText={(formattedValue, value) => `${value}% complete`}
|
|
164
|
+
>
|
|
165
|
+
<div className='flex items-center justify-between mb-2'>
|
|
166
|
+
<MeterLabel>Progress</MeterLabel>
|
|
167
|
+
<MeterValue />
|
|
168
|
+
</div>
|
|
169
|
+
<MeterTrack>
|
|
170
|
+
<MeterIndicator />
|
|
171
|
+
</MeterTrack>
|
|
172
|
+
</MeterRoot>
|
|
173
|
+
</div>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Resources
|
|
179
|
+
|
|
180
|
+
- [Base UI Meter Documentation](https://base-ui.com/react/components/meter)
|
|
181
|
+
- [API Reference](https://base-ui.com/react/components/meter#api-reference)
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Navigation Menu
|
|
2
|
+
|
|
3
|
+
A navigation component with support for dropdowns and submenus.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { NavigationMenuRoot, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuIcon, NavigationMenuContent, NavigationMenuLink, NavigationMenuPortal, NavigationMenuPositioner, NavigationMenuPopup, NavigationMenuViewport, NavigationMenuArrow, NavigationMenuBackdrop } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Basic
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import {
|
|
23
|
+
NavigationMenuArrow,
|
|
24
|
+
NavigationMenuContent,
|
|
25
|
+
NavigationMenuIcon,
|
|
26
|
+
NavigationMenuItem,
|
|
27
|
+
NavigationMenuLink,
|
|
28
|
+
NavigationMenuList,
|
|
29
|
+
NavigationMenuPopup,
|
|
30
|
+
NavigationMenuPortal,
|
|
31
|
+
NavigationMenuPositioner,
|
|
32
|
+
NavigationMenuRoot,
|
|
33
|
+
NavigationMenuTrigger,
|
|
34
|
+
NavigationMenuViewport,
|
|
35
|
+
} from '@lglab/compose-ui/navigation-menu'
|
|
36
|
+
import { ChevronDown, ChevronRight } from 'lucide-react'
|
|
37
|
+
import Link from 'next/link'
|
|
38
|
+
|
|
39
|
+
const gettingStartedLinks = [
|
|
40
|
+
{
|
|
41
|
+
href: '/overview/quick-start',
|
|
42
|
+
title: 'Quick Start',
|
|
43
|
+
description: 'Get started with Compose UI in your React project.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
href: '/overview/composition',
|
|
47
|
+
title: 'Composition',
|
|
48
|
+
description: 'Learn about composable components and architecture.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
href: '/overview/accessibility',
|
|
52
|
+
title: 'Accessibility',
|
|
53
|
+
description: 'Built-in ARIA, keyboard navigation, and focus management.',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
href: '/overview/theming',
|
|
57
|
+
title: 'Theming',
|
|
58
|
+
description: 'Customize colors, typography, and dark mode.',
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
const componentsLinks = [
|
|
63
|
+
{ href: '/components/button', title: 'Button' },
|
|
64
|
+
{ href: '/components/card', title: 'Card' },
|
|
65
|
+
{ href: '/components/dialog', title: 'Dialog' },
|
|
66
|
+
{ href: '/components/menu', title: 'Menu' },
|
|
67
|
+
{ href: '/components/navigation-menu', title: 'Navigation Menu' },
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
const moreComponentsLinks = [
|
|
71
|
+
{ href: '/components/accordion', title: 'Accordion' },
|
|
72
|
+
{ href: '/components/tabs', title: 'Tabs' },
|
|
73
|
+
{ href: '/components/tooltip', title: 'Tooltip' },
|
|
74
|
+
{ href: '/components/popover', title: 'Popover' },
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
export default function NavigationMenuExample() {
|
|
78
|
+
return (
|
|
79
|
+
<NavigationMenuRoot>
|
|
80
|
+
<NavigationMenuList className='flex-col sm:flex-row'>
|
|
81
|
+
<NavigationMenuItem value='home'>
|
|
82
|
+
<NavigationMenuLink render={<Link href='/overview/quick-start' />}>
|
|
83
|
+
Home
|
|
84
|
+
</NavigationMenuLink>
|
|
85
|
+
</NavigationMenuItem>
|
|
86
|
+
|
|
87
|
+
<NavigationMenuItem value='getting-started'>
|
|
88
|
+
<NavigationMenuTrigger>
|
|
89
|
+
Getting Started
|
|
90
|
+
<NavigationMenuIcon>
|
|
91
|
+
<ChevronDown className='size-4' />
|
|
92
|
+
</NavigationMenuIcon>
|
|
93
|
+
</NavigationMenuTrigger>
|
|
94
|
+
<NavigationMenuContent className='max-w-[500px]'>
|
|
95
|
+
<ul className='grid gap-1 md:grid-cols-2'>
|
|
96
|
+
{gettingStartedLinks.map((link) => (
|
|
97
|
+
<li key={link.href}>
|
|
98
|
+
<NavigationMenuLink
|
|
99
|
+
render={<Link href={link.href} />}
|
|
100
|
+
className='flex flex-col'
|
|
101
|
+
>
|
|
102
|
+
<div className='font-medium'>{link.title}</div>
|
|
103
|
+
<p className='text-sm text-muted-foreground'>{link.description}</p>
|
|
104
|
+
</NavigationMenuLink>
|
|
105
|
+
</li>
|
|
106
|
+
))}
|
|
107
|
+
</ul>
|
|
108
|
+
</NavigationMenuContent>
|
|
109
|
+
</NavigationMenuItem>
|
|
110
|
+
|
|
111
|
+
<NavigationMenuItem value='components'>
|
|
112
|
+
<NavigationMenuTrigger>
|
|
113
|
+
Components
|
|
114
|
+
<NavigationMenuIcon>
|
|
115
|
+
<ChevronDown className='size-4' />
|
|
116
|
+
</NavigationMenuIcon>
|
|
117
|
+
</NavigationMenuTrigger>
|
|
118
|
+
<NavigationMenuContent className='w-[220px]'>
|
|
119
|
+
<ul className='grid'>
|
|
120
|
+
{componentsLinks.map((link) => (
|
|
121
|
+
<li key={link.href}>
|
|
122
|
+
<NavigationMenuLink render={<Link href={link.href} />}>
|
|
123
|
+
{link.title}
|
|
124
|
+
</NavigationMenuLink>
|
|
125
|
+
</li>
|
|
126
|
+
))}
|
|
127
|
+
<li>
|
|
128
|
+
<NavigationMenuRoot orientation='vertical' className='w-full'>
|
|
129
|
+
<NavigationMenuList className='flex-col items-stretch'>
|
|
130
|
+
<NavigationMenuItem value='more-components'>
|
|
131
|
+
<NavigationMenuTrigger className='w-full justify-between'>
|
|
132
|
+
More Components
|
|
133
|
+
<NavigationMenuIcon>
|
|
134
|
+
<ChevronRight className='size-4' />
|
|
135
|
+
</NavigationMenuIcon>
|
|
136
|
+
</NavigationMenuTrigger>
|
|
137
|
+
<NavigationMenuContent className='w-[200px]'>
|
|
138
|
+
<ul className='grid'>
|
|
139
|
+
{moreComponentsLinks.map((link) => (
|
|
140
|
+
<li key={link.href}>
|
|
141
|
+
<NavigationMenuLink render={<Link href={link.href} />}>
|
|
142
|
+
{link.title}
|
|
143
|
+
</NavigationMenuLink>
|
|
144
|
+
</li>
|
|
145
|
+
))}
|
|
146
|
+
</ul>
|
|
147
|
+
</NavigationMenuContent>
|
|
148
|
+
</NavigationMenuItem>
|
|
149
|
+
</NavigationMenuList>
|
|
150
|
+
|
|
151
|
+
<NavigationMenuPortal>
|
|
152
|
+
<NavigationMenuPositioner side='right' align='start'>
|
|
153
|
+
<NavigationMenuPopup>
|
|
154
|
+
<NavigationMenuViewport />
|
|
155
|
+
</NavigationMenuPopup>
|
|
156
|
+
</NavigationMenuPositioner>
|
|
157
|
+
</NavigationMenuPortal>
|
|
158
|
+
</NavigationMenuRoot>
|
|
159
|
+
</li>
|
|
160
|
+
</ul>
|
|
161
|
+
</NavigationMenuContent>
|
|
162
|
+
</NavigationMenuItem>
|
|
163
|
+
|
|
164
|
+
<NavigationMenuItem value='resources'>
|
|
165
|
+
<NavigationMenuLink render={<Link href='/overview/llms' />}>
|
|
166
|
+
LLMs
|
|
167
|
+
</NavigationMenuLink>
|
|
168
|
+
</NavigationMenuItem>
|
|
169
|
+
</NavigationMenuList>
|
|
170
|
+
|
|
171
|
+
<NavigationMenuPortal>
|
|
172
|
+
<NavigationMenuPositioner>
|
|
173
|
+
<NavigationMenuPopup>
|
|
174
|
+
<NavigationMenuArrow />
|
|
175
|
+
<NavigationMenuViewport />
|
|
176
|
+
</NavigationMenuPopup>
|
|
177
|
+
</NavigationMenuPositioner>
|
|
178
|
+
</NavigationMenuPortal>
|
|
179
|
+
</NavigationMenuRoot>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Resources
|
|
185
|
+
|
|
186
|
+
- [Base UI Navigation Menu Documentation](https://base-ui.com/react/components/navigation-menu)
|
|
187
|
+
- [API Reference](https://base-ui.com/react/components/navigation-menu#api-reference)
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# Number Field
|
|
2
|
+
|
|
3
|
+
A numeric input element with increment and decrement buttons, and a scrub area.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { NumberFieldRoot, NumberFieldScrubArea, NumberFieldScrubAreaCursor, NumberFieldGroup, NumberFieldInput, NumberFieldDecrement, NumberFieldIncrement } 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
|
+
NumberFieldDecrement,
|
|
25
|
+
NumberFieldGroup,
|
|
26
|
+
NumberFieldIncrement,
|
|
27
|
+
NumberFieldInput,
|
|
28
|
+
NumberFieldRoot,
|
|
29
|
+
NumberFieldScrubArea,
|
|
30
|
+
NumberFieldScrubAreaCursor,
|
|
31
|
+
} from '@lglab/compose-ui/number-field'
|
|
32
|
+
import { Minus, MoveHorizontal, Plus } from 'lucide-react'
|
|
33
|
+
|
|
34
|
+
export default function DefaultExample() {
|
|
35
|
+
return (
|
|
36
|
+
<FieldRoot>
|
|
37
|
+
<NumberFieldRoot defaultValue={100}>
|
|
38
|
+
<NumberFieldScrubArea>
|
|
39
|
+
<FieldLabel>Amount</FieldLabel>
|
|
40
|
+
<NumberFieldScrubAreaCursor>
|
|
41
|
+
<MoveHorizontal className='size-4' />
|
|
42
|
+
</NumberFieldScrubAreaCursor>
|
|
43
|
+
</NumberFieldScrubArea>
|
|
44
|
+
|
|
45
|
+
<NumberFieldGroup>
|
|
46
|
+
<NumberFieldDecrement>
|
|
47
|
+
<Minus className='size-4' />
|
|
48
|
+
</NumberFieldDecrement>
|
|
49
|
+
<NumberFieldInput />
|
|
50
|
+
<NumberFieldIncrement>
|
|
51
|
+
<Plus className='size-4' />
|
|
52
|
+
</NumberFieldIncrement>
|
|
53
|
+
</NumberFieldGroup>
|
|
54
|
+
</NumberFieldRoot>
|
|
55
|
+
</FieldRoot>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Min/Max
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { FieldLabel, FieldRoot } from '@lglab/compose-ui/field'
|
|
64
|
+
import {
|
|
65
|
+
NumberFieldDecrement,
|
|
66
|
+
NumberFieldGroup,
|
|
67
|
+
NumberFieldIncrement,
|
|
68
|
+
NumberFieldInput,
|
|
69
|
+
NumberFieldRoot,
|
|
70
|
+
NumberFieldScrubArea,
|
|
71
|
+
NumberFieldScrubAreaCursor,
|
|
72
|
+
} from '@lglab/compose-ui/number-field'
|
|
73
|
+
import { Minus, MoveHorizontal, Plus } from 'lucide-react'
|
|
74
|
+
|
|
75
|
+
export default function MinMaxExample() {
|
|
76
|
+
return (
|
|
77
|
+
<FieldRoot>
|
|
78
|
+
<NumberFieldRoot defaultValue={50} min={0} max={100}>
|
|
79
|
+
<NumberFieldScrubArea>
|
|
80
|
+
<FieldLabel>Percentage (0-100)</FieldLabel>
|
|
81
|
+
<NumberFieldScrubAreaCursor>
|
|
82
|
+
<MoveHorizontal className='size-4' />
|
|
83
|
+
</NumberFieldScrubAreaCursor>
|
|
84
|
+
</NumberFieldScrubArea>
|
|
85
|
+
|
|
86
|
+
<NumberFieldGroup>
|
|
87
|
+
<NumberFieldDecrement>
|
|
88
|
+
<Minus className='size-4' />
|
|
89
|
+
</NumberFieldDecrement>
|
|
90
|
+
<NumberFieldInput />
|
|
91
|
+
<NumberFieldIncrement>
|
|
92
|
+
<Plus className='size-4' />
|
|
93
|
+
</NumberFieldIncrement>
|
|
94
|
+
</NumberFieldGroup>
|
|
95
|
+
</NumberFieldRoot>
|
|
96
|
+
</FieldRoot>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Step
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { FieldLabel, FieldRoot } from '@lglab/compose-ui/field'
|
|
105
|
+
import {
|
|
106
|
+
NumberFieldDecrement,
|
|
107
|
+
NumberFieldGroup,
|
|
108
|
+
NumberFieldIncrement,
|
|
109
|
+
NumberFieldInput,
|
|
110
|
+
NumberFieldRoot,
|
|
111
|
+
NumberFieldScrubArea,
|
|
112
|
+
NumberFieldScrubAreaCursor,
|
|
113
|
+
} from '@lglab/compose-ui/number-field'
|
|
114
|
+
import { Minus, MoveHorizontal, Plus } from 'lucide-react'
|
|
115
|
+
|
|
116
|
+
export default function StepExample() {
|
|
117
|
+
return (
|
|
118
|
+
<FieldRoot>
|
|
119
|
+
<NumberFieldRoot defaultValue={0} step={5}>
|
|
120
|
+
<NumberFieldScrubArea>
|
|
121
|
+
<FieldLabel>Quantity (step: 5)</FieldLabel>
|
|
122
|
+
<NumberFieldScrubAreaCursor>
|
|
123
|
+
<MoveHorizontal className='size-4' />
|
|
124
|
+
</NumberFieldScrubAreaCursor>
|
|
125
|
+
</NumberFieldScrubArea>
|
|
126
|
+
|
|
127
|
+
<NumberFieldGroup>
|
|
128
|
+
<NumberFieldDecrement>
|
|
129
|
+
<Minus className='size-4' />
|
|
130
|
+
</NumberFieldDecrement>
|
|
131
|
+
<NumberFieldInput />
|
|
132
|
+
<NumberFieldIncrement>
|
|
133
|
+
<Plus className='size-4' />
|
|
134
|
+
</NumberFieldIncrement>
|
|
135
|
+
</NumberFieldGroup>
|
|
136
|
+
</NumberFieldRoot>
|
|
137
|
+
</FieldRoot>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Controlled
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import { Button } from '@lglab/compose-ui/button'
|
|
146
|
+
import { FieldLabel, FieldRoot } from '@lglab/compose-ui/field'
|
|
147
|
+
import {
|
|
148
|
+
NumberFieldDecrement,
|
|
149
|
+
NumberFieldGroup,
|
|
150
|
+
NumberFieldIncrement,
|
|
151
|
+
NumberFieldInput,
|
|
152
|
+
NumberFieldRoot,
|
|
153
|
+
NumberFieldScrubArea,
|
|
154
|
+
NumberFieldScrubAreaCursor,
|
|
155
|
+
} from '@lglab/compose-ui/number-field'
|
|
156
|
+
import { Minus, MoveHorizontal, Plus } from 'lucide-react'
|
|
157
|
+
import * as React from 'react'
|
|
158
|
+
|
|
159
|
+
export default function ControlledExample() {
|
|
160
|
+
const [value, setValue] = React.useState<number | null>(50)
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<div className='flex flex-col items-center gap-4'>
|
|
164
|
+
<FieldRoot>
|
|
165
|
+
<NumberFieldRoot value={value} onValueChange={setValue}>
|
|
166
|
+
<NumberFieldScrubArea>
|
|
167
|
+
<FieldLabel>Controlled Value</FieldLabel>
|
|
168
|
+
<NumberFieldScrubAreaCursor>
|
|
169
|
+
<MoveHorizontal className='size-4' />
|
|
170
|
+
</NumberFieldScrubAreaCursor>
|
|
171
|
+
</NumberFieldScrubArea>
|
|
172
|
+
|
|
173
|
+
<NumberFieldGroup>
|
|
174
|
+
<NumberFieldDecrement>
|
|
175
|
+
<Minus className='size-4' />
|
|
176
|
+
</NumberFieldDecrement>
|
|
177
|
+
<NumberFieldInput />
|
|
178
|
+
<NumberFieldIncrement>
|
|
179
|
+
<Plus className='size-4' />
|
|
180
|
+
</NumberFieldIncrement>
|
|
181
|
+
</NumberFieldGroup>
|
|
182
|
+
</NumberFieldRoot>
|
|
183
|
+
</FieldRoot>
|
|
184
|
+
|
|
185
|
+
<div className='flex gap-2'>
|
|
186
|
+
<Button onClick={() => setValue(0)}>Set to 0</Button>
|
|
187
|
+
<Button onClick={() => setValue(100)}>Set to 100</Button>
|
|
188
|
+
<Button onClick={() => setValue(50)}>Reset to 50</Button>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Format
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import { FieldLabel, FieldRoot } from '@lglab/compose-ui/field'
|
|
199
|
+
import {
|
|
200
|
+
NumberFieldDecrement,
|
|
201
|
+
NumberFieldGroup,
|
|
202
|
+
NumberFieldIncrement,
|
|
203
|
+
NumberFieldInput,
|
|
204
|
+
NumberFieldRoot,
|
|
205
|
+
NumberFieldScrubArea,
|
|
206
|
+
NumberFieldScrubAreaCursor,
|
|
207
|
+
} from '@lglab/compose-ui/number-field'
|
|
208
|
+
import { Minus, MoveHorizontal, Plus } from 'lucide-react'
|
|
209
|
+
|
|
210
|
+
export default function FormatExample() {
|
|
211
|
+
return (
|
|
212
|
+
<FieldRoot>
|
|
213
|
+
<NumberFieldRoot
|
|
214
|
+
defaultValue={1234.56}
|
|
215
|
+
locale='ja-JP'
|
|
216
|
+
format={{ style: 'currency', currency: 'JPY' }}
|
|
217
|
+
>
|
|
218
|
+
<NumberFieldScrubArea>
|
|
219
|
+
<FieldLabel>Japanese Yen (ja-JP)</FieldLabel>
|
|
220
|
+
<NumberFieldScrubAreaCursor>
|
|
221
|
+
<MoveHorizontal className='size-4' />
|
|
222
|
+
</NumberFieldScrubAreaCursor>
|
|
223
|
+
</NumberFieldScrubArea>
|
|
224
|
+
|
|
225
|
+
<NumberFieldGroup>
|
|
226
|
+
<NumberFieldDecrement>
|
|
227
|
+
<Minus className='size-4' />
|
|
228
|
+
</NumberFieldDecrement>
|
|
229
|
+
<NumberFieldInput />
|
|
230
|
+
<NumberFieldIncrement>
|
|
231
|
+
<Plus className='size-4' />
|
|
232
|
+
</NumberFieldIncrement>
|
|
233
|
+
</NumberFieldGroup>
|
|
234
|
+
</NumberFieldRoot>
|
|
235
|
+
</FieldRoot>
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Resources
|
|
241
|
+
|
|
242
|
+
- [Base UI Number Field Documentation](https://base-ui.com/react/components/number-field)
|
|
243
|
+
- [API Reference](https://base-ui.com/react/components/number-field#api-reference)
|