tailwind-styled-v4 1.0.0 → 4.0.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.
Files changed (89) hide show
  1. package/dist/animate.cjs +252 -0
  2. package/dist/animate.cjs.map +1 -0
  3. package/dist/animate.d.cts +117 -0
  4. package/dist/animate.d.ts +117 -0
  5. package/dist/animate.js +245 -0
  6. package/dist/animate.js.map +1 -0
  7. package/dist/astTransform-ua-eapqs.d.cts +41 -0
  8. package/dist/astTransform-ua-eapqs.d.ts +41 -0
  9. package/dist/compiler.cjs +3594 -0
  10. package/dist/compiler.cjs.map +1 -0
  11. package/dist/compiler.d.cts +716 -0
  12. package/dist/compiler.d.ts +716 -0
  13. package/dist/compiler.js +3535 -0
  14. package/dist/compiler.js.map +1 -0
  15. package/dist/css.cjs +71 -0
  16. package/dist/css.cjs.map +1 -0
  17. package/dist/css.d.cts +45 -0
  18. package/dist/css.d.ts +45 -0
  19. package/dist/css.js +62 -0
  20. package/dist/css.js.map +1 -0
  21. package/dist/devtools.cjs +959 -0
  22. package/dist/devtools.cjs.map +1 -0
  23. package/dist/devtools.d.cts +22 -0
  24. package/dist/devtools.d.ts +22 -0
  25. package/dist/devtools.js +952 -0
  26. package/dist/devtools.js.map +1 -0
  27. package/dist/index.cjs +1058 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +584 -0
  30. package/dist/index.d.ts +456 -958
  31. package/dist/index.js +1021 -8
  32. package/dist/index.js.map +1 -1
  33. package/dist/next.cjs +268 -0
  34. package/dist/next.cjs.map +1 -0
  35. package/dist/next.d.cts +45 -0
  36. package/dist/next.d.ts +45 -0
  37. package/dist/next.js +261 -0
  38. package/dist/next.js.map +1 -0
  39. package/dist/plugins.cjs +396 -0
  40. package/dist/plugins.cjs.map +1 -0
  41. package/dist/plugins.d.cts +231 -0
  42. package/dist/plugins.d.ts +231 -0
  43. package/dist/plugins.js +381 -0
  44. package/dist/plugins.js.map +1 -0
  45. package/dist/preset.cjs +129 -0
  46. package/dist/preset.cjs.map +1 -0
  47. package/dist/preset.d.cts +249 -0
  48. package/dist/preset.d.ts +249 -0
  49. package/dist/preset.js +124 -0
  50. package/dist/preset.js.map +1 -0
  51. package/dist/theme.cjs +154 -0
  52. package/dist/theme.cjs.map +1 -0
  53. package/dist/theme.d.cts +181 -0
  54. package/dist/theme.d.ts +181 -0
  55. package/dist/theme.js +148 -0
  56. package/dist/theme.js.map +1 -0
  57. package/dist/turbopackLoader.cjs +2689 -0
  58. package/dist/turbopackLoader.cjs.map +1 -0
  59. package/dist/turbopackLoader.d.cts +22 -0
  60. package/dist/turbopackLoader.d.ts +22 -0
  61. package/dist/turbopackLoader.js +2681 -0
  62. package/dist/turbopackLoader.js.map +1 -0
  63. package/dist/vite.cjs +105 -0
  64. package/dist/vite.cjs.map +1 -0
  65. package/dist/vite.d.cts +22 -0
  66. package/dist/vite.d.ts +22 -0
  67. package/dist/vite.js +96 -0
  68. package/dist/vite.js.map +1 -0
  69. package/dist/webpackLoader.cjs +2670 -0
  70. package/dist/webpackLoader.cjs.map +1 -0
  71. package/dist/webpackLoader.d.cts +24 -0
  72. package/dist/webpackLoader.d.ts +24 -0
  73. package/dist/webpackLoader.js +2662 -0
  74. package/dist/webpackLoader.js.map +1 -0
  75. package/package.json +66 -90
  76. package/CHANGELOG.md +0 -75
  77. package/LICENSE +0 -21
  78. package/README.md +0 -330
  79. package/dist/compiler/index.d.mts +0 -214
  80. package/dist/compiler/index.d.ts +0 -214
  81. package/dist/compiler/index.js +0 -546
  82. package/dist/compiler/index.js.map +0 -1
  83. package/dist/compiler/index.mjs +0 -504
  84. package/dist/compiler/index.mjs.map +0 -1
  85. package/dist/index.d.mts +0 -1086
  86. package/dist/index.mjs +0 -9
  87. package/dist/index.mjs.map +0 -1
  88. package/dist/turbopack-loader.js +0 -232
  89. package/dist/webpack-loader.js +0 -213
