@windi-ui/core 0.8.0-beta.1 → 0.8.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,27 +1,42 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/windi-ui/windi-ui/main/docs/public/logo-lockup.svg" alt="WindiUI" width="292">
2
+ <img src="https://raw.githubusercontent.com/windi-ui/windi-ui/main/docs/public/logo-lockup-npm.svg" alt="WindiUI" width="306">
3
3
  </p>
4
4
 
5
5
  # WindiUI
6
6
 
7
7
  🚧 under development 🚧
8
8
 
9
- WindiUI is a modern, modular, and customizable UI component library designed to work seamlessly with Tailwind CSS. It provides developers with a set of reusable components and utilities to build beautiful and consistent user interfaces efficiently.
9
+ WindiUI is a Tailwind CSS plugin that adds three axes to your classes: a color (`c-*`), a variant (`v-*`) and a size
10
+ (`s-*`). Each one is a class that sets CSS variables, so `btn c-blue v-solid s-lg` is a large, solid, blue button, and
11
+ the same `btn` takes every palette of your theme, in light and dark mode.
12
+
13
+ **[Documentation](https://windi-ui.github.io/windi-ui/guide/introduction)** ·
14
+ [Installation](https://windi-ui.github.io/windi-ui/guide/installation) ·
15
+ [Options](https://windi-ui.github.io/windi-ui/reference/options) ·
16
+ [Builder API](https://windi-ui.github.io/windi-ui/reference/builder) ·
17
+ [Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8)
10
18
 
11
19
  ## Features
12
20
 
13
- - **Core Components**: A collection of essential UI components such as buttons, badges, and cards.
14
- - **Tailwind Integration**: Utilities and themes tailored for Tailwind CSS.
15
- - **Customizable**: Easily extend and modify components to fit your design system.
16
- - **Extensible**: Build your own components and variants with advanced utilities.
17
- - **Dark mode**: Automatically detect your dark mode config and apply appropriate style.
21
+ - **Three axes.** `c-*` picks one of your palettes, `v-*` a variant and `s-*` a size. They combine freely, and colors
22
+ and sizes inherit down the tree.
23
+ - **Calibrated variants.** `default`, `solid`, `outline` and `light` pick shades of the 11-shade palette for the
24
+ background, border and text, with soft, muted and accent levels, a hover state and dark values. A variant can use
25
+ other shades for some colors, such as a darker `solid` yellow.
26
+ - **Presets.** `nuxt-ui` adds `soft`, `subtle`, `ghost` and `link`, with text that passes a contrast of 4.5:1.
27
+ - **Components and utilities.** `btn`, `badge`, `bg-v`, `text-v`, `border-v`, and `apply-v` for your own CSS.
28
+ - **Builder API.** Add, replace, change or remove colors, variants, sizes and components.
29
+ - **Runtime palettes.** A color given by CSS variables follows a theme set at runtime.
30
+ - **Dark mode.** Follows the dark variant of your Tailwind setup, with nothing to configure.
31
+ - **Tailwind v3 and v4**, with the same class names.
18
32
 
19
33
  ## Getting Started
20
34
 
21
35
  ### Prerequisites
22
36
 
23
- - Node.js (v22 or higher)
24
- - Tailwind v3/v4
37
+ - Node.js 22 or higher, or 22.12 or higher to load a
38
+ [config file](https://windi-ui.github.io/windi-ui/reference/config-file). The tests run on Node.js 26.
39
+ - Tailwind CSS v3.3 or higher, or v4. The tests run on Tailwind CSS 3.4, 4.1.16 and the current 4.3.
25
40
 
26
41
  ### Installation
27
42
 
@@ -36,87 +51,100 @@ On Tailwind v4, load it from your stylesheet:
36
51
  @plugin "@windi-ui/tailwind";
37
52
  ```
38
53
 
39
- Options go in the `@plugin` block, in a `windiui.config.ts` config file that exports them with `defineConfig`, or in
40
- a `windiui.plugin.ts` plugin module that exports `windiui({ ... })` and is loaded with `@plugin "./windiui.plugin.ts"`;
41
- see [Installation](https://windi-ui.github.io/windi-ui/guide/installation) and [Config file and plugin module](https://windi-ui.github.io/windi-ui/reference/config-file).
42
-
43
- On Tailwind v3, add the plugin to your `tailwind.config.ts` / `tailwind.config.js` file:
54
+ On Tailwind v3, add it to the plugins of your Tailwind config:
44
55
 
45
56
  ```ts
46
57
  import type { Config } from 'tailwindcss';
47
58
  import windiui from '@windi-ui/tailwind';
48
59
 
49
60
  export default {
50
- // ...
51
- plugins: [
52
- windiui()
53
- ],
61
+ content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
62
+ plugins: [windiui()],
54
63
  } satisfies Config;
55
64
  ```
56
65
 
57
- ### Usage
58
-
59
- #### Colors
60
-
61
- WindiUI automatically detect all the colors in your theme and make them available to be used with components and utility classes.
66
+ Options go in the `@plugin` block, in a `windiui.config.ts` config file, or in a plugin module; see
67
+ [Installation](https://windi-ui.github.io/windi-ui/guide/installation) and
68
+ [Options](https://windi-ui.github.io/windi-ui/reference/options).
62
69
 
63
- First you choose the color you want with `c-*` (e.g. `c-blue`, ...), then apply it with Tailwind class (e.g. `bg-c-800`, ...)
70
+ ### Usage
64
71
 
65
72
  ```html
66
- <div class="c-blue bg-c-800/50 text-c-300 border border-c-500 p-5">Hello World</div>
73
+ <button class="btn c-blue v-solid">Save</button>
74
+ <button class="btn c-red v-outline s-sm">Delete</button>
75
+ <button class="btn c-blue v-light s-lg">Inbox <span class="badge c-red v-solid">3</span></button>
76
+ <div class="c-green v-light bg-v text-v border border-v-muted rounded p-4">A box painted by its variant</div>
77
+ <div class="c-amber bg-c-100 text-c-800 p-4">Shades of the current color</div>
67
78
  ```
68
79
 
69
- #### Variants
80
+ A plugin module configures WindiUI with the builder API. This one adds the `nuxt-ui` variants, gives `solid` a darker
81
+ background with yellow, and adds a `c-primary` color whose shades are CSS variables set at runtime:
70
82
 
71
- Make your component more flexible by styling it with variant utilities classes, use (`bg-v`, `text-v`, `border-v`, ...) to apply the colors, then use `v-*` to change the style, WindiUI has the following built-in variants styles: `v-default`, `v-solid`, `v-outline`, `v-light`.
83
+ ```ts
84
+ // windiui.plugin.ts
85
+ import windiui from '@windi-ui/tailwind';
72
86
 
73
- ```html
74
- <span class="inline-block c-red v-solid bg-v-soft/60 text-v border border-v py-1 px-2 rounded">Test</span>
87
+ export default windiui({
88
+ presets: ['nuxt-ui'],
89
+ build: (builder) => builder
90
+ .overrideVariant('solid', 'yellow', { bg: '700', pseudos: { ':hover': { bg: '800' } } })
91
+ .addColor('primary', { vars: '--ui-color-primary' }),
92
+ });
75
93
  ```
76
94
 
77
- #### Components
78
-
79
- WindiUI comes with a few built-in components (e.g. `btn`, `badge`, ... more to come) that can be styled with `c-*`, `v-*` utilities, some components also support `s-*` utility to control its size.
95
+ ```css
96
+ @import "tailwindcss";
97
+ @plugin "./windiui.plugin.ts";
98
+ ```
80
99
 
81
100
  ```html
82
- <button class="btn v-light c-blue s-lg">
83
- Primary
84
- <span class="badge v-solid c-red leading-none rounded-full absolute top-0 start-full -translate-1/2">32</span>
85
- </button>
101
+ <button class="btn c-yellow v-solid">Solid yellow, on shade 700</button>
102
+ <button class="btn c-primary v-soft">Soft, in the runtime color</button>
86
103
  ```
87
104
 
88
- You can find more code examples in the [playground](https://github.com/windi-ui/windi-ui/blob/main/playground/vue-tailwindv4/src/App.vue).
105
+ The [guide](https://windi-ui.github.io/windi-ui/guide/introduction) covers each part, with live examples. The
106
+ [playground](https://github.com/windi-ui/windi-ui/blob/main/playground/vue-tailwindv4/src/App.vue) has more.
89
107
 
90
- #### Class names built at runtime
108
+ #### Variants and sizes in your own CSS
91
109
 
92
- Tailwind only emits the classes it finds in your source. A class built at runtime, such as `c-${color}` from a
93
- component prop, has to be safelisted.
94
-
95
- On Tailwind v4, add one line to the stylesheet. `safelistSource()` returns the string for your config:
110
+ `apply-v` paints the background, border and text from the current variant, at rest and on hover, as `btn` does. A
111
+ list in brackets chooses the properties and the states. The `s-*` classes set size variables that a control of your
112
+ own can read:
96
113
 
97
114
  ```css
98
- @source inline("{c-{accent,accent-accent,accent-blue,accent-default,accent-red,blue,default,red},v-{default,light,outline,solid},s-{default,lg,sm,xl,xs}}");
99
- ```
100
-
101
- ```ts
102
- import { safelistSource } from '@windi-ui/tailwind';
115
+ @import "tailwindcss";
116
+ @plugin "@windi-ui/tailwind";
103
117
 
104
- safelistSource({}, { palettes: ['blue', 'red'] }); // the string above; without `palettes`, every palette of the default theme
118
+ .card-action { @apply apply-v; } /* bg, border, text + :hover */
119
+ .tab { @apply apply-v-[bg,text,hover,focus-visible]; } /* chosen properties and states */
120
+ .my-input { /* as tall as a btn of the same size */
121
+ padding: calc(var(--wui-s-spacing-1\.5) - 1px) calc(var(--wui-s-spacing-3) - 1px);
122
+ border: 1px solid;
123
+ font-size: var(--wui-s-text);
124
+ line-height: var(--wui-s-line-height);
125
+ }
105
126
  ```
106
127
 
107
- On Tailwind v3, `windiui({ safelist: true })` emits every `c-*`, `v-*` and `s-*` class.
128
+ | Size variable | Meaning |
129
+ | --- | --- |
130
+ | `--wui-s-spacing-1`, `-1\.5`, `-2`, `-3`, `-4` | Spacing slots |
131
+ | `--wui-s-text`, `--wui-s-line-height` | Font size and line height |
132
+ | `--wui-s-<key>` | A key of your own on a size, such as `height` for an app that wants a fixed control height |
108
133
 
109
- See [the `safelist` option](https://windi-ui.github.io/windi-ui/reference/options#safelist) for the details.
134
+ The `variantUtilities` option adds color utilities painted from a variant, such as `bg-yellow` with the `solid`
135
+ background of yellow, overrides and dark values included. See
136
+ [Utilities](https://windi-ui.github.io/windi-ui/guide/utilities) and
137
+ [Sizes](https://windi-ui.github.io/windi-ui/guide/sizes).
110
138
 
111
139
  ## Upgrading from 0.7
112
140
 
113
- See [Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8). The one thing to check: 0.8 no longer sets the default variant on every
114
- element with a `*` rule (the new `variantScope` option, default `'element'`). `btn`, `badge` and the `bg-v`,
115
- `text-v`, `border-v` utilities look the same, but your own CSS that reads a variant variable directly, such as
116
- `background: var(--wui-v-bg)`, on an element without a `v-*` class no longer gets a value. Either set
117
- `windiui({ variantScope: 'universal' })` to keep the 0.7 output, or give the rule a variant with
118
- `@apply v-default v-scope`. A rule that uses `@apply v-*` should also apply `v-scope`, so its children do not
119
- inherit the variant.
141
+ See [Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8#upgrading-from-0-7). The one thing to check: 0.8
142
+ no longer sets the default variant on every element with a `*` rule (the new `variantScope` option, default
143
+ `'element'`). `btn`, `badge` and the `bg-v`, `text-v`, `border-v` utilities look the same, but your own CSS that
144
+ reads a variant variable directly, such as `background: var(--wui-v-bg)`, on an element without a `v-*` class no
145
+ longer gets a value. Either set `windiui({ variantScope: 'universal' })` to keep the 0.7 output, or give the rule a
146
+ variant with `@apply v-default v-scope`. A rule that uses `@apply v-*` should also apply `v-scope`, so its children
147
+ do not inherit the variant.
120
148
 
121
149
  ## Documentation
122
150
 
@@ -169,6 +197,9 @@ The tests are in `test/` and run on Vitest.
169
197
  snapshot diff with the code, so the review shows what changed for users.
170
198
  - **Browser.** `test/browser.test.ts` checks what a snapshot cannot: how the CSS cascades and inherits.
171
199
  It drives the Chrome or Edge already installed on the machine, and is skipped locally if there is neither.
200
+ - **README.** `test/readme.ts` compiles every TypeScript sample of this file on each fixture and every CSS sample
201
+ on the Tailwind v4 ones, and checks that the classes of its HTML samples exist. Keep the samples compilable when
202
+ you change them.
172
203
  - A test file works with one fixture only, because the helper that loads a fixture changes the working directory.
173
204
 
174
205
  ### Project Structure
@@ -1,4 +1,4 @@
1
- import { _ as IComponent, g as ComponentBuilderContext, h as ComponentBuilder } from "./vars-BQT8iude.cjs";
1
+ import { C as ComponentBuilderContext, S as ComponentBuilder, w as IComponent } from "./vars-D-T56h9H.cjs";
2
2
  export declare function defineComponent(component: IComponent | ComponentBuilder): ComponentBuilder;
3
3
  declare const _default$1: ComponentBuilder;
4
4
  declare const _default: ComponentBuilder;
@@ -1,4 +1,4 @@
1
- import { n as ComponentBuilderContext, r as IComponent, t as ComponentBuilder } from "./types-DKL2Gqrn.mjs";
1
+ import { n as ComponentBuilderContext, r as IComponent, t as ComponentBuilder } from "./types-7pMUZGLb.mjs";
2
2
  export declare function defineComponent(component: IComponent | ComponentBuilder): ComponentBuilder;
3
3
  declare const _default$1: ComponentBuilder;
4
4
  declare const _default: ComponentBuilder;