shadcn-ui-react 0.2.7 โ 0.3.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 +215 -91
- package/dist/index.cjs +889 -892
- package/dist/index.d.cts +102 -68
- package/dist/index.d.ts +102 -68
- package/dist/index.js +862 -861
- package/dist/style.css +213 -57
- package/package.json +76 -57
package/README.md
CHANGED
|
@@ -1,63 +1,165 @@
|
|
|
1
|
-
# shadcn-ui-react
|
|
1
|
+
# ๐งฉ shadcn-ui-react
|
|
2
2
|
|
|
3
|
-
A simple wrapper for [shadcn/ui](https://github.com/shadcn-ui/ui)
|
|
3
|
+
A simple wrapper for [shadcn/ui](https://github.com/shadcn-ui/ui) to build modern, accessible, and customizable UIs in React with minimal setup.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
## ๐ฆ Installation
|
|
8
|
+
|
|
9
|
+
Install via your preferred package manager:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
10
12
|
npm install shadcn-ui-react
|
|
11
13
|
# or
|
|
12
14
|
yarn add shadcn-ui-react
|
|
15
|
+
# or
|
|
16
|
+
pnpm add shadcn-ui-react
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ๐ Getting Started
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
### 1. Import Global Styles
|
|
24
|
+
|
|
25
|
+
In your `main.tsx` or `App.tsx`:
|
|
18
26
|
|
|
19
27
|
```tsx
|
|
20
|
-
import
|
|
28
|
+
import "shadcn-ui-react/dist/style.css";
|
|
21
29
|
```
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
### 2. Use Components
|
|
24
32
|
|
|
25
33
|
```tsx
|
|
26
|
-
import { Button } from
|
|
34
|
+
import { Button } from "shadcn-ui-react";
|
|
27
35
|
|
|
28
|
-
export default function
|
|
29
|
-
return (
|
|
36
|
+
export default function App() {
|
|
37
|
+
return (
|
|
38
|
+
<div className="p-4">
|
|
39
|
+
<Button variant="default">Click me</Button>
|
|
40
|
+
<Button loading className="ml-2">Loading</Button>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
30
43
|
}
|
|
31
44
|
```
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
import { Card } from 'shadcn-ui-react'
|
|
46
|
+
---
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
## ๐งฑ Available Components
|
|
49
|
+
|
|
50
|
+
### ๐ฆ UI Primitives
|
|
51
|
+
|
|
52
|
+
- `Accordion`
|
|
53
|
+
- `Alert`
|
|
54
|
+
- `Avatar`
|
|
55
|
+
- `Badge`
|
|
56
|
+
- `Breadcrumb`
|
|
57
|
+
- `Button`
|
|
58
|
+
- `Calendar`
|
|
59
|
+
- `Card`
|
|
60
|
+
- `Carousel`
|
|
61
|
+
- `Checkbox`
|
|
62
|
+
- `Collapsible`
|
|
63
|
+
- `Command`
|
|
64
|
+
- `ContextMenu`
|
|
65
|
+
- `Dialog`
|
|
66
|
+
- `Drawer`
|
|
67
|
+
- `DropdownMenu`
|
|
68
|
+
- `HoverCard`
|
|
69
|
+
- `Input`
|
|
70
|
+
- `InputOtp`
|
|
71
|
+
- `Label`
|
|
72
|
+
- `Menubar`
|
|
73
|
+
- `Modal`
|
|
74
|
+
- `NavigationMenu`
|
|
75
|
+
- `Pagination`
|
|
76
|
+
- `Popover`
|
|
77
|
+
- `Progress`
|
|
78
|
+
- `RadioGroup`
|
|
79
|
+
- `Resizable`
|
|
80
|
+
- `ScrollArea`
|
|
81
|
+
- `Select`
|
|
82
|
+
- `Separator`
|
|
83
|
+
- `Sheet`
|
|
84
|
+
- `Skeleton`
|
|
85
|
+
- `Slider`
|
|
86
|
+
- `Sonner`
|
|
87
|
+
- `Switch`
|
|
88
|
+
- `Table`
|
|
89
|
+
- `Tabs`
|
|
90
|
+
- `Textarea`
|
|
91
|
+
- `Toast`
|
|
92
|
+
- `Toggle`
|
|
93
|
+
- `ToggleGroup`
|
|
94
|
+
- `Tooltip`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### ๐ง Forms
|
|
99
|
+
|
|
100
|
+
- `Form`
|
|
101
|
+
- `FormField`
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### ๐ Inputs
|
|
106
|
+
|
|
107
|
+
- `SearchInput`
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### ๐งฉ Utilities
|
|
112
|
+
|
|
113
|
+
- `UseToast`
|
|
114
|
+
- `Icons`
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### ๐ Shared Components
|
|
119
|
+
|
|
120
|
+
- `AlertModal`
|
|
121
|
+
- `Breadcrumbs`
|
|
122
|
+
- `DataTable` (with pagination)
|
|
123
|
+
- `DataTableSkeleton`
|
|
124
|
+
- `FileUpload`
|
|
125
|
+
- `Heading`
|
|
126
|
+
- `PageHead`
|
|
127
|
+
- `PaginationSection`
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## โจ Examples
|
|
132
|
+
|
|
133
|
+
### ๐ Button
|
|
40
134
|
|
|
41
135
|
```tsx
|
|
42
|
-
|
|
43
|
-
|
|
136
|
+
<Button variant="default">Default</Button>
|
|
137
|
+
<Button variant="outline">Outline</Button>
|
|
138
|
+
<Button loading>Loading...</Button>
|
|
139
|
+
```
|
|
44
140
|
|
|
45
|
-
|
|
46
|
-
const [searchTerm, setSearchTerm] = useState('');
|
|
141
|
+
### ๐ช Accordion
|
|
47
142
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
143
|
+
```tsx
|
|
144
|
+
<Accordion type="single" collapsible>
|
|
145
|
+
<AccordionItem value="item-1">
|
|
146
|
+
<AccordionTrigger>Click me</AccordionTrigger>
|
|
147
|
+
<AccordionContent>Hidden content revealed!</AccordionContent>
|
|
148
|
+
</AccordionItem>
|
|
149
|
+
</Accordion>
|
|
150
|
+
```
|
|
52
151
|
|
|
53
|
-
|
|
54
|
-
|
|
152
|
+
### โ ๏ธ Alert
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
<Alert>This is an alert message</Alert>
|
|
55
156
|
```
|
|
56
157
|
|
|
57
|
-
|
|
158
|
+
### ๐งพ Form
|
|
159
|
+
|
|
58
160
|
```tsx
|
|
59
|
-
import { zodResolver } from
|
|
60
|
-
import { useForm } from
|
|
161
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
162
|
+
import { useForm } from "react-hook-form";
|
|
61
163
|
import {
|
|
62
164
|
Button,
|
|
63
165
|
Form,
|
|
@@ -66,122 +168,144 @@ import {
|
|
|
66
168
|
FormItem,
|
|
67
169
|
FormLabel,
|
|
68
170
|
FormMessage,
|
|
69
|
-
Input
|
|
70
|
-
} from
|
|
71
|
-
import * as z from
|
|
171
|
+
Input,
|
|
172
|
+
} from "shadcn-ui-react";
|
|
173
|
+
import * as z from "zod";
|
|
72
174
|
|
|
73
175
|
const formSchema = z.object({
|
|
74
|
-
email: z.string().email({ message:
|
|
176
|
+
email: z.string({required_error: "Email is required"}).email({ message: "Enter a valid email address" }),
|
|
75
177
|
password: z
|
|
76
178
|
.string()
|
|
77
|
-
.min(8, { message:
|
|
179
|
+
.min(8, { message: "Password must be at least 8 characters" }),
|
|
78
180
|
});
|
|
79
181
|
|
|
80
182
|
type UserFormValue = z.infer<typeof formSchema>;
|
|
81
183
|
|
|
82
184
|
export default function UserAuthForm() {
|
|
83
185
|
const defaultValues = {
|
|
84
|
-
email:
|
|
186
|
+
email: "demo@domain.com",
|
|
85
187
|
};
|
|
86
188
|
const form = useForm<UserFormValue>({
|
|
87
189
|
resolver: zodResolver(formSchema),
|
|
88
|
-
defaultValues
|
|
190
|
+
defaultValues,
|
|
89
191
|
});
|
|
90
192
|
|
|
91
193
|
const onSubmit = async (data: UserFormValue) => {};
|
|
92
194
|
|
|
93
195
|
return (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<Input
|
|
107
|
-
id="email"
|
|
108
|
-
type="email"
|
|
109
|
-
placeholder="demo@domain.com"
|
|
110
|
-
{...field}
|
|
111
|
-
/>
|
|
112
|
-
</FormControl>
|
|
113
|
-
<FormMessage />
|
|
114
|
-
</FormItem>
|
|
115
|
-
)}
|
|
116
|
-
/>
|
|
117
|
-
<Button className="ml-auto w-full" type="submit">
|
|
118
|
-
Log In
|
|
119
|
-
</Button>
|
|
120
|
-
</form>
|
|
121
|
-
</Form>
|
|
196
|
+
<Form methods={form} onSubmit={onSubmit}>
|
|
197
|
+
<FormField
|
|
198
|
+
control={form.control}
|
|
199
|
+
name="email"
|
|
200
|
+
type="email"
|
|
201
|
+
placeholder="Enter your email"
|
|
202
|
+
label="Email"
|
|
203
|
+
/>
|
|
204
|
+
<Button className="ml-auto w-full" type="submit">
|
|
205
|
+
Log In
|
|
206
|
+
</Button>
|
|
207
|
+
</Form>
|
|
122
208
|
);
|
|
123
209
|
}
|
|
124
210
|
```
|
|
125
211
|
|
|
126
|
-
|
|
212
|
+
### ๐ DataTable
|
|
127
213
|
|
|
128
214
|
```tsx
|
|
129
|
-
import React, { useState } from
|
|
130
|
-
import { DataTable } from
|
|
131
|
-
import { ColumnDef } from
|
|
215
|
+
import React, { useState } from "react";
|
|
216
|
+
import { DataTable } from "shadcn-ui-react";
|
|
217
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
132
218
|
|
|
133
|
-
type
|
|
219
|
+
type User = {
|
|
134
220
|
id: number;
|
|
135
221
|
name: string;
|
|
136
|
-
|
|
222
|
+
email: string;
|
|
137
223
|
};
|
|
138
224
|
|
|
139
|
-
const columns: ColumnDef<
|
|
225
|
+
const columns: ColumnDef<User, any>[] = [
|
|
140
226
|
{
|
|
141
|
-
accessorKey:
|
|
142
|
-
header:
|
|
227
|
+
accessorKey: "id",
|
|
228
|
+
header: "ID",
|
|
143
229
|
},
|
|
144
230
|
{
|
|
145
|
-
accessorKey:
|
|
146
|
-
header:
|
|
231
|
+
accessorKey: "name",
|
|
232
|
+
header: "Name",
|
|
147
233
|
},
|
|
148
234
|
{
|
|
149
|
-
accessorKey:
|
|
150
|
-
header:
|
|
235
|
+
accessorKey: "email",
|
|
236
|
+
header: "Email",
|
|
151
237
|
},
|
|
152
238
|
];
|
|
153
239
|
|
|
154
|
-
const data:
|
|
155
|
-
{ id: 1, name:
|
|
156
|
-
{ id: 2, name:
|
|
157
|
-
{ id: 3, name:
|
|
240
|
+
const data: User[] = [
|
|
241
|
+
{ id: 1, name: "John Doe", email: "john@example.com" },
|
|
242
|
+
{ id: 2, name: "Jane Smith", email: "jane@example.com" },
|
|
243
|
+
{ id: 3, name: "Sam Johnson", email: "sam@example.com" },
|
|
244
|
+
{ id: 4, name: "Alice Brown", email: "alice@example.com" },
|
|
245
|
+
{ id: 5, name: "Bob White", email: "bob@example.com" },
|
|
246
|
+
{ id: 6, name: "Charlie Black", email: "charlie@example.com" },
|
|
247
|
+
{ id: 7, name: "Diana Green", email: "diana@example.com" },
|
|
248
|
+
{ id: 8, name: "Eve Blue", email: "eve@example.com" },
|
|
249
|
+
{ id: 9, name: "Frank Yellow", email: "frank@example.com" },
|
|
250
|
+
{ id: 10, name: "Grace Red", email: "grace@example.com" },
|
|
158
251
|
];
|
|
159
252
|
|
|
160
253
|
const Example = () => {
|
|
161
254
|
const [page, setPage] = useState(1);
|
|
255
|
+
const [perPage, setPerPage] = useState(5);
|
|
256
|
+
|
|
257
|
+
const paginatedData = data.slice((page - 1) * perPage, page * perPage);
|
|
162
258
|
|
|
163
259
|
const handlePageChange = (newPage: number) => {
|
|
164
260
|
setPage(newPage);
|
|
165
261
|
};
|
|
166
262
|
|
|
167
|
-
const
|
|
168
|
-
|
|
263
|
+
const handlePageSizeChange = (newPageSize: number) => {
|
|
264
|
+
setPerPage(newPageSize);
|
|
265
|
+
setPage(1); // Reset to the first page when page size changes
|
|
169
266
|
};
|
|
170
267
|
|
|
171
268
|
return (
|
|
172
269
|
<div>
|
|
173
|
-
<h1>Data Table
|
|
270
|
+
<h1 className="text-xl font-bold mb-4">Data Table with Pagination</h1>
|
|
174
271
|
<DataTable
|
|
175
272
|
columns={columns}
|
|
176
|
-
data={
|
|
177
|
-
pageCount={
|
|
273
|
+
data={paginatedData}
|
|
274
|
+
pageCount={Math.ceil(data.length / perPage)}
|
|
178
275
|
page={page}
|
|
276
|
+
perPage={perPage}
|
|
179
277
|
onPageChange={handlePageChange}
|
|
180
|
-
|
|
278
|
+
onPageSizeChange={handlePageSizeChange}
|
|
279
|
+
rowPerPageLabel="Rows per page"
|
|
280
|
+
pageLabel="Page"
|
|
281
|
+
ofLabel="of"
|
|
282
|
+
rowsSelectedLabel="rows selected"
|
|
283
|
+
emptyData={<div>No data available</div>}
|
|
181
284
|
/>
|
|
182
285
|
</div>
|
|
183
286
|
);
|
|
184
287
|
};
|
|
185
288
|
|
|
186
289
|
export default Example;
|
|
187
|
-
```
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## ๐
Theming & Styling
|
|
295
|
+
|
|
296
|
+
- Built with **Tailwind CSS**
|
|
297
|
+
- Override styles using your own CSS/Tailwind classes
|
|
298
|
+
- Component APIs are designed to be extensible
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## ๐งช Example Projects
|
|
303
|
+
|
|
304
|
+
- Vite + React + Tailwind
|
|
305
|
+
- Next.js + TypeScript + shadcn-ui-react
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## ๐ License
|
|
310
|
+
|
|
311
|
+
Licensed under the [MIT license](https://github.com/blencm/shadcn-ui-react/blob/main/LICENSE).
|