@bgunnarsson/react-primitives 0.1.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/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/index.cjs +1131 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +621 -0
- package/dist/index.d.ts +621 -0
- package/dist/index.js +1131 -0
- package/dist/index.js.map +1 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bjarni Gunnarsson
|
|
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
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @bgunnarsson/react-primitives
|
|
2
|
+
|
|
3
|
+
An unstyled, accessible React component library. Built on [Radix UI](https://www.radix-ui.com/) primitives — components ship with zero CSS and are styled entirely via `className` in the consuming project.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Philosophy
|
|
7
|
+
|
|
8
|
+
- **Unstyled by default** — no opinions on colors, spacing, or typography. Apply Tailwind or any CSS solution via `className`.
|
|
9
|
+
- **Accessible** — Radix UI handles ARIA attributes, keyboard navigation, and focus management out of the box.
|
|
10
|
+
- **Composable** — compound component pattern throughout. Each named part (trigger, content, item, etc.) is a separate export that accepts `className`.
|
|
11
|
+
- **Framework-agnostic styling** — works with Tailwind CSS v3/v4, CSS Modules, plain CSS, or any other approach.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @bgunnarsson/react-primitives
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Peer dependencies
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add react react-dom
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Import components directly from the package:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { useState } from 'react'
|
|
31
|
+
import { Button, Dialog, DialogContent, DialogTitle } from '@bgunnarsson/react-primitives'
|
|
32
|
+
|
|
33
|
+
export function MyComponent() {
|
|
34
|
+
const [open, setOpen] = useState(false)
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<Button className="rounded-md bg-blue-600 px-4 py-2 text-sm text-white" onClick={() => setOpen(true)}>
|
|
39
|
+
Open dialog
|
|
40
|
+
</Button>
|
|
41
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
42
|
+
<DialogContent className="fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-xl bg-white p-6 shadow-xl">
|
|
43
|
+
<DialogTitle className="text-lg font-semibold">Hello</DialogTitle>
|
|
44
|
+
</DialogContent>
|
|
45
|
+
</Dialog>
|
|
46
|
+
</>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Lightbox CSS
|
|
52
|
+
|
|
53
|
+
If you use the `Lightbox` component, import its stylesheet once in your app entry or layout:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import 'yet-another-react-lightbox/styles.css'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Toaster
|
|
60
|
+
|
|
61
|
+
Place `<Toaster>` once in your root layout to enable toast notifications:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Toaster } from '@bgunnarsson/react-primitives'
|
|
65
|
+
|
|
66
|
+
export default function Layout({ children }) {
|
|
67
|
+
return <>{children}<Toaster /></>
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Development
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pnpm dev # Start Storybook on http://localhost:6006
|
|
75
|
+
pnpm build # Build the library (ESM + CJS + types)
|
|
76
|
+
pnpm build-storybook # Build static Storybook
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Component Reference
|
|
80
|
+
|
|
81
|
+
55 components across layout, form, navigation, overlay, and media categories.
|
|
82
|
+
|
|
83
|
+
### Layout & Content
|
|
84
|
+
|
|
85
|
+
| Component | Description |
|
|
86
|
+
|---|---|
|
|
87
|
+
| [Card](src/components/Card/Card.md) | Flexible container for composing any card layout |
|
|
88
|
+
| [EmptyState](src/components/EmptyState/EmptyState.md) | Zero-data placeholder with icon, title, description, and action |
|
|
89
|
+
| [Grid](src/components/Grid/Grid.md) | CSS grid container and item wrapper |
|
|
90
|
+
| [Separator](src/components/Separator/Separator.md) | Horizontal or vertical dividing line |
|
|
91
|
+
| [Skeleton](src/components/Skeleton/Skeleton.md) | Loading placeholder element |
|
|
92
|
+
| [ScrollArea](src/components/ScrollArea/ScrollArea.md) | Scrollable container with custom scrollbars |
|
|
93
|
+
| [Stat](src/components/Stat/Stat.md) | Metric display with label, value, and help text |
|
|
94
|
+
| [Table](src/components/Table/Table.md) | Semantic table with Header, Body, Footer, Row, Head, Cell, Caption |
|
|
95
|
+
| [Text](src/components/Text/Text.md) | Polymorphic text element (`p`, `span`, `h1`–`h6`) |
|
|
96
|
+
|
|
97
|
+
### Typography & Media
|
|
98
|
+
|
|
99
|
+
| Component | Description |
|
|
100
|
+
|---|---|
|
|
101
|
+
| [Badge](src/components/Badge/Badge.md) | Inline label for status, counts, or categories |
|
|
102
|
+
| [Icon](src/components/Icon/Icon.md) | SVG icon from sprite or external file |
|
|
103
|
+
| [Lightbox](src/components/Lightbox/Lightbox.md) | Full-screen image viewer with navigation |
|
|
104
|
+
| [Picture](src/components/Picture/Picture.md) | Responsive `<picture>` with multiple sources |
|
|
105
|
+
| [Richtext](src/components/Richtext/Richtext.md) | CMS HTML string renderer |
|
|
106
|
+
| [Spinner](src/components/Spinner/Spinner.md) | Animated loading indicator |
|
|
107
|
+
| [VideoPlayer](src/components/VideoPlayer/VideoPlayer.md) | HTML5 video wrapper |
|
|
108
|
+
|
|
109
|
+
### Form
|
|
110
|
+
|
|
111
|
+
| Component | Description |
|
|
112
|
+
|---|---|
|
|
113
|
+
| [Button](src/components/Button/Button.md) | Unstyled button element |
|
|
114
|
+
| [Checkbox](src/components/Checkbox/Checkbox.md) | Accessible checkbox with built-in indicator |
|
|
115
|
+
| [CheckboxGroup](src/components/CheckboxGroup/CheckboxGroup.md) | Controlled group of labelled checkboxes |
|
|
116
|
+
| [Combobox](src/components/Combobox/Combobox.md) | Searchable dropdown select |
|
|
117
|
+
| [DatePicker](src/components/DatePicker/DatePicker.md) | Single date picker with calendar popover |
|
|
118
|
+
| [FileInput](src/components/FileInput/FileInput.md) | File picker with drag-and-drop support |
|
|
119
|
+
| [Form](src/components/Form/Form.md) | Context-based field wrapper (label, control, error message) |
|
|
120
|
+
| [Input](src/components/Input/Input.md) | Text input field |
|
|
121
|
+
| [Label](src/components/Label/Label.md) | Form field label |
|
|
122
|
+
| [NumberInput](src/components/NumberInput/NumberInput.md) | Numeric input with increment/decrement buttons |
|
|
123
|
+
| [RadioGroup](src/components/RadioGroup/RadioGroup.md) | Radio button group |
|
|
124
|
+
| [Select](src/components/Select/Select.md) | Dropdown select with groups and separators |
|
|
125
|
+
| [Slider](src/components/Slider/Slider.md) | Accessible range slider |
|
|
126
|
+
| [Switch](src/components/Switch/Switch.md) | Toggle switch |
|
|
127
|
+
| [Textarea](src/components/Textarea/Textarea.md) | Multi-line text input |
|
|
128
|
+
|
|
129
|
+
### Navigation
|
|
130
|
+
|
|
131
|
+
| Component | Description |
|
|
132
|
+
|---|---|
|
|
133
|
+
| [Breadcrumbs](src/components/Breadcrumb/Breadcrumb.md) | Navigation trail with current page indicator |
|
|
134
|
+
| [Link](src/components/Link/Link.md) | Anchor element |
|
|
135
|
+
| [Nav](src/components/Nav/Nav.md) | Semantic `<nav>`, `<ul>`, `<li>` wrappers |
|
|
136
|
+
| [Pagination](src/components/Pagination/Pagination.md) | Page navigation with prev, next, and ellipsis |
|
|
137
|
+
| [Stepper](src/components/Stepper/Stepper.md) | Multi-step progress indicator |
|
|
138
|
+
| [Tabs](src/components/Tabs/Tabs.md) | Tabbed panel interface |
|
|
139
|
+
|
|
140
|
+
### Overlay & Popover
|
|
141
|
+
|
|
142
|
+
| Component | Description |
|
|
143
|
+
|---|---|
|
|
144
|
+
| [AlertDialog](src/components/AlertDialog/AlertDialog.md) | Confirmation dialog for destructive actions |
|
|
145
|
+
| [ContextMenu](src/components/ContextMenu/ContextMenu.md) | Right-click menu |
|
|
146
|
+
| [Dialog](src/components/Dialog/Dialog.md) | Modal dialog |
|
|
147
|
+
| [Drawer](src/components/Drawer/Drawer.md) | Bottom sheet with drag-to-dismiss |
|
|
148
|
+
| [DropdownMenu](src/components/DropdownMenu/DropdownMenu.md) | Button-triggered dropdown menu |
|
|
149
|
+
| [HoverCard](src/components/HoverCard/HoverCard.md) | Hover-triggered preview popover |
|
|
150
|
+
| [Popover](src/components/Popover/Popover.md) | Click-triggered floating panel |
|
|
151
|
+
| [Sheet](src/components/Sheet/Sheet.md) | Sliding panel from any screen edge |
|
|
152
|
+
| [Toast](src/components/Toast/Toast.md) | Toast notification system |
|
|
153
|
+
| [Tooltip](src/components/Tooltip/Tooltip.md) | Hover/focus tooltip |
|
|
154
|
+
|
|
155
|
+
### Disclosure & Interaction
|
|
156
|
+
|
|
157
|
+
| Component | Description |
|
|
158
|
+
|---|---|
|
|
159
|
+
| [Accordion](src/components/Accordion/Accordion.md) | Expandable sections (single or multiple) |
|
|
160
|
+
| [Carousel](src/components/Carousel/Carousel.md) | Touch-friendly slideshow |
|
|
161
|
+
| [Collapsible](src/components/Collapsible/Collapsible.md) | Single expandable section |
|
|
162
|
+
| [Progress](src/components/Progress/Progress.md) | Progress bar (0–100) |
|
|
163
|
+
| [Toggle](src/components/Toggle/Toggle.md) | Pressed/unpressed button |
|
|
164
|
+
| [ToggleGroup](src/components/ToggleGroup/ToggleGroup.md) | Group of toggles (single or multiple selection) |
|
|
165
|
+
|
|
166
|
+
### Display
|
|
167
|
+
|
|
168
|
+
| Component | Description |
|
|
169
|
+
|---|---|
|
|
170
|
+
| [Alert](src/components/Alert/Alert.md) | Status message with title and description |
|
|
171
|
+
| [Avatar](src/components/Avatar/Avatar.md) | Profile image with text fallback |
|