tailwind-zag 1.0.4 → 1.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.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 John Paul Calvo
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
1
+ MIT License
2
+
3
+ Copyright (c) 2024 John Paul Calvo
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
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,247 +1,247 @@
1
- # tailwind-zag
2
-
3
- A [TailwindCSS](https://tailwindcss.com/) plugin to style [zag](https://zagjs.com/)-powered-components using their [data attributes](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Solve_HTML_problems/Use_data_attributes).
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install -D tailwind-zag
9
- ```
10
-
11
- ## Usage
12
-
13
- Add the plugin to your tailwind config
14
-
15
- ```ts
16
- // tailwind.config.ts
17
- import type {Config} from 'tailwindcss';
18
- import zag from 'tailwind-zag';
19
-
20
- export default {
21
- content: ['./src/**/*.{js,ts,jsx,tsx}'],
22
- plugins: [
23
- // using the default prefix: "ui"
24
- zag,
25
-
26
- // or using a custom prefix
27
- zag({
28
- prefix: 'custom-prefix',
29
- }),
30
- ],
31
- } satisfies Config
32
- ```
33
-
34
- If you are using tailwind v4, you can add the plugin to your `css` file like this:
35
-
36
- ```css
37
- @plugin 'tailwind-zag';
38
- ```
39
-
40
- Style your components
41
-
42
- ```tsx
43
- import {Field} from '@ark-ui/react';
44
-
45
- export function Component() {
46
- return (
47
- <Field.Root>
48
- <Field.Input className="ui-invalid:border-red-300 ui-readonly:border-gray-200" />
49
- </Field.Root>
50
- );
51
- }
52
- ```
53
-
54
- ### Example using Ark UI react components
55
-
56
- ```js
57
- // tailwind.config.js
58
- import zag from 'tailwind-zag';
59
-
60
- /** @type {import('tailwindcss').Config} */
61
- export default {
62
- content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
63
- theme: {
64
- extend: {
65
- keyframes: {
66
- 'fade-in': {
67
- from: {opacity: '0'},
68
- to: {opacity: '1'},
69
- },
70
- 'fade-out': {
71
- from: {opacity: '1'},
72
- to: {opacity: '0'},
73
- },
74
- },
75
- animation: {
76
- 'fade-in': 'fade-in 250ms ease-in-out',
77
- 'fade-out': 'fade-out 150ms ease-in-out',
78
- },
79
- },
80
- },
81
- plugins: [zag],
82
- };
83
- ```
84
-
85
- ```tsx
86
- // App.tsx
87
- import {Dialog, Portal} from '@ark-ui/react';
88
-
89
- export function App() {
90
- return (
91
- <div className="p-4">
92
- <Dialog.Root>
93
- <Dialog.Trigger className="bg-neutral-900 rounded text-white font-semibold h-11 px-4">
94
- Open
95
- </Dialog.Trigger>
96
- <Portal>
97
- <Dialog.Backdrop className="fixed inset-0 bg-black/50 ui-open:animate-fade-in ui-closed:animate-fade-out" />
98
- <Dialog.Positioner>
99
- <Dialog.Content className="fixed max-w-[24rem] rounded w-full left-1/2 -translate-x-1/2 my-16 p-4 bg-white ui-open:animate-fade-in ui-closed:animate-fade-out">
100
- <Dialog.Title className="text-neutral-800 text-xl font-bold">Title</Dialog.Title>
101
- <Dialog.Description className="text-neutral-600">Description</Dialog.Description>
102
- <Dialog.CloseTrigger className="border border-neutral-300 h-11 w-full rounded mt-4">
103
- Close
104
- </Dialog.CloseTrigger>
105
- </Dialog.Content>
106
- </Dialog.Positioner>
107
- </Portal>
108
- </Dialog.Root>
109
- </div>
110
- );
111
- }
112
- ```
113
-
114
- ### Using inverse variants
115
-
116
- To apply the style to the component only when the data attribute is not present, you can add the `-not` prefix before the variant.
117
-
118
- ```tsx
119
- <Component className="ui-not-hover:bg-gray-50" />
120
- ```
121
-
122
- ### Using group variants
123
-
124
- You can add `-group` before the variant to apply the style to the component if its parent has the specific data attribute present.
125
-
126
- ```tsx
127
- <ParentComponent className="group">
128
- <ChildComponent className="ui-group-hover:bg-gray-50" />
129
- </ParentComponent>
130
- ```
131
-
132
- ### Using peer variants
133
-
134
- You can add `-peer` before the variant to apply the style to the component if its sibling has the specific data attribute present.
135
-
136
- ```tsx
137
- <ParentComponent>
138
- <ChildComponent className="ui-peer-hover:bg-gray-50" />
139
- <ChildComponent className="peer ui-hover:bg-gray-50" />
140
- </ParentComponent>
141
- ```
142
-
143
- ## Variants and their equivalent data attributes
144
-
145
- | Variant | Data attributes |
146
- |---------------------------|--------------------------------------------|
147
- | `hover` | `data-hover` |
148
- | `focus` | `data-focus` |
149
- | `focus-visible` | `data-focus-visible` |
150
- | `focusable` | `data-focusable` |
151
- | `active` | `data-active` |
152
- | `invalid` | `data-invalid` |
153
- | `disabled` | `data-disabled` |
154
- | `readonly` | `data-readonly` |
155
- | `current` | `data-current` |
156
- | `inview` | `data-inview` |
157
- | `copied` | `data-copied` |
158
- | `collapsible` | `data-collapsible` |
159
- | `highlighted` | `data-highlighted` |
160
- | `selected` | `data-selected` |
161
- | `placeholder-shown` | `data-placeholder-shown` |
162
- | `autoresize` | `data-autoresize` |
163
- | `required` | `data-required` |
164
- | `dragging` | `data-dragging` |
165
- | `complete` | `data-complete` |
166
- | `incomplete` | `data-incomplete` |
167
- | `expanded` | `data-expanded` |
168
- | `half` | `data-half` |
169
- | `first` | `data-first` |
170
- | `mounted` | `data-mounted` |
171
- | `overlap` | `data-overlap` |
172
- | `sibling` | `data-sibling` |
173
- | `paused` | `data-paused` |
174
- | `pressed` | `data-pressed` |
175
- | `on` | `data-state="on"` |
176
- | `off` | `data-state="off"` |
177
- | `open` | `data-state="open"` |
178
- | `closed` | `data-state="closed"` |
179
- | `hidden` | `data-state="hidden"` |
180
- | `visible` | `data-state="visible"` |
181
- | `checked` | `data-checked`, `data-state="checked"` |
182
- | `unchecked` | `data-unchecked`, `data-state="unchecked"` |
183
- | `indeterminate` | `data-state="indeterminate"` |
184
- | `vertical` | `data-orientation="vertical"` |
185
- | `horizontal` | `data-orientation="horizontal"` |
186
- | `placement-top` | `data-placement="top"` |
187
- | `placement-top-end` | `data-placement="top-end"` |
188
- | `placement-top-start` | `data-placement="top-start"` |
189
- | `placement-left` | `data-placement="left"` |
190
- | `placement-left-end` | `data-placement="left-end"` |
191
- | `placement-left-start` | `data-placement="left-start"` |
192
- | `placement-right` | `data-placement="right"` |
193
- | `placement-right-end` | `data-placement="right-end"` |
194
- | `placement-right-start` | `data-placement="right-start"` |
195
- | `placement-bottom` | `data-placement="bottom"` |
196
- | `placement-bottom-end` | `data-placement="bottom-end"` |
197
- | `placement-bottom-start` | `data-placement="bottom-start"` |
198
- | `side-top` | `data-side="top"` |
199
- | `side-left` | `data-side="left"` |
200
- | `side-right` | `data-side="right"` |
201
- | `side-bottom` | `data-side="bottom"` |
202
- | `align-center` | `data-align="center"` |
203
- | `align-start` | `data-align="start"` |
204
- | `align-end` | `data-align="end"` |
205
- | `today` | `data-today` |
206
- | `weekend` | `data-weekend` |
207
- | `in-range` | `data-in-range` |
208
- | `range-start` | `data-range-start` |
209
- | `range-end` | `data-range-end` |
210
- | `view-day` | `data-view="day"` |
211
- | `view-month` | `data-view="month"` |
212
- | `view-year` | `data-view="year"` |
213
- | `under-value` | `data-state="under-value"` |
214
- | `over-value` | `data-state="over-value"` |
215
- | `delete-intent` | `data-delete-intent` |
216
- | `unit-hour` | `data-unit="hour"` |
217
- | `unit-minute` | `data-unit="minute"` |
218
- | `unit-second` | `data-unit="second"` |
219
- | `unit-period` | `data-unit="period"` |
220
- | `channel-hue` | `data-channel="hue"` |
221
- | `channel-saturation` | `data-channel="saturation"` |
222
- | `channel-brightness` | `data-channel="brightness"` |
223
- | `channel-lightness` | `data-channel="lightness"` |
224
- | `channel-red` | `data-channel="red"` |
225
- | `channel-green` | `data-channel="green"` |
226
- | `channel-blue` | `data-channel="blue"` |
227
- | `channel-alpha` | `data-channel="alpha"` |
228
- | `channel-hex` | `data-channel="hex"` |
229
- | `channel-css` | `data-channel="css"` |
230
- | `tour-highlighted` | `data-tour-highlighted` |
231
- | `scroll-lock` | `data-scroll-lock` |
232
- | `inert` | `data-inert` |
233
- | `scope-<value>` | `data-scope="<value>"` |
234
- | `part-<value>` | `data-part="<value>"` |
235
- | `value-<value>` | `data-value="<value>"` |
236
- | `valuetext-<value>` | `data-valuetext="<value>"` |
237
- | `index-<value>` | `data-index="<value>"` |
238
- | `columns-<value>` | `data-columns="<value>"` |
239
- | `branch-<value>` | `data-branch="<value>"` |
240
- | `depth-<value>` | `data-depth="<value>"` |
241
- | `path-<value>` | `data-path="<value>"` |
242
- | `type-<value>` | `data-type="<value>"` |
243
-
244
- ## Credits
245
-
246
- - [@headlessui/tailwindcss](https://github.com/tailwindlabs/headlessui/tree/main/packages/%40headlessui-tailwindcss)
1
+ # tailwind-zag
2
+
3
+ A [TailwindCSS](https://tailwindcss.com/) plugin to style [zag](https://zagjs.com/)-powered-components using their [data attributes](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Solve_HTML_problems/Use_data_attributes).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -D tailwind-zag
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Add the plugin to your tailwind config
14
+
15
+ ```ts
16
+ // tailwind.config.ts
17
+ import type {Config} from 'tailwindcss';
18
+ import zag from 'tailwind-zag';
19
+
20
+ export default {
21
+ content: ['./src/**/*.{js,ts,jsx,tsx}'],
22
+ plugins: [
23
+ // using the default prefix: "ui"
24
+ zag,
25
+
26
+ // or using a custom prefix
27
+ zag({
28
+ prefix: 'custom-prefix',
29
+ }),
30
+ ],
31
+ } satisfies Config
32
+ ```
33
+
34
+ If you are using tailwind v4, you can add the plugin to your `css` file like this:
35
+
36
+ ```css
37
+ @plugin 'tailwind-zag';
38
+ ```
39
+
40
+ Style your components
41
+
42
+ ```tsx
43
+ import {Field} from '@ark-ui/react';
44
+
45
+ export function Component() {
46
+ return (
47
+ <Field.Root>
48
+ <Field.Input className="ui-invalid:border-red-300 ui-readonly:border-gray-200" />
49
+ </Field.Root>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ### Example using Ark UI react components
55
+
56
+ ```js
57
+ // tailwind.config.js
58
+ import zag from 'tailwind-zag';
59
+
60
+ /** @type {import('tailwindcss').Config} */
61
+ export default {
62
+ content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
63
+ theme: {
64
+ extend: {
65
+ keyframes: {
66
+ 'fade-in': {
67
+ from: {opacity: '0'},
68
+ to: {opacity: '1'},
69
+ },
70
+ 'fade-out': {
71
+ from: {opacity: '1'},
72
+ to: {opacity: '0'},
73
+ },
74
+ },
75
+ animation: {
76
+ 'fade-in': 'fade-in 250ms ease-in-out',
77
+ 'fade-out': 'fade-out 150ms ease-in-out',
78
+ },
79
+ },
80
+ },
81
+ plugins: [zag],
82
+ };
83
+ ```
84
+
85
+ ```tsx
86
+ // App.tsx
87
+ import {Dialog, Portal} from '@ark-ui/react';
88
+
89
+ export function App() {
90
+ return (
91
+ <div className="p-4">
92
+ <Dialog.Root>
93
+ <Dialog.Trigger className="bg-neutral-900 rounded text-white font-semibold h-11 px-4">
94
+ Open
95
+ </Dialog.Trigger>
96
+ <Portal>
97
+ <Dialog.Backdrop className="fixed inset-0 bg-black/50 ui-open:animate-fade-in ui-closed:animate-fade-out" />
98
+ <Dialog.Positioner>
99
+ <Dialog.Content className="fixed max-w-[24rem] rounded w-full left-1/2 -translate-x-1/2 my-16 p-4 bg-white ui-open:animate-fade-in ui-closed:animate-fade-out">
100
+ <Dialog.Title className="text-neutral-800 text-xl font-bold">Title</Dialog.Title>
101
+ <Dialog.Description className="text-neutral-600">Description</Dialog.Description>
102
+ <Dialog.CloseTrigger className="border border-neutral-300 h-11 w-full rounded mt-4">
103
+ Close
104
+ </Dialog.CloseTrigger>
105
+ </Dialog.Content>
106
+ </Dialog.Positioner>
107
+ </Portal>
108
+ </Dialog.Root>
109
+ </div>
110
+ );
111
+ }
112
+ ```
113
+
114
+ ### Using inverse variants
115
+
116
+ To apply the style to the component only when the data attribute is not present, you can add the `-not` prefix before the variant.
117
+
118
+ ```tsx
119
+ <Component className="ui-not-hover:bg-gray-50" />
120
+ ```
121
+
122
+ ### Using group variants
123
+
124
+ You can add `-group` before the variant to apply the style to the component if its parent has the specific data attribute present.
125
+
126
+ ```tsx
127
+ <ParentComponent className="group">
128
+ <ChildComponent className="ui-group-hover:bg-gray-50" />
129
+ </ParentComponent>
130
+ ```
131
+
132
+ ### Using peer variants
133
+
134
+ You can add `-peer` before the variant to apply the style to the component if its sibling has the specific data attribute present.
135
+
136
+ ```tsx
137
+ <ParentComponent>
138
+ <ChildComponent className="ui-peer-hover:bg-gray-50" />
139
+ <ChildComponent className="peer ui-hover:bg-gray-50" />
140
+ </ParentComponent>
141
+ ```
142
+
143
+ ## Variants and their equivalent data attributes
144
+
145
+ | Variant | Data attributes |
146
+ |---------------------------|--------------------------------------------|
147
+ | `hover` | `data-hover` |
148
+ | `focus` | `data-focus` |
149
+ | `focus-visible` | `data-focus-visible` |
150
+ | `focusable` | `data-focusable` |
151
+ | `active` | `data-active` |
152
+ | `invalid` | `data-invalid` |
153
+ | `disabled` | `data-disabled` |
154
+ | `readonly` | `data-readonly` |
155
+ | `current` | `data-current` |
156
+ | `inview` | `data-inview` |
157
+ | `copied` | `data-copied` |
158
+ | `collapsible` | `data-collapsible` |
159
+ | `highlighted` | `data-highlighted` |
160
+ | `selected` | `data-selected` |
161
+ | `placeholder-shown` | `data-placeholder-shown` |
162
+ | `autoresize` | `data-autoresize` |
163
+ | `required` | `data-required` |
164
+ | `dragging` | `data-dragging` |
165
+ | `complete` | `data-complete` |
166
+ | `incomplete` | `data-incomplete` |
167
+ | `expanded` | `data-expanded` |
168
+ | `half` | `data-half` |
169
+ | `first` | `data-first` |
170
+ | `mounted` | `data-mounted` |
171
+ | `overlap` | `data-overlap` |
172
+ | `sibling` | `data-sibling` |
173
+ | `paused` | `data-paused` |
174
+ | `pressed` | `data-pressed` |
175
+ | `on` | `data-state="on"` |
176
+ | `off` | `data-state="off"` |
177
+ | `open` | `data-state="open"` |
178
+ | `closed` | `data-state="closed"` |
179
+ | `hidden` | `data-state="hidden"` |
180
+ | `visible` | `data-state="visible"` |
181
+ | `checked` | `data-checked`, `data-state="checked"` |
182
+ | `unchecked` | `data-unchecked`, `data-state="unchecked"` |
183
+ | `indeterminate` | `data-state="indeterminate"` |
184
+ | `vertical` | `data-orientation="vertical"` |
185
+ | `horizontal` | `data-orientation="horizontal"` |
186
+ | `placement-top` | `data-placement="top"` |
187
+ | `placement-top-end` | `data-placement="top-end"` |
188
+ | `placement-top-start` | `data-placement="top-start"` |
189
+ | `placement-left` | `data-placement="left"` |
190
+ | `placement-left-end` | `data-placement="left-end"` |
191
+ | `placement-left-start` | `data-placement="left-start"` |
192
+ | `placement-right` | `data-placement="right"` |
193
+ | `placement-right-end` | `data-placement="right-end"` |
194
+ | `placement-right-start` | `data-placement="right-start"` |
195
+ | `placement-bottom` | `data-placement="bottom"` |
196
+ | `placement-bottom-end` | `data-placement="bottom-end"` |
197
+ | `placement-bottom-start` | `data-placement="bottom-start"` |
198
+ | `side-top` | `data-side="top"` |
199
+ | `side-left` | `data-side="left"` |
200
+ | `side-right` | `data-side="right"` |
201
+ | `side-bottom` | `data-side="bottom"` |
202
+ | `align-center` | `data-align="center"` |
203
+ | `align-start` | `data-align="start"` |
204
+ | `align-end` | `data-align="end"` |
205
+ | `today` | `data-today` |
206
+ | `weekend` | `data-weekend` |
207
+ | `in-range` | `data-in-range` |
208
+ | `range-start` | `data-range-start` |
209
+ | `range-end` | `data-range-end` |
210
+ | `view-day` | `data-view="day"` |
211
+ | `view-month` | `data-view="month"` |
212
+ | `view-year` | `data-view="year"` |
213
+ | `under-value` | `data-state="under-value"` |
214
+ | `over-value` | `data-state="over-value"` |
215
+ | `delete-intent` | `data-delete-intent` |
216
+ | `unit-hour` | `data-unit="hour"` |
217
+ | `unit-minute` | `data-unit="minute"` |
218
+ | `unit-second` | `data-unit="second"` |
219
+ | `unit-period` | `data-unit="period"` |
220
+ | `channel-hue` | `data-channel="hue"` |
221
+ | `channel-saturation` | `data-channel="saturation"` |
222
+ | `channel-brightness` | `data-channel="brightness"` |
223
+ | `channel-lightness` | `data-channel="lightness"` |
224
+ | `channel-red` | `data-channel="red"` |
225
+ | `channel-green` | `data-channel="green"` |
226
+ | `channel-blue` | `data-channel="blue"` |
227
+ | `channel-alpha` | `data-channel="alpha"` |
228
+ | `channel-hex` | `data-channel="hex"` |
229
+ | `channel-css` | `data-channel="css"` |
230
+ | `tour-highlighted` | `data-tour-highlighted` |
231
+ | `scroll-lock` | `data-scroll-lock` |
232
+ | `inert` | `data-inert` |
233
+ | `scope-<value>` | `data-scope="<value>"` |
234
+ | `part-<value>` | `data-part="<value>"` |
235
+ | `value-<value>` | `data-value="<value>"` |
236
+ | `valuetext-<value>` | `data-valuetext="<value>"` |
237
+ | `index-<value>` | `data-index="<value>"` |
238
+ | `columns-<value>` | `data-columns="<value>"` |
239
+ | `branch-<value>` | `data-branch="<value>"` |
240
+ | `depth-<value>` | `data-depth="<value>"` |
241
+ | `path-<value>` | `data-path="<value>"` |
242
+ | `type-<value>` | `data-type="<value>"` |
243
+
244
+ ## Credits
245
+
246
+ - [@headlessui/tailwindcss](https://github.com/tailwindlabs/headlessui/tree/main/packages/%40headlessui-tailwindcss)
247
247
  - [@kobalte/tailwindcss](https://github.com/kobaltedev/kobalte/tree/main/packages/tailwindcss)