@kbach/react 0.1.1 → 0.1.3

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 (2) hide show
  1. package/README.md +63 -46
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @kbach/react
2
2
 
3
- Tailwind-like utility classes for **React (web)**. Same class names as Tailwind, zero stylesheet required — classes are converted to inline styles at render time via a custom JSX runtime.
3
+ Tailwind-like utility classes for **React (web)**. Classes are converted to inline styles at render time through a custom JSX runtime — no stylesheet required.
4
4
 
5
- ```tsx
5
+ ```
6
6
  /** @jsxImportSource @kbach/react */
7
7
 
8
8
  <div className="bg-white dark:bg-gray-10 p-4 rounded-xl shadow" />
@@ -20,7 +20,7 @@ npm install @kbach/react
20
20
 
21
21
  ### 1. Configure the JSX runtime
22
22
 
23
- **tsconfig.json** (applies to every file in the project)
23
+ **tsconfig.json**
24
24
 
25
25
  ```jsonc
26
26
  {
@@ -33,7 +33,7 @@ npm install @kbach/react
33
33
 
34
34
  **Vite**
35
35
 
36
- ```ts
36
+ ```js
37
37
  // vite.config.ts
38
38
  import { defineConfig } from 'vite';
39
39
  import react from '@vitejs/plugin-react';
@@ -56,13 +56,13 @@ module.exports = {
56
56
 
57
57
  **Per-file pragma** (no config change required)
58
58
 
59
- ```tsx
59
+ ```
60
60
  /** @jsxImportSource @kbach/react */
61
61
  ```
62
62
 
63
63
  ### 2. Wrap your app
64
64
 
65
- ```tsx
65
+ ```
66
66
  import { ThemeProvider } from '@kbach/react';
67
67
 