package/package.json CHANGED
@@ -1,55 +1,64 @@
1
1
  {
2
2
  "name": "tailwind-styled-v4",
3
- "version": "1.0.0",
4
- "description": "PRO Engine: styled-components + Tailwind CSS v4, zero-runtime compile, variant system, responsive props, plugin ecosystem",
3
+ "version": "4.0.0",
4
+ "description": "Zero-config, zero-runtime, compiler-driven Tailwind styling — tw.div, variants, RSC-aware",
5
5
  "author": "Dictionar32",
6
6
  "license": "MIT",
7
- "keywords": [
8
- "tailwind",
9
- "tailwindcss",
10
- "styled-components",
11
- "css-in-js",
12
- "variants",
13
- "cva",
14
- "stitches",
15
- "panda-css",
16
- "twin.macro",
17
- "react",
18
- "next.js",
19
- "vite",
20
- "zero-runtime",
21
- "typescript",
22
- "shadcn",
23
- "radix",
24
- "headless-ui"
25
- ],
26
- "homepage": "https://github.com/Dictionar32/tailwind-styled-v4.1.2",
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/Dictionar32/tailwind-styled-v4.1.2.git"
30
- },
31
- "bugs": {
32
- "url": "https://github.com/Dictionar32/tailwind-styled-v4.1.2/issues"
33
- },
34
- "main": "dist/index.js",
35
- "module": "dist/index.mjs",
36
- "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
37
11
  "exports": {
38
12
  ".": {
39
- "types": "./dist/index.d.ts",
40
- "import": "./dist/index.mjs",
41
- "require": "./dist/index.js"
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./next": {
19
+ "types": "./dist/next.d.ts",
20
+ "import": "./dist/next.js",
21
+ "require": "./dist/next.cjs"
22
+ },
23
+ "./vite": {
24
+ "types": "./dist/vite.d.ts",
25
+ "import": "./dist/vite.js",
26
+ "require": "./dist/vite.cjs"
42
27
  },
43
28
  "./compiler": {
44
- "types": "./dist/compiler/index.d.ts",
45
- "import": "./dist/compiler/index.mjs",
46
- "require": "./dist/compiler/index.js"
29
+ "types": "./dist/compiler.d.ts",
30
+ "import": "./dist/compiler.js",
31
+ "require": "./dist/compiler.cjs"
47
32
  },
48
- "./webpack-loader": {
49
- "require": "./dist/webpack-loader.js"
33
+ "./preset": {
34
+ "types": "./dist/preset.d.ts",
35
+ "import": "./dist/preset.js",
36
+ "require": "./dist/preset.cjs"
50
37
  },
51
- "./turbopack-loader": {
52
- "require": "./dist/turbopack-loader.js"
38
+ "./css": {
39
+ "types": "./dist/css.d.ts",
40
+ "import": "./dist/css.js",
41
+ "require": "./dist/css.cjs"
42
+ },
43
+ "./plugins": {
44
+ "types": "./dist/plugins.d.ts",
45
+ "import": "./dist/plugins.js",
46
+ "require": "./dist/plugins.cjs"
47
+ },
48
+ "./devtools": {
49
+ "types": "./dist/devtools.d.ts",
50
+ "import": "./dist/devtools.js",
51
+ "require": "./dist/devtools.cjs"
52
+ },
53
+ "./animate": {
54
+ "types": "./dist/animate.d.ts",
55
+ "import": "./dist/animate.js",
56
+ "require": "./dist/animate.cjs"
57
+ },
58
+ "./theme": {
59
+ "types": "./dist/theme.d.ts",
60
+ "import": "./dist/theme.js",
61
+ "require": "./dist/theme.cjs"
53
62
  },
54
63
  "./package.json": "./package.json"
55
64
  },
@@ -60,62 +69,29 @@
60
69
  "LICENSE"
61
70
  ],
62
71
  "sideEffects": false,
63
- "engines": {
64
- "node": ">=18.0.0"
65
- },
66
- "scripts": {
67
- "build": "tsup",
68
- "build:types": "ts-node -P tsconfig.test.json scripts/build-types.ts",
69
- "build:safelist": "ts-node -P tsconfig.test.json scripts/extract-css.ts",
70
- "build:all": "npm run build:types && npm run build",
71
- "analyze": "npm run build && ts-node -P tsconfig.test.json scripts/analyze-bundle.ts",
72
- "dev": "tsup --watch",
73
- "prepare": "npm run build",
74
- "setup": "ts-node -P tsconfig.test.json src/setup/intellisense.ts",
75
- "test": "npm run test:unit && npm run test:snapshot",
76
- "test:unit": "ts-node -P tsconfig.test.json tests/unit/propEngine.unit.test.ts && ts-node -P tsconfig.test.json tests/unit/validator.test.ts",
77
- "test:snapshot": "ts-node -P tsconfig.test.json tests/integration/snapshot.test.ts",
78
- "test:legacy": "ts-node -P tsconfig.test.json tests/variant.test.ts && ts-node -P tsconfig.test.json tests/propEngine.test.ts && ts-node -P tsconfig.test.json tests/responsive.test.ts && ts-node -P tsconfig.test.json tests/zeroRuntime.test.ts",
79
- "test:all": "npm run test && npm run test:legacy",
80
- "typecheck": "tsc --noEmit",
81
- "lint": "eslint src tests",
82
- "lint:fix": "eslint src tests --fix",
83
- "format": "prettier --write src tests scripts starters",
84
- "format:check": "prettier --check src tests scripts starters",
85
- "clean": "rm -rf dist bundle-report.json tailwind.safelist.json"
72
+ "engines": { "node": ">=18" },
73
+ "dependencies": {
74
+ "tailwind-merge": "^3",
75
+ "postcss": "^8"
86
76
  },
87
77
  "peerDependencies": {
88
- "clsx": "^2",
89
78
  "react": ">=18",
90
- "react-dom": ">=18",
91
- "styled-components": ">=6",
92
- "tailwind-merge": "^3"
79
+ "react-dom": ">=18"
93
80
  },
94
- "peerDependenciesMeta": {
95
- "clsx": {
96
- "optional": true
97
- },
98
- "tailwind-merge": {
99
- "optional": true
100
- }
81
+ "peerDependenciesOptional": {
82
+ "tailwindcss": "^4",
83
+ "@tailwindcss/postcss": "^4"
101
84
  },
102
85
  "devDependencies": {
103
- "@eslint/js": "^9",
86
+ "@tailwind-styled/animate": "*",
87
+ "@types/node": "^20",
104
88
  "@types/react": "^19",
105
- "@types/react-dom": "^19",
106
- "@types/styled-components": "^5",
107
- "@typescript-eslint/eslint-plugin": "^8",
108
- "@typescript-eslint/parser": "^8",
109
- "eslint": "^9",
110
- "eslint-plugin-react": "^7",
111
- "eslint-plugin-react-hooks": "^5",
112
- "prettier": "^3",
113
- "ts-node": "^10",
114
89
  "tsup": "^8",
115
- "typescript": "^5",
116
- "typescript-eslint": "^8"
90
+ "typescript": "^5"
117
91
  },
118
- "dependencies": {
119
- "@types/node": "^20"
92
+ "scripts": {
93
+ "build": "tsup",
94
+ "dev": "tsup --watch",
95
+ "clean": "rm -rf dist"
120
96
  }
121
97
  }
package/CHANGELOG.md DELETED
@@ -1,75 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to `tailwind-styled-v4` will be documented here.
4
-
5
- ## [1.0.0] — Initial Release
6
-
7
- ### Added
8
-
9
- #### Core Engine
10
- - `tw` proxy — template literal & object config syntax
11
- - `tw.tag\`classes\`` — template literal API
12
- - `tw.tag({ base, variants, compoundVariants, defaultVariants })` — object config API
13
- - `tw(Component)\`classes\`` — wrap any existing component
14
- - `Component.extend\`extra-classes\`` — chain extra classes
15
- - `Component.withVariants(config)` — merge new variants
16
-
17
- #### Runtime Engines
18
- - **propEngine** — 80+ props (padding, margin, sizing, colors, flex, grid, layout, effects, animation, interaction)
19
- - **responsiveEngine** — `{ base, sm, md, lg, xl, 2xl }` responsive objects
20
- - **variantEngine** — CVA-style variants with `defaultVariants` support
21
- - **compoundVariant** — multi-condition compound variants
22
- - **classResolver** — central resolver combining all engines via `tailwind-merge`
23
-
24
- #### Standalone APIs
25
- - `cv()` — standalone class variants function (shadcn/ui & Radix compatible)
26
- - `withTw(Component, base?)` — HOC untuk wrap third-party components
27
- - `cls\`...\`` — tagged template for static class strings
28
- - `cx(...inputs)` — lightweight class joiner (~100b, zero-dep)
29
- - `cxm(...inputs)` — cx + tailwind-merge deduplication
30
-
31
- #### Plugin System
32
- - `registerPlugin({ name, props })` — custom prop resolver plugins
33
- - `loadBuiltinPlugins()` — 6 built-in plugins: animation, grid, backdrop, gradient, scroll, print
34
- - `listPlugins()` / `getPlugin(name)` — plugin introspection
35
-
36
- #### Theme System
37
- - `setTheme(tokens)` — deep-merge semantic tokens
38
- - `replaceTheme(tokens)` — replace entire theme
39
- - `getTheme()` / `getThemeNamespace(key)` — read current theme
40
- - `onThemeChange(listener)` — subscription API
41
- - `loadDefaultTheme()` — semantic token preset (primary, surface, muted, etc.)
42
- - `loadDarkTheme()` — fintech/crypto/Web3 dark preset
43
-
44
- #### Zero-Runtime Compiler
45
- - `withTailwindStyled(opts)(nextConfig)` — Next.js HOC wrapper
46
- - `tailwindStyledPlugin(opts)` — Vite plugin
47
- - Webpack loader (`tailwind-styled-v4/webpack-loader`)
48
- - Static transform: `tw.div\`p-4\`` → `styled.div.attrs(()=>({className:"p-4"}))\`\``
49
- - Dynamic guard: skips interpolated templates (`${}`) safely
50
- - `data-tw="tw-xxxxx"` attribute injection for DevTools (dev mode)
51
-
52
- #### Build Tools
53
- - `generateTailwindTypes.ts` — generates **58.055** Tailwind class type unions
54
- - `generateSafelist.ts` — scans src/ and outputs `tailwind.safelist.json`
55
- - `extractAllClasses(source)` — extract classes from any source string
56
-
57
- #### IntelliSense
58
- - **58.055 class definitions** in `tailwind.generated.ts`
59
- - Coverage: all colors (21 palettes × 11 shades), spacing, sizing, flexbox, grid, effects, transitions, animations, responsive prefixes (sm/md/lg/xl/2xl), state prefixes (hover/focus/active/disabled/dark/group-hover/peer-hover/focus-visible/focus-within)
60
-
61
- #### Developer Experience
62
- - `shouldForwardProp` — tw props tidak bocor ke DOM attributes
63
- - `blockProp(name)` / `allowProp(name)` — fine-grained forwarding control
64
- - `hashClass(input)` → `"tw-xxxxx"` — stable component hash
65
- - `componentName(tag, classes)` — display name generator for React DevTools
66
- - Source maps enabled in all builds
67
-
68
- #### Stack Compatibility
69
- - Next.js 15/16 (App Router + Pages Router)
70
- - React 18/19
71
- - Tailwind CSS v3/v4
72
- - styled-components v5/v6
73
- - TypeScript 4.9/5.x
74
- - shadcn/ui, Radix UI, Headless UI
75
- - Vite 4/5, Webpack 4/5
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 tailwind-styled-v4
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 DELETED
@@ -1,330 +0,0 @@
1
- # tailwind-styled-v4
2
-
3
- **PRO Engine** — styled-components + Tailwind CSS v4, zero-runtime compile option, variant system, responsive props, plugin ecosystem.
4
-
5
- > Melampaui `twin.macro` dengan tetap kompatibel penuh terhadap Next.js 16 · React 19 · Tailwind CSS v4 · styled-components v6 · TypeScript 5 · shadcn/ui.
6
-
7
- ---
8
-
9
- ## Installation
10
-
11
- ```bash
12
- npm install tailwind-styled-v4
13
- # peerDependencies
14
- npm install styled-components tailwind-merge clsx
15
- ```
16
-
17
- ---
18
-
19
- ## Quick Start
20
-
21
- ### Template Literal (sederhana)
22
-
23
- ```tsx
24
- import { tw } from "tailwind-styled-v4"
25
-
26
- const Card = tw.div`
27
- p-6
28
- bg-zinc-900
29
- rounded-2xl
30
- border border-zinc-800
31
- `
32
-
33
- // Responsive props inline
34
- <Card p={{ base: 4, md: 6, lg: 8 }} />
35
- // → p-4 md:p-6 lg:p-8
36
- ```
37
-
38
- ### Object Config (full power)
39
-
40
- ```tsx
41
- const Button = tw.button({
42
- base: "inline-flex items-center justify-center rounded-lg font-medium transition",
43
- variants: {
44
- variant: {
45
- primary: "bg-blue-600 text-white hover:bg-blue-700",
46
- ghost: "bg-transparent border border-zinc-700 hover:bg-zinc-800",
47
- danger: "bg-red-600 text-white hover:bg-red-700",
48
- },
49
- size: {
50
- sm: "h-8 px-3 text-sm",
51
- md: "h-10 px-4 text-sm",
52
- lg: "h-12 px-6 text-base",
53
- },
54
- },
55
- compoundVariants: [
56
- { variant: "primary", size: "lg", class: "shadow-lg shadow-blue-600/30" },
57
- ],
58
- defaultVariants: { variant: "primary", size: "md" },
59
- })
60
-
61
- // Usage
62
- <Button variant="primary" size="lg">Click me</Button>
63
- <Button variant="ghost" size="sm">Cancel</Button>
64
- ```
65
-
66
- ### Extend existing component
67
-
68
- ```tsx
69
- const HeroCard = Card.extend`shadow-2xl ring-1 ring-zinc-700/50`
70
- ```
71
-
72
- ### Wrap any component (shadcn/ui, Radix, dll)
73
-
74
- ```tsx
75
- import { withTw, tw } from "tailwind-styled-v4"
76
- import { Button } from "@/components/ui/button" // shadcn
77
- import Link from "next/link"
78
-
79
- const TwButton = withTw(Button, "px-4 py-2")
80
- const NavLink = tw(Link)`text-zinc-400 hover:text-zinc-100 transition-colors`
81
- ```
82
-
83
- ### Standalone class variants (headless/shadcn compatible)
84
-
85
- ```tsx
86
- import { cv } from "tailwind-styled-v4"
87
-
88
- const badgeCv = cv({
89
- base: "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",
90
- variants: {
91
- color: {
92
- blue: "bg-blue-100 text-blue-800",
93
- green: "bg-green-100 text-green-800",
94
- red: "bg-red-100 text-red-800",
95
- }
96
- },
97
- defaultVariants: { color: "blue" }
98
- })
99
-
100
- // Use anywhere
101
- <span className={badgeCv({ color: "green" })}>Active</span>
102
- ```
103
-
104
- ---
105
-
106
- ## Responsive Props
107
-
108
- Semua props mendukung responsive object:
109
-
110
- ```tsx
111
- <Box
112
- p={{ base: 2, sm: 4, md: 6, lg: 8 }}
113
- cols={{ base: 1, sm: 2, lg: 3 }}
114
- gap={{ base: 3, md: 4 }}
115
- display="grid"
116
- />
117
- // → p-2 sm:p-4 md:p-6 lg:p-8 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 md:gap-4
118
- ```
119
-
120
- ### Available Props
121
-
122
- | Category | Props |
123
- |----------|-------|
124
- | **Padding** | `p` `px` `py` `pt` `pb` `pl` `pr` |
125
- | **Margin** | `m` `mx` `my` `mt` `mb` `ml` `mr` |
126
- | **Gap** | `gap` `gapX` `gapY` `spaceX` `spaceY` |
127
- | **Sizing** | `w` `h` `size` `minW` `maxW` `minH` `maxH` |
128
- | **Colors** | `bg` `text` `border` `ring` `fill` `stroke` |
129
- | **Typography** | `font` `fontSize` `leading` `tracking` `align` `truncate` `lineClamp` |
130
- | **Flexbox** | `flex` `flexDir` `items` `justify` `wrap` `grow` `shrink` `basis` `self` |
131
- | **Grid** | `cols` `rows` `colSpan` `rowSpan` `colStart` `colEnd` |
132
- | **Layout** | `display` `overflow` `pos` `z` `top` `right` `bottom` `left` `inset` |
133
- | **Border** | `rounded` `roundedT` `roundedB` `borderStyle` `outline` |
134
- | **Effects** | `opacity` `shadow` `blur` `brightness` `contrast` `grayscale` `backdrop` |
135
- | **Motion** | `transition` `duration` `ease` `delay` `animate` |
136
- | **Interaction** | `cursor` `select` `pointer` `touch` |
137
-
138
- ---
139
-
140
- ## Zero-Runtime (Next.js)
141
-
142
- Di production build, semua `tw.tag\`...\`` dikompilasi menjadi static string — zero JS runtime overhead.
143
-
144
- ```ts
145
- // next.config.ts
146
- import { withTailwindStyled } from "tailwind-styled-v4/compiler"
147
-
148
- export default withTailwindStyled({
149
- mode: "zero-runtime", // "runtime" di dev, "zero-runtime" di production
150
- addDataAttr: true, // data-tw="tw-3f2a1" untuk DevTools
151
- generateSafelist: true, // auto-generate tailwind.safelist.json
152
- })(/** nextConfig */ {})
153
- ```
154
-
155
- **Before (source):**
156
- ```tsx
157
- const Box = tw.div`p-4 bg-zinc-900 rounded-xl`
158
- ```
159
-
160
- **After (compiled output):**
161
- ```tsx
162
- const Box = styled.div.attrs(() => ({ className: "p-4 bg-zinc-900 rounded-xl" }))``
163
- ```
164
-
165
- Runtime cost: **0 bytes** untuk class resolution.
166
-
167
- ---
168
-
169
- ## Zero-Runtime (Vite)
170
-
171
- ```ts
172
- // vite.config.ts
173
- import { tailwindStyledPlugin } from "tailwind-styled-v4/compiler"
174
-
175
- export default defineConfig({
176
- plugins: [react(), tailwindStyledPlugin({ mode: "zero-runtime" })],
177
- })
178
- ```
179
-
180
- ---
181
-
182
- ## Plugin System
183
-
184
- ```tsx
185
- import { registerPlugin } from "tailwind-styled-v4"
186
-
187
- // Custom plugin
188
- registerPlugin({
189
- name: "glass",
190
- props: {
191
- glass: v => v === true ? "bg-white/10 backdrop-blur-xl border border-white/10" : "",
192
- frosted: v => v === true ? "bg-white/5 backdrop-blur-md saturate-150" : "",
193
- }
194
- })
195
-
196
- // Usage
197
- <Box glass /> // → bg-white/10 backdrop-blur-xl border border-white/10
198
- <Box frosted /> // → bg-white/5 backdrop-blur-md saturate-150
199
- ```
200
-
201
- ### Built-in Plugins
202
-
203
- ```tsx
204
- import { loadBuiltinPlugins } from "tailwind-styled-v4"
205
- loadBuiltinPlugins() // animation, grid, backdrop, gradient, scroll, print
206
- ```
207
-
208
- ---
209
-
210
- ## Theme System
211
-
212
- ```tsx
213
- import { setTheme, loadDefaultTheme, loadDarkTheme } from "tailwind-styled-v4"
214
-
215
- // Preset themes
216
- loadDefaultTheme() // semantic tokens: primary, surface, muted, dll
217
- loadDarkTheme() // fintech/crypto/Web3 dark preset
218
-
219
- // Custom tokens
220
- setTheme({
221
- colors: {
222
- brand: "blue-600",
223
- "brand-hover": "blue-700",
224
- surface: "zinc-900",
225
- },
226
- radius: {
227
- card: "2xl",
228
- button: "lg",
229
- },
230
- })
231
-
232
- // Now works everywhere
233
- <Box bg="brand" rounded="card" />
234
- // → bg-blue-600 rounded-2xl
235
- ```
236
-
237
- ---
238
-
239
- ## Safelist Generation
240
-
241
- ```bash
242
- npm run build:safelist
243
- ```
244
-
245
- Menghasilkan `tailwind.safelist.json` yang bisa direferensikan di `tailwind.config.ts`:
246
-
247
- ```ts
248
- // tailwind.config.ts
249
- import safelist from "./tailwind.safelist.json"
250
-
251
- export default {
252
- safelist: safelist.safelist,
253
- // ...
254
- }
255
- ```
256
-
257
- ---
258
-
259
- ## IntelliSense (VSCode)
260
-
261
- Library ini menyertakan **58.055 class definitions** di `src/types/tailwind.generated.ts` untuk autocomplete penuh di VSCode termasuk semua modifier:
262
-
263
- ```
264
- bg-blue-500 ← base class
265
- hover:bg-blue-500 ← hover state
266
- md:bg-blue-500 ← responsive
267
- dark:bg-blue-500 ← dark mode
268
- dark:hover:bg-blue-500 ← combined
269
- ```
270
-
271
- Tambahkan ke `.vscode/settings.json`:
272
- ```json
273
- {
274
- "tailwindCSS.experimental.classRegex": [
275
- ["tw\\.\\w+`([^`]*)`", "([^`]*)"],
276
- ["tw\\.\\w+\\(([^)]*)\\)", "\"([^\"]*)\""],
277
- ["cv\\(([^)]*)\\)", "\"([^\"]*)\""]
278
- ]
279
- }
280
- ```
281
-
282
- ---
283
-
284
- ## Scripts
285
-
286
- ```bash
287
- npm run build # build library
288
- npm run build:types # regenerate 58k class types
289
- npm run build:safelist # scan src/ dan generate safelist
290
- npm run dev # watch mode
291
- npm run test # run all tests
292
- ```
293
-
294
- ---
295
-
296
- ## Comparison
297
-
298
- | Feature | tailwind-styled-v4 | twin.macro | CVA | Stitches |
299
- |---------|--------------------|------------|-----|----------|
300
- | Template literal | ✅ | ✅ | ❌ | ❌ |
301
- | Object config + variants | ✅ | ❌ | ✅ | ✅ |
302
- | Compound variants | ✅ | ❌ | ✅ | ✅ |
303
- | Responsive props | ✅ | ❌ | ❌ | ❌ |
304
- | Zero-runtime | ✅ | ✅ | ❌ | ✅ |
305
- | Plugin system | ✅ | ❌ | ❌ | ❌ |
306
- | styled-components compat | ✅ | ✅ | ❌ | ❌ |
307
- | shadcn/ui compat | ✅ | ❌ | ✅ | ❌ |
308
- | Theme/token system | ✅ | ❌ | ❌ | ✅ |
309
- | IntelliSense 58k classes | ✅ | ✅ | ❌ | ❌ |
310
- | Wrap any component | ✅ | ❌ | ❌ | ❌ |
311
-
312
- ---
313
-
314
- ## Stack Compatibility
315
-
316
- - **Next.js** 15 / 16 (App Router + Pages Router)
317
- - **React** 18 / 19 (Server Components compatible)
318
- - **Tailwind CSS** v3 / v4
319
- - **styled-components** v5 / v6
320
- - **TypeScript** 4.9 / 5.x
321
- - **shadcn/ui** (semua komponen)
322
- - **Radix UI** (via `withTw()`)
323
- - **Vite** 4 / 5
324
- - **Webpack** 4 / 5
325
-
326
- ---
327
-
328
- ## License
329
-
330
- MIT