reusify-ui 1.0.7 → 2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Mukesh Yadav
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,305 @@
1
- # React + Vite
1
+ # Reusify UI
2
2
 
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3
+ Reusable, accessible React components with built-in dark mode and CSS-variable theming.
4
+ Works with or without Tailwind CSS.
4
5
 
5
- Currently, two official plugins are available:
6
+ [![npm](https://img.shields.io/npm/v/reusify-ui)](https://www.npmjs.com/package/reusify-ui)
7
+ [![license](https://img.shields.io/npm/l/reusify-ui)](./LICENSE)
6
8
 
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+ ## Installation
9
10
 
10
- ## Expanding the ESLint configuration
11
+ ```bash
12
+ npm install reusify-ui
13
+ # or
14
+ yarn add reusify-ui
15
+ # or
16
+ pnpm add reusify-ui
17
+ ```
11
18
 
12
- If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
19
+ Requires React 18 or newer.
20
+
21
+ ## Setup
22
+
23
+ Import the stylesheet once, at your app's entry point (for example `main.jsx`, `App.jsx` or Next.js `app/layout.tsx`):
24
+
25
+ ```jsx
26
+ import 'reusify-ui/styles.css';
27
+ ```
28
+
29
+ ### With Tailwind CSS v4
30
+
31
+ Import the stylesheet from your CSS instead, into a cascade layer between Tailwind's `base` and `utilities`. Preflight can't affect the components, and your utility classes can still override them:
32
+
33
+ ```css
34
+ @layer theme, base, reusify, components, utilities;
35
+
36
+ @import 'tailwindcss';
37
+ @import 'reusify-ui/styles.css' layer(reusify);
38
+ ```
39
+
40
+ (Skip the JavaScript import in this case.) With Tailwind v3, the JavaScript import above is all you need.
41
+
42
+ ## Usage
43
+
44
+ ```jsx
45
+ import { Button, Input, Card, CardBody } from 'reusify-ui';
46
+
47
+ export default function App() {
48
+ return (
49
+ <Card>
50
+ <CardBody>
51
+ <Input label="Email" placeholder="you@example.com" fullWidth />
52
+ <Button onClick={() => alert('Hello!')}>Subscribe</Button>
53
+ </CardBody>
54
+ </Card>
55
+ );
56
+ }
57
+ ```
58
+
59
+ ## Components
60
+
61
+ | Category | Components |
62
+ | -------------- | -------------------------------------------------------------------------- |
63
+ | Actions | `Button` |
64
+ | Forms | `Input`, `Textarea`, `Select`, `Checkbox`, `Radio`, `RadioGroup`, `Switch` |
65
+ | Data display | `Card`, `CardHeader`, `CardBody`, `CardFooter`, `Badge`, `Avatar`, `AvatarGroup`, `Table`, `Divider`, `Kbd` |
66
+ | Feedback | `Alert`, `ToastProvider` + `useToast`, `Spinner`, `Progress`, `Skeleton` |
67
+ | Overlays | `Modal`, `Drawer`, `Tooltip`, `Dropdown` |
68
+ | Navigation | `Tabs`, `Accordion`, `Pagination`, `Breadcrumbs` |
69
+ | Effects | `SpotlightCard`, `Pattern` |
70
+ | Hooks & utils | `useDisclosure`, `useClickOutside`, `useControllableState`, `cn` |
71
+
72
+ ### Button
73
+
74
+ ```jsx
75
+ <Button>Primary</Button>
76
+ <Button variant="secondary">Secondary</Button>
77
+ <Button variant="outline" size="sm">Outline</Button>
78
+ <Button variant="ghost">Ghost</Button>
79
+ <Button variant="danger" loading>Deleting</Button>
80
+ <Button leftIcon={<PlusIcon />} fullWidth>Add item</Button>
81
+ ```
82
+
83
+ | Prop | Type | Default |
84
+ | ----------- | ----------------------------------------------------------------------------- | ----------- |
85
+ | `variant` | `'primary' \| 'secondary' \| 'outline' \| 'ghost' \| 'danger' \| 'success' \| 'link'` | `'primary'` |
86
+ | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` |
87
+ | `loading` | `boolean` | `false` |
88
+ | `fullWidth` | `boolean` | `false` |
89
+ | `leftIcon`, `rightIcon` | `ReactNode` | — |
90
+
91
+ All native `<button>` props are supported too.
92
+
93
+ ### Form controls
94
+
95
+ ```jsx
96
+ <Input label="Email" type="email" helperText="We never share it." required />
97
+ <Input label="Username" error="Username is taken" />
98
+ <Textarea label="Message" rows={5} />
99
+ <Select
100
+ label="Country"
101
+ placeholder="Choose a country"
102
+ options={[{ label: 'India', value: 'in' }, { label: 'USA', value: 'us' }]}
103
+ />
104
+ <Checkbox label="Accept terms" />
105
+ <RadioGroup
106
+ label="Plan"
107
+ defaultValue="pro"
108
+ options={[{ label: 'Free', value: 'free' }, { label: 'Pro', value: 'pro' }]}
109
+ onChange={(value) => console.log(value)}
110
+ />
111
+ <Switch label="Notifications" checked={on} onChange={setOn} />
112
+ ```
113
+
114
+ `Input`, `Textarea` and `Select` share these props: `label`, `helperText`, `error` (`boolean | string`), `size` (`'sm' | 'md' | 'lg'`), `fullWidth`, plus every native attribute. They forward refs, so they work with React Hook Form's `register()`.
115
+
116
+ ### Modal & Drawer
117
+
118
+ ```jsx
119
+ import { Modal, Button, useDisclosure } from 'reusify-ui';
120
+
121
+ function DeleteDialog() {
122
+ const { isOpen, open, close } = useDisclosure();
123
+ return (
124
+ <>
125
+ <Button variant="danger" onClick={open}>Delete</Button>
126
+ <Modal
127
+ open={isOpen}
128
+ onClose={close}
129
+ title="Delete project?"
130
+ description="This action cannot be undone."
131
+ footer={
132
+ <>
133
+ <Button variant="ghost" onClick={close}>Cancel</Button>
134
+ <Button variant="danger" onClick={close}>Delete</Button>
135
+ </>
136
+ }
137
+ />
138
+ </>
139
+ );
140
+ }
141
+ ```
142
+
143
+ Both close on Escape and overlay click, trap focus, lock page scroll and return focus to the trigger when closed.
144
+ `Modal` sizes: `sm | md | lg | xl | full`. `Drawer` takes `placement` (`left | right | top | bottom`) and `size` (`sm | md | lg` or any CSS length).
145
+ Add `data-autofocus` to an element inside to focus it on open.
146
+
147
+ ### Toasts
148
+
149
+ ```jsx
150
+ import { ToastProvider, useToast } from 'reusify-ui';
151
+
152
+ // Wrap your app once
153
+ <ToastProvider position="bottom-right">
154
+ <App />
155
+ </ToastProvider>
156
+
157
+ // Anywhere inside
158
+ function SaveButton() {
159
+ const toast = useToast();
160
+ return (
161
+ <Button onClick={() => toast.success('Saved!', { description: 'Your changes are live.' })}>
162
+ Save
163
+ </Button>
164
+ );
165
+ }
166
+ ```
167
+
168
+ `toast(options | string)`, `toast.success()`, `toast.error()`, `toast.warning()`, `toast.info()` and `toast.dismiss(id?)`.
169
+ Options: `title`, `description`, `variant`, `duration` (ms, `Infinity` keeps it open) and `action`.
170
+
171
+ ### Tooltip & Dropdown
172
+
173
+ ```jsx
174
+ <Tooltip content="Copy to clipboard" placement="top">
175
+ <Button variant="ghost">Copy</Button>
176
+ </Tooltip>
177
+
178
+ <Dropdown
179
+ trigger={<Button variant="outline">Actions</Button>}
180
+ align="end"
181
+ items={[
182
+ { label: 'Edit', onClick: edit },
183
+ { divider: true },
184
+ { label: 'Delete', danger: true, onClick: remove },
185
+ ]}
186
+ />
187
+ ```
188
+
189
+ ### Tabs & Accordion
190
+
191
+ ```jsx
192
+ <Tabs
193
+ variant="pills" // or "line"
194
+ items={[
195
+ { value: 'profile', label: 'Profile', content: <Profile /> },
196
+ { value: 'billing', label: 'Billing', content: <Billing /> },
197
+ ]}
198
+ />
199
+
200
+ <Accordion
201
+ multiple
202
+ items={[
203
+ { title: 'What is Reusify?', content: 'A React UI library.' },
204
+ { title: 'Is it free?', content: 'Yes, MIT licensed.' },
205
+ ]}
206
+ />
207
+ ```
208
+
209
+ Both support controlled (`value` + `onChange`) and uncontrolled (`defaultValue`) usage.
210
+
211
+ ### Table
212
+
213
+ ```jsx
214
+ <Table
215
+ rowKey="id"
216
+ striped
217
+ hoverable
218
+ data={users}
219
+ columns={[
220
+ { key: 'name', header: 'Name' },
221
+ { key: 'email', header: 'Email' },
222
+ { key: 'status', header: 'Status', align: 'right', render: (u) => <Badge>{u.status}</Badge> },
223
+ ]}
224
+ />
225
+ ```
226
+
227
+ ### Other components
228
+
229
+ ```jsx
230
+ <Alert variant="success" title="Saved">Your profile was updated.</Alert>
231
+ <Badge color="warning" variant="soft" dot>Pending</Badge>
232
+ <Avatar src="/me.jpg" name="Mukesh Yadav" size="lg" />
233
+ <AvatarGroup max={3}>{/* <Avatar /> ... */}</AvatarGroup>
234
+ <Spinner size="lg" />
235
+ <Progress value={60} label="Uploading" showValue />
236
+ <Skeleton lines={3} />
237
+ <Pagination page={page} totalPages={20} onChange={setPage} />
238
+ <Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Settings' }]} />
239
+ <Divider label="OR" />
240
+ ```
241
+
242
+ ## Dark mode
243
+
244
+ Add the `dark` class (Tailwind style) or `data-theme="dark"` to `<html>` or any wrapper:
245
+
246
+ ```js
247
+ document.documentElement.classList.toggle('dark');
248
+ ```
249
+
250
+ ## Theming
251
+
252
+ Every color, radius and shadow is a CSS variable. Override them in your own CSS:
253
+
254
+ ```css
255
+ :root {
256
+ --ru-primary: #7c3aed; /* brand color: buttons, focus rings, active tabs */
257
+ --ru-radius: 0.75rem;
258
+ --ru-font-family: 'Inter', sans-serif;
259
+ }
260
+
261
+ .dark {
262
+ --ru-primary: #a78bfa;
263
+ --ru-surface: #18181b;
264
+ }
265
+ ```
266
+
267
+ | Variable | Purpose |
268
+ | --- | --- |
269
+ | `--ru-primary`, `--ru-secondary`, `--ru-success`, `--ru-danger`, `--ru-warning`, `--ru-info` | Semantic colors |
270
+ | `--ru-bg`, `--ru-surface`, `--ru-muted`, `--ru-border` | Page background, surfaces and hairline borders |
271
+ | `--ru-text`, `--ru-text-muted` | Text colors |
272
+ | `--ru-radius-sm`, `--ru-radius`, `--ru-radius-lg` | Corner radius |
273
+ | `--ru-shadow-xs`, `--ru-shadow-sm`, `--ru-shadow`, `--ru-shadow-lg` | Layered shadows (hairline ring + soft drops) |
274
+ | `--ru-font-family`, `--ru-font-mono` | Fonts (UI text inherits from your page by default) |
275
+ | `--ru-z-dropdown`, `--ru-z-overlay`, `--ru-z-toast`, `--ru-z-tooltip` | Stacking order |
276
+
277
+ Every component also accepts `className`, so you can add your own (or Tailwind) classes.
278
+
279
+ ### Effects
280
+
281
+ ```jsx
282
+ <div style={{ position: 'relative' }}>
283
+ <Pattern variant="grid" size={24} /> {/* or variant="dots" */}
284
+ <h1 style={{ position: 'relative' }}>Hero</h1>
285
+ </div>
286
+
287
+ <SpotlightCard color="#f472b6"> {/* glow follows the cursor */}
288
+ <CardBody>Feature</CardBody>
289
+ </SpotlightCard>
290
+
291
+ <Kbd>⌘</Kbd> <Kbd>K</Kbd>
292
+ ```
293
+
294
+ ## Next.js
295
+
296
+ The package ships with a `'use client'` directive, so you can import components directly into App Router pages and layouts.
297
+
298
+ ## Upgrading from 1.x
299
+
300
+ - Import `reusify-ui/styles.css` once. Tailwind is no longer required.
301
+ - `<Button variant="primary" | "secondary">` still works as before.
302
+
303
+ ## License
304
+
305
+ MIT © Mukesh Yadav