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 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
- ## Install
5
+ ---
6
6
 
7
- ```sh
8
- pnpm add shadcn-ui-react
9
- # or
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
- ## Usage
19
+ ---
20
+
21
+ ## ๐Ÿš€ Getting Started
16
22
 
17
- Import `style.css` in the App root:
23
+ ### 1. Import Global Styles
24
+
25
+ In your `main.tsx` or `App.tsx`:
18
26
 
19
27
  ```tsx
20
- import 'shadcn-ui-react/dist/style.css';
28
+ import "shadcn-ui-react/dist/style.css";
21
29
  ```
22
30
 
23
- Then use the components:
31
+ ### 2. Use Components
24
32
 
25
33
  ```tsx
26
- import { Button } from 'shadcn-ui-react'
34
+ import { Button } from "shadcn-ui-react";
27
35
 
28
- export default function MyComponent() {
29
- return (<Button>Hello world</Button>)
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
- ```tsx
34
- import { Card } from 'shadcn-ui-react'
46
+ ---
35
47
 
36
- export default function MyComponent() {
37
- return (<Card><h1>Hello World</h1></Card>)
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
- import React, { useState } from 'react';
43
- import { SearchInput } from './components/search-input';
136
+ <Button variant="default">Default</Button>
137
+ <Button variant="outline">Outline</Button>
138
+ <Button loading>Loading...</Button>
139
+ ```
44
140
 
45
- export default function MyComponent() {
46
- const [searchTerm, setSearchTerm] = useState('');
141
+ ### ๐Ÿช„ Accordion
47
142
 
48
- const handleSearch = (term) => {
49
- setSearchTerm(term);
50
- console.log('Search term:', term);
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
- return (<SearchInput placeholder="Search" value={searchTerm} onSearch={handleSearch} />);
54
- };
152
+ ### โš ๏ธ Alert
153
+
154
+ ```tsx
155
+ <Alert>This is an alert message</Alert>
55
156
  ```
56
157
 
57
- ## Example of a login form
158
+ ### ๐Ÿงพ Form
159
+
58
160
  ```tsx
59
- import { zodResolver } from '@hookform/resolvers/zod';
60
- import { useForm } from 'react-hook-form';
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 'shadcn-ui-react';
71
- import * as z from 'zod';
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: 'Enter a valid email address' }),
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: 'Password must be at least 8 characters' })
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: 'demo@domain.com'
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
- <Form {...form}>
95
- <form
96
- onSubmit={form.handleSubmit(onSubmit)}
97
- className="w-full space-y-2"
98
- >
99
- <FormField
100
- control={form.control}
101
- name="email"
102
- render={({ field }) => (
103
- <FormItem>
104
- <FormLabel>Email</FormLabel>
105
- <FormControl>
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
- ## Example of a data table
212
+ ### ๐Ÿ“Š DataTable
127
213
 
128
214
  ```tsx
129
- import React, { useState } from 'react';
130
- import { DataTable } from 'shadcn-ui-react';
131
- import { ColumnDef } from '@tanstack/react-table';
215
+ import React, { useState } from "react";
216
+ import { DataTable } from "shadcn-ui-react";
217
+ import { ColumnDef } from "@tanstack/react-table";
132
218
 
133
- type Data = {
219
+ type User = {
134
220
  id: number;
135
221
  name: string;
136
- age: number;
222
+ email: string;
137
223
  };
138
224
 
139
- const columns: ColumnDef<Data, any>[] = [
225
+ const columns: ColumnDef<User, any>[] = [
140
226
  {
141
- accessorKey: 'id',
142
- header: 'ID',
227
+ accessorKey: "id",
228
+ header: "ID",
143
229
  },
144
230
  {
145
- accessorKey: 'name',
146
- header: 'Name',
231
+ accessorKey: "name",
232
+ header: "Name",
147
233
  },
148
234
  {
149
- accessorKey: 'age',
150
- header: 'Age',
235
+ accessorKey: "email",
236
+ header: "Email",
151
237
  },
152
238
  ];
153
239
 
154
- const data: Data[] = [
155
- { id: 1, name: 'John Doe', age: 28 },
156
- { id: 2, name: 'Jane Smith', age: 34 },
157
- { id: 3, name: 'Sam Johnson', age: 45 },
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 handleRowClick = (row: Data) => {
168
- console.log('Row clicked:', row);
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 Example</h1>
270
+ <h1 className="text-xl font-bold mb-4">Data Table with Pagination</h1>
174
271
  <DataTable
175
272
  columns={columns}
176
- data={data}
177
- pageCount={3}
273
+ data={paginatedData}
274
+ pageCount={Math.ceil(data.length / perPage)}
178
275
  page={page}
276
+ perPage={perPage}
179
277
  onPageChange={handlePageChange}
180
- onClick={handleRowClick}
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).