@matheusrizzati/ui 0.1.0 â 0.1.2
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 +300 -0
- package/dist/index.cjs +2706 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +535 -3
- package/dist/index.d.ts +535 -3
- package/dist/index.js +2615 -158
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1821 -0
- package/dist/styles.css.map +1 -0
- package/dist/styles.d.cts +2 -0
- package/dist/styles.d.ts +2 -0
- package/dist/tokens.css +107 -41
- package/dist/tokens.css.map +1 -1
- package/package.json +79 -63
package/README.md
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# @matheusrizzati/ui
|
|
2
|
+
|
|
3
|
+
A premium React UI component library built for modern SaaS applications. Features a dual light/dark theme (Obsidian), 39 production-ready components, and a flexible token-based design system.
|
|
4
|
+
|
|
5
|
+
## âĻ Features
|
|
6
|
+
|
|
7
|
+
- ðĻ **Dual Theme** â Light mode + Obsidian dark mode with seamless toggle
|
|
8
|
+
- ðĶ **39 Components** â Forms, data display, overlays, navigation, feedback, and layout
|
|
9
|
+
- ð§ **Token-Based** â Fully customizable via CSS variables
|
|
10
|
+
- âŋ **Accessible** â Built on Radix UI primitives where it matters
|
|
11
|
+
- ð **TypeScript** â Full type safety and IntelliSense
|
|
12
|
+
- ðŠķ **Lightweight** â Tree-shakeable ESM + CJS output
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## ðĨ Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @matheusrizzati/ui
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Peer dependencies:**
|
|
23
|
+
```bash
|
|
24
|
+
npm install react react-dom
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## ð Setup
|
|
30
|
+
|
|
31
|
+
### 1. Import the CSS
|
|
32
|
+
|
|
33
|
+
In your app's entry file (e.g., `main.tsx` or `layout.tsx`):
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import "@matheusrizzati/ui/tokens.css";
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Add the ThemeProvider
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { ThemeProvider } from "@matheusrizzati/ui";
|
|
43
|
+
|
|
44
|
+
function App() {
|
|
45
|
+
return (
|
|
46
|
+
<ThemeProvider defaultTheme="system">
|
|
47
|
+
{/* your app */}
|
|
48
|
+
</ThemeProvider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The `ThemeProvider` supports three modes:
|
|
54
|
+
- `"light"` â Light theme
|
|
55
|
+
- `"dark"` â Obsidian dark theme
|
|
56
|
+
- `"system"` â Follows OS preference (default)
|
|
57
|
+
|
|
58
|
+
### 3. Toggle themes
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { useTheme } from "@matheusrizzati/ui";
|
|
62
|
+
|
|
63
|
+
function ThemeToggle() {
|
|
64
|
+
const { resolvedTheme, toggleTheme } = useTheme();
|
|
65
|
+
return (
|
|
66
|
+
<button onClick={toggleTheme}>
|
|
67
|
+
{resolvedTheme === "dark" ? "âïļ" : "ð"}
|
|
68
|
+
</button>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 4. Tailwind CSS (if using)
|
|
74
|
+
|
|
75
|
+
Add `darkMode: "class"` to your `tailwind.config.ts` and include the library in `content`:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
export default {
|
|
79
|
+
darkMode: "class",
|
|
80
|
+
content: [
|
|
81
|
+
"./src/**/*.{ts,tsx}",
|
|
82
|
+
"./node_modules/@matheusrizzati/ui/dist/**/*.{js,cjs}",
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## ð Component Catalog
|
|
90
|
+
|
|
91
|
+
### Forms & Inputs
|
|
92
|
+
|
|
93
|
+
| Component | Description | Key Features |
|
|
94
|
+
|-----------|-------------|--------------|
|
|
95
|
+
| `Button` | Primary action trigger | 5 variants, 3 sizes, loading state, icon support |
|
|
96
|
+
| `Input` | Text input field | Start/end icons, clearable (`onClear`), error state |
|
|
97
|
+
| `Textarea` | Multi-line text input | Auto-resize, character count |
|
|
98
|
+
| `Select` | Custom dropdown select | **Searchable**, clearable, groups, icons, descriptions, keyboard nav |
|
|
99
|
+
| `Combobox` | Autocomplete/typeahead | Multi-select, **creatable**, groups, loading state |
|
|
100
|
+
| `Checkbox` | Boolean toggle box | Indeterminate state |
|
|
101
|
+
| `Radio` | Single selection group | RadioGroup + Radio |
|
|
102
|
+
| `Switch` | Toggle switch | Labels, sizes |
|
|
103
|
+
| `Slider` | Range input | Pointer drag, keyboard, step snapping, value display |
|
|
104
|
+
|
|
105
|
+
### Data Display
|
|
106
|
+
|
|
107
|
+
| Component | Description | Key Features |
|
|
108
|
+
|-----------|-------------|--------------|
|
|
109
|
+
| `Table` | Basic table primitives | Thead, Tbody, Tr, Th, Td |
|
|
110
|
+
| `DataTable` | Feature-rich data table | Sorting, pagination, row selection |
|
|
111
|
+
| `Badge` | Status/category label | 6 variants, 3 sizes |
|
|
112
|
+
| `Avatar` | User/entity image | Sizes, shapes, status indicator |
|
|
113
|
+
| `AvatarGroup` | Stacked avatars | `max` prop, +N overflow counter |
|
|
114
|
+
| `Card` | Content container | Elevated, outlined, ghost variants |
|
|
115
|
+
| `StatCard` | KPI metric card | Change indicator, icon slot |
|
|
116
|
+
| `Skeleton` | Loading placeholder | Pulse animation |
|
|
117
|
+
| `Progress` | Progress bar | Variants, sizes, label |
|
|
118
|
+
|
|
119
|
+
### Navigation
|
|
120
|
+
|
|
121
|
+
| Component | Description | Key Features |
|
|
122
|
+
|-----------|-------------|--------------|
|
|
123
|
+
| `Tabs` | Tab switcher | Segmented style |
|
|
124
|
+
| `Breadcrumb` | Path navigation | Separator, active state |
|
|
125
|
+
| `Pagination` | Page navigation | Page numbers, ellipsis |
|
|
126
|
+
| `Sidebar` | App sidebar | Collapsible, sections, active items |
|
|
127
|
+
| `Navbar` | Top navigation bar | â |
|
|
128
|
+
| `Steps` | Step indicator | Completed/active/upcoming states |
|
|
129
|
+
|
|
130
|
+
### Overlays
|
|
131
|
+
|
|
132
|
+
| Component | Description | Key Features |
|
|
133
|
+
|-----------|-------------|--------------|
|
|
134
|
+
| `Modal` | Dialog window | Radix Dialog, title/description/footer |
|
|
135
|
+
| `Drawer` | Slide-out panel | **4 sides**, 5 sizes, header/body/footer |
|
|
136
|
+
| `Dropdown` | Context/action menu | Radix DropdownMenu, labels, groups, separators |
|
|
137
|
+
| `Tooltip` | Hover info | Radix Tooltip |
|
|
138
|
+
| `Popover` | Click popover | Radix Popover |
|
|
139
|
+
| `ConfirmDialog` | Destructive action confirm | Danger/primary variants, loading state |
|
|
140
|
+
|
|
141
|
+
### Feedback
|
|
142
|
+
|
|
143
|
+
| Component | Description | Key Features |
|
|
144
|
+
|-----------|-------------|--------------|
|
|
145
|
+
| `Alert` | Inline message | Info, success, warning, danger |
|
|
146
|
+
| `Toast` | Notification popup | Provider + `useToast()` hook |
|
|
147
|
+
| `EmptyState` | No-data placeholder | Icon, title, description, action |
|
|
148
|
+
|
|
149
|
+
### Layout
|
|
150
|
+
|
|
151
|
+
| Component | Description | Key Features |
|
|
152
|
+
|-----------|-------------|--------------|
|
|
153
|
+
| `AppShell` | Full page layout | Sidebar + content areas |
|
|
154
|
+
| `PageHeader` | Page title section | Title, description, action slot |
|
|
155
|
+
| `Separator` | Visual divider | Horizontal/vertical |
|
|
156
|
+
| `Accordion` | Collapsible sections | Single/multiple mode, smooth animation |
|
|
157
|
+
|
|
158
|
+
### Utilities
|
|
159
|
+
|
|
160
|
+
| Export | Description |
|
|
161
|
+
|--------|-------------|
|
|
162
|
+
| `ThemeProvider` | Light/dark/system toggle + persistence |
|
|
163
|
+
| `useTheme()` | Access theme state and controls |
|
|
164
|
+
| `cn()` | Class merging utility (clsx + tailwind-merge) |
|
|
165
|
+
| `CommandPalette` | âK search palette |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## ðŊ Quick Start Example
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import {
|
|
173
|
+
ThemeProvider,
|
|
174
|
+
AppShell,
|
|
175
|
+
Sidebar,
|
|
176
|
+
SidebarHeader,
|
|
177
|
+
SidebarContent,
|
|
178
|
+
SidebarSection,
|
|
179
|
+
SidebarItem,
|
|
180
|
+
Navbar,
|
|
181
|
+
PageHeader,
|
|
182
|
+
Button,
|
|
183
|
+
Card,
|
|
184
|
+
CardHeader,
|
|
185
|
+
CardBody,
|
|
186
|
+
StatCard,
|
|
187
|
+
Input,
|
|
188
|
+
Select,
|
|
189
|
+
DataTable,
|
|
190
|
+
useTheme,
|
|
191
|
+
} from "@matheusrizzati/ui";
|
|
192
|
+
|
|
193
|
+
function Dashboard() {
|
|
194
|
+
const { toggleTheme, resolvedTheme } = useTheme();
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<AppShell>
|
|
198
|
+
<Sidebar>
|
|
199
|
+
<SidebarHeader>My App</SidebarHeader>
|
|
200
|
+
<SidebarContent>
|
|
201
|
+
<SidebarSection label="Menu">
|
|
202
|
+
<SidebarItem active>Dashboard</SidebarItem>
|
|
203
|
+
<SidebarItem>Users</SidebarItem>
|
|
204
|
+
<SidebarItem>Settings</SidebarItem>
|
|
205
|
+
</SidebarSection>
|
|
206
|
+
</SidebarContent>
|
|
207
|
+
</Sidebar>
|
|
208
|
+
|
|
209
|
+
<main>
|
|
210
|
+
<Navbar>
|
|
211
|
+
<Button variant="ghost" onClick={toggleTheme}>
|
|
212
|
+
{resolvedTheme === "dark" ? "âïļ" : "ð"}
|
|
213
|
+
</Button>
|
|
214
|
+
</Navbar>
|
|
215
|
+
|
|
216
|
+
<div className="p-6">
|
|
217
|
+
<PageHeader
|
|
218
|
+
title="Dashboard"
|
|
219
|
+
description="Overview of your metrics"
|
|
220
|
+
/>
|
|
221
|
+
|
|
222
|
+
<div className="grid grid-cols-3 gap-4 mb-6">
|
|
223
|
+
<StatCard title="Revenue" value="$12,345" change="+12%" />
|
|
224
|
+
<StatCard title="Users" value="1,234" change="+5%" />
|
|
225
|
+
<StatCard title="Orders" value="567" change="-2%" />
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<Card>
|
|
229
|
+
<CardHeader>Recent Orders</CardHeader>
|
|
230
|
+
<CardBody>
|
|
231
|
+
<DataTable
|
|
232
|
+
columns={[
|
|
233
|
+
{ key: "id", header: "ID" },
|
|
234
|
+
{ key: "customer", header: "Customer" },
|
|
235
|
+
{ key: "total", header: "Total" },
|
|
236
|
+
]}
|
|
237
|
+
data={[
|
|
238
|
+
{ id: "#001", customer: "John Doe", total: "$99.00" },
|
|
239
|
+
{ id: "#002", customer: "Jane Smith", total: "$149.00" },
|
|
240
|
+
]}
|
|
241
|
+
/>
|
|
242
|
+
</CardBody>
|
|
243
|
+
</Card>
|
|
244
|
+
</div>
|
|
245
|
+
</main>
|
|
246
|
+
</AppShell>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## ðĻ Customizing Tokens
|
|
254
|
+
|
|
255
|
+
Override CSS variables in your own stylesheet to customize the theme:
|
|
256
|
+
|
|
257
|
+
```css
|
|
258
|
+
:root {
|
|
259
|
+
/* Change the primary color to emerald */
|
|
260
|
+
--color-primary-500: #10b981;
|
|
261
|
+
--color-primary-600: #059669;
|
|
262
|
+
--color-primary-700: #047857;
|
|
263
|
+
--color-primary: var(--color-primary-600);
|
|
264
|
+
--color-primary-hover: var(--color-primary-700);
|
|
265
|
+
|
|
266
|
+
/* Change the font */
|
|
267
|
+
--font-sans: "Inter", sans-serif;
|
|
268
|
+
|
|
269
|
+
/* Adjust border radius */
|
|
270
|
+
--radius: 0.75rem;
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## ð ïļ Tech Stack
|
|
277
|
+
|
|
278
|
+
- **React 18+** with TypeScript
|
|
279
|
+
- **Tailwind CSS** for utility classes
|
|
280
|
+
- **Radix UI** for accessible primitives (Dialog, Dropdown, Tooltip, Popover, AlertDialog)
|
|
281
|
+
- **CVA** (class-variance-authority) for variant management
|
|
282
|
+
- **tsup** for building ESM + CJS bundles
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## ðĶ Exports
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
dist/
|
|
290
|
+
âââ index.js # ESM
|
|
291
|
+
âââ index.cjs # CommonJS
|
|
292
|
+
âââ index.d.ts # TypeScript declarations
|
|
293
|
+
âââ index.d.cts # CTS declarations
|
|
294
|
+
âââ styles.css # Compiled styles
|
|
295
|
+
âââ tokens.css # Design tokens (import this!)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## ð License
|
|
299
|
+
|
|
300
|
+
MIT
|