68
68
  export default function Root() {
@@ -76,21 +76,21 @@ export default function Root() {
76
76
 
77
77
  ## API
78
78
 
79
- ### `className` prop
79
+ ### className prop
80
80
 
81
81
  Works on any HTML element or React component once the JSX runtime is configured.
82
82
 
83
- ```tsx
83
+ ```
84
84
  <div className="bg-white dark:bg-gray-10 p-4 rounded-xl" />
85
85
  <p className="text-gray-10 dark:text-white text-lg font-bold" />
86
86
  <button className="bg-blue-7 hover:bg-blue-8 pressed:bg-blue-8 rounded-lg px-4 py-2" />
87
87
  ```
88
88
 
89
- ### `styled(Component, classes)`
89
+ ### styled(Component, classes)
90
90
 
91
91
  Pre-style any component. Returns a new component that merges the base classes with any `className` or `tw` prop passed at use time.
92
92
 
93
- ```tsx
93
+ ```
94
94
  import { styled } from '@kbach/react';
95
95
 
96
96
  const Card = styled('div', 'bg-white dark:bg-gray-9 rounded-2xl p-6 shadow');
@@ -106,11 +106,11 @@ const Button = styled(
106
106
  </Card>
107
107
  ```
108
108
 
109
- ### `useStyles(classes)`
109
+ ### useStyles(classes)
110
110
 
111
111
  Resolve classes to a style object inside a component.
112
112
 
113
- ```tsx
113
+ ```
114
114
  import { useStyles } from '@kbach/react';
115
115
 
116
116
  function Badge() {
@@ -119,21 +119,21 @@ function Badge() {
119
119
  }
120
120
  ```
121
121
 
122
- ### `tw(classes)`
122
+ ### tw(classes)
123
123
 
124
124
  Resolve classes outside a component (static contexts).
125
125
 
126
- ```tsx
126
+ ```
127
127
  import { tw } from '@kbach/react';
128
128
 
129
129
  const cardStyle = tw('bg-white p-4 rounded-xl') as React.CSSProperties;
130
130
  ```
131
131
 
132
- ### `cx(...classes)`
132
+ ### cx(...classes)
133
133
 
134
134
  Conditionally join class strings. Falsy values are ignored.
135
135
 
136
- ```tsx
136
+ ```
137
137
  import { cx } from '@kbach/react';
138
138
 
139
139
  <div className={cx(
@@ -143,9 +143,9 @@ import { cx } from '@kbach/react';
143
143
  )} />
144
144
  ```
145
145
 
146
- ### `useTheme()`
146
+ ### useTheme()
147
147
 
148
- ```tsx
148
+ ```
149
149
  import { useTheme } from '@kbach/react';
150
150
 
151
151
  const { mode, resolvedMode, isDark, setMode, toggle } = useTheme();
@@ -153,45 +153,45 @@ const { mode, resolvedMode, isDark, setMode, toggle } = useTheme();
153
153
 
154
154
  | Value | Type | Description |
155
155
  |---|---|---|
156
- | `mode` | `'light' \| 'dark' \| 'system'` | User-selected mode |
157
- | `resolvedMode` | `'light' \| 'dark'` | Resolved after system lookup |
158
- | `isDark` | `boolean` | Shorthand for `resolvedMode === 'dark'` |
159
- | `setMode(mode)` | `fn` | Set mode explicitly |
160
- | `toggle()` | `fn` | Toggle between light and dark |
156
+ | mode | `'light' \| 'dark' \| 'system'` | User-selected mode |
157
+ | resolvedMode | `'light' \| 'dark'` | Resolved after system lookup |
158
+ | isDark | boolean | Shorthand for `resolvedMode === 'dark'` |
159
+ | setMode | function | Set mode explicitly |
160
+ | toggle | function | Toggle between light and dark |
161
161
 
162
- ### `ThemeToggle`
162
+ ### ThemeToggle
163
163
 
164
164
  Drop-in toggle component.
165
165
 
166
- ```tsx
167
- <ThemeToggle /> // button (default)
168
- <ThemeToggle variant="switch" /> // toggle switch
169
- <ThemeToggle variant="icon-button" /> // icon button
166
+ ```
167
+ <ThemeToggle /> // button (default)
168
+ <ThemeToggle variant="switch" /> // toggle switch
169
+ <ThemeToggle variant="icon-button" /> // icon button
170
170
  <ThemeToggle variant="button" includeSystem /> // three-way selector
171
171
  ```
172
172
 
173
173
  ## Modifiers
174
174
 
175
- Up to **3 modifiers** can be chained in any order.
175
+ Up to 3 modifiers can be chained in any order.
176
176
 
177
177
  | Modifier | Trigger |
178
178
  |---|---|
179
- | `dark:` | Dark mode active |
180
- | `light:` | Light mode active |
181
- | `hover:` | Mouse hover |
182
- | `pressed:` | Click / touch |
183
- | `focus:` | Element focused |
184
- | `active:` | Element active |
185
- | `disabled:` | Element disabled |
186
-
187
- ```tsx
179
+ | dark: | Dark mode active |
180
+ | light: | Light mode active |
181
+ | hover: | Mouse hover |
182
+ | pressed: | Click or touch |
183
+ | focus: | Element focused |
184
+ | active: | Element active |
185
+ | disabled: | Element disabled |
186
+
187
+ ```
188
188
  <div className="dark:hover:bg-gray-9" />
189
189
  <button className="dark:pressed:bg-indigo-8" />
190
190
  ```
191
191
 
192
192
  ## Arbitrary values
193
193
 
194
- ```tsx
194
+ ```
195
195
  <div className="bg-[#6366f1]" />
196
196
  <div className="p-[14px]" />
197
197
  <div className="text-[18px]" />
@@ -200,20 +200,35 @@ Up to **3 modifiers** can be chained in any order.
200
200
 
201
201
  ## Color with opacity
202
202
 
203
- ```tsx
204
- <div className="bg-blue-6/50" /> {/* 50% opacity */}
205
- <div className="bg-gray-10/75" /> {/* 75% opacity */}
203
+ ```
204
+ <div className="bg-blue-6/50" /> // 50% opacity
205
+ <div className="bg-gray-10/75" /> // 75% opacity
206
206
  ```
207
207
 
208
208
  ## Color scale
209
209
 
210
- Colors use an 11-shade scale where **1 is lightest** and **11 is darkest**.
210
+ Colors use an 11-shade scale 1 is lightest, 11 is darkest.
211
211
 
212
212
  ```
213
- bg-gray-1 (near white) bg-gray-6 (mid) bg-gray-11 (near black)
213
+ shade 1 · 2 · 3 · 4 · 5 · 6 · 7 · 8 · 9 · 10 · 11
214
+ light ─────────────────────────────────────────────────────────── dark
214
215
  ```
215
216
 
216
- Available families: `slate` `gray` `zinc` `neutral` `stone` `red` `orange` `amber` `yellow` `lime` `green` `emerald` `teal` `cyan` `sky` `blue` `indigo` `violet` `purple` `fuchsia` `pink` `rose`
217
+ Available families: slate, gray, zinc, neutral, stone, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose.
218
+
219
+ ## Common utilities
220
+
221
+ | Category | Examples |
222
+ |---|---|
223
+ | Background | `bg-white`, `bg-gray-10`, `bg-blue-6`, `bg-[#fff]` |
224
+ | Text | `text-sm`, `text-2xl`, `text-gray-10`, `font-bold` |
225
+ | Padding | `p-4`, `px-6`, `py-3` |
226
+ | Margin | `m-4`, `mx-auto`, `mt-2`, `-mt-4` |
227
+ | Size | `w-full`, `h-12`, `w-[200px]` |
228
+ | Flex | `flex-1`, `flex-row`, `items-center`, `justify-between`, `gap-4` |
229
+ | Border | `border`, `border-2`, `border-gray-4`, `rounded-xl` |
230
+ | Shadow | `shadow`, `shadow-md`, `shadow-lg` |
231
+ | Opacity | `opacity-50`, `opacity-75` |
217
232
 
218
233
  ## Configuration
219
234
 
@@ -246,7 +261,9 @@ module.exports = {
246
261
  };
247
262
  ```
248
263
 
249
- ```tsx
264
+ Apply at runtime:
265
+
266
+ ```
250
267
  import { updateConfig } from '@kbach/react';
251
268
 
252
269
  updateConfig({ extend: { theme: { colors: { brand: { 6: '#6366f1' } } } } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "React / React Native components and hooks for the Kbach framework",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",