shadcn-ui-react 0.2.8 โ†’ 0.3.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 CHANGED
@@ -1,70 +1,161 @@
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
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
34
  import { Button } from "shadcn-ui-react";
27
35
 
28
- export default function MyComponent() {
29
- return <Button>Hello world</Button>;
30
- }
31
- ```
32
-
33
- ```tsx
34
- import { Card } from "shadcn-ui-react";
35
-
36
- export default function MyComponent() {
36
+ export default function App() {
37
37
  return (
38
- <Card>
39
- <h1>Hello World</h1>
40
- </Card>
38
+ <div className="p-4">
39
+ <Button variant="default">Click me</Button>
40
+ <Button loading className="ml-2">Loading</Button>
41
+ </div>
41
42
  );
42
43
  }
43
44
  ```
44
45
 
46
+ ---
47
+
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
134
+
45
135
  ```tsx
46
- import React, { useState } from "react";
47
- import { SearchInput } from "./components/search-input";
136
+ <Button variant="default">Default</Button>
137
+ <Button variant="outline">Outline</Button>
138
+ <Button loading>Loading...</Button>
139
+ ```
48
140
 
49
- export default function MyComponent() {
50
- const [searchTerm, setSearchTerm] = useState("");
141
+ ### ๐Ÿช„ Accordion
51
142
 
52
- const handleSearch = (term?: string) => {
53
- setSearchTerm(term);
54
- console.log("Search term:", term);
55
- };
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
+ ```
56
151
 
57
- return (
58
- <SearchInput
59
- placeholder="Search"
60
- value={searchTerm}
61
- onSearch={handleSearch}
62
- />
63
- );
64
- }
152
+ ### โš ๏ธ Alert
153
+
154
+ ```tsx
155
+ <Alert>This is an alert message</Alert>
65
156
  ```
66
157
 
67
- ## Example of a login form
158
+ ### ๐Ÿงพ Form
68
159
 
69
160
  ```tsx
70
161
  import { zodResolver } from "@hookform/resolvers/zod";
@@ -82,7 +173,7 @@ import {
82
173
  import * as z from "zod";
83
174
 
84
175
  const formSchema = z.object({
85
- 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" }),
86
177
  password: z
87
178
  .string()
88
179
  .min(8, { message: "Password must be at least 8 characters" }),
@@ -106,10 +197,9 @@ export default function UserAuthForm() {
106
197
  <FormField
107
198
  control={form.control}
108
199
  name="email"
200
+ type="email"
109
201
  placeholder="Enter your email"
110
- onChange={(e) => {
111
- form.setValue("firstname", e.target.value);
112
- }}
202
+ label="Email"
113
203
  />
114
204
  <Button className="ml-auto w-full" type="submit">
115
205
  Log In
@@ -119,20 +209,20 @@ export default function UserAuthForm() {
119
209
  }
120
210
  ```
121
211
 
122
- ## Example of a data table
212
+ ### ๐Ÿ“Š DataTable
123
213
 
124
214
  ```tsx
125
215
  import React, { useState } from "react";
126
216
  import { DataTable } from "shadcn-ui-react";
127
217
  import { ColumnDef } from "@tanstack/react-table";
128
218
 
129
- type Data = {
219
+ type User = {
130
220
  id: number;
131
221
  name: string;
132
- age: number;
222
+ email: string;
133
223
  };
134
224
 
135
- const columns: ColumnDef<Data, any>[] = [
225
+ const columns: ColumnDef<User, any>[] = [
136
226
  {
137
227
  accessorKey: "id",
138
228
  header: "ID",
@@ -142,38 +232,55 @@ const columns: ColumnDef<Data, any>[] = [
142
232
  header: "Name",
143
233
  },
144
234
  {
145
- accessorKey: "age",
146
- header: "Age",
235
+ accessorKey: "email",
236
+ header: "Email",
147
237
  },
148
238
  ];
149
239
 
150
- const data: Data[] = [
151
- { id: 1, name: "John Doe", age: 28 },
152
- { id: 2, name: "Jane Smith", age: 34 },
153
- { 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" },
154
251
  ];
155
252
 
156
253
  const Example = () => {
157
254
  const [page, setPage] = useState(1);
255
+ const [perPage, setPerPage] = useState(5);
256
+
257
+ const paginatedData = data.slice((page - 1) * perPage, page * perPage);
158
258
 
159
259
  const handlePageChange = (newPage: number) => {
160
260
  setPage(newPage);
161
261
  };
162
262
 
163
- const handleRowClick = (row: Data) => {
164
- 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
165
266
  };
166
267
 
167
268
  return (
168
269
  <div>
169
- <h1>Data Table Example</h1>
270
+ <h1 className="text-xl font-bold mb-4">Data Table with Pagination</h1>
170
271
  <DataTable
171
272
  columns={columns}
172
- data={data}
173
- pageCount={3}
273
+ data={paginatedData}
274
+ pageCount={Math.ceil(data.length / perPage)}
174
275
  page={page}
276
+ perPage={perPage}
175
277
  onPageChange={handlePageChange}
176
- 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>}
177
284
  />
178
285
  </div>
179
286
  );
@@ -181,3 +288,24 @@ const Example = () => {
181
288
 
182
289
  export default Example;
183
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).