@ranimontagna/agent-toolkit 0.1.5 → 0.1.6
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 +42 -8
- package/package.json +1 -1
- package/skills/frontend/react/react-patterns/LICENSE +21 -0
- package/skills/frontend/react/react-patterns/NOTICE.md +11 -0
- package/skills/frontend/react/react-patterns/SKILL.md +341 -0
- package/skills/frontend/react/react-performance/LICENSE +21 -0
- package/skills/frontend/react/react-performance/NOTICE.md +11 -0
- package/skills/frontend/react/react-performance/SKILL.md +574 -0
- package/skills/frontend/react/react-testing/LICENSE +21 -0
- package/skills/frontend/react/react-testing/NOTICE.md +11 -0
- package/skills/frontend/react/react-testing/SKILL.md +423 -0
- package/skills/frontend/react-native/react-native-expert/LICENSE +21 -0
- package/skills/frontend/react-native/react-native-expert/NOTICE.md +11 -0
- package/skills/frontend/react-native/react-native-expert/SKILL.md +187 -0
- package/skills/frontend/react-native/react-native-expert/references/expo-router.md +187 -0
- package/skills/frontend/react-native/react-native-expert/references/list-optimization.md +204 -0
- package/skills/frontend/react-native/react-native-expert/references/platform-handling.md +188 -0
- package/skills/frontend/react-native/react-native-expert/references/project-structure.md +171 -0
- package/skills/frontend/react-native/react-native-expert/references/storage-hooks.md +173 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/LICENSE +21 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/NOTICE.md +11 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/SKILL.md +159 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/api-reference.md +495 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/common-issues.md +389 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/setup-guide.md +217 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/styling-patterns.md +705 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/third-party-integration.md +318 -0
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Complete API for every export from `react-native-unistyles`.
|
|
4
|
+
|
|
5
|
+
## StyleSheet
|
|
6
|
+
|
|
7
|
+
The main API. Import from `react-native-unistyles`. It is a **full polyfill** of React Native's `StyleSheet` — replace all `import { StyleSheet } from 'react-native'` imports.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { StyleSheet } from 'react-native-unistyles'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### StyleSheet.create(styles)
|
|
14
|
+
|
|
15
|
+
Creates a reactive stylesheet. Returns an object with the same keys as your stylesheet, plus a `useVariants()` method. Each style value is a C++ proxy object.
|
|
16
|
+
|
|
17
|
+
**Overload 1 — Static object:**
|
|
18
|
+
```tsx
|
|
19
|
+
const styles = StyleSheet.create({
|
|
20
|
+
container: { flex: 1, padding: 16 }
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Overload 2 — Theme function (zero re-renders on theme change):**
|
|
25
|
+
```tsx
|
|
26
|
+
const styles = StyleSheet.create(theme => ({
|
|
27
|
+
container: { backgroundColor: theme.colors.background }
|
|
28
|
+
}))
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Overload 3 — Theme + miniRuntime function (zero re-renders on theme/device change):**
|
|
32
|
+
```tsx
|
|
33
|
+
const styles = StyleSheet.create((theme, rt) => ({
|
|
34
|
+
container: {
|
|
35
|
+
backgroundColor: theme.colors.background,
|
|
36
|
+
paddingTop: rt.insets.top,
|
|
37
|
+
width: rt.screen.width > 768 ? 500 : rt.screen.width - 32
|
|
38
|
+
}
|
|
39
|
+
}))
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Dynamic functions — pass arguments at the call site:**
|
|
43
|
+
```tsx
|
|
44
|
+
const styles = StyleSheet.create(theme => ({
|
|
45
|
+
box: (width: number, isActive: boolean) => ({
|
|
46
|
+
width,
|
|
47
|
+
backgroundColor: isActive ? theme.colors.active : theme.colors.inactive,
|
|
48
|
+
})
|
|
49
|
+
}))
|
|
50
|
+
|
|
51
|
+
// Usage:
|
|
52
|
+
<View style={styles.box(200, true)} />
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### StyleSheet.configure(config)
|
|
56
|
+
|
|
57
|
+
One-time initialization. Must be called before any `StyleSheet.create()`.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
StyleSheet.configure({
|
|
61
|
+
themes?: { [name: string]: ThemeObject },
|
|
62
|
+
breakpoints?: { [name: string]: number }, // first must be 0
|
|
63
|
+
settings?: {
|
|
64
|
+
initialTheme?: string | (() => string),
|
|
65
|
+
adaptiveThemes?: boolean,
|
|
66
|
+
CSSVars?: boolean,
|
|
67
|
+
nativeBreakpointsMode?: 'pixels' | 'points',
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### StyleSheet utilities
|
|
73
|
+
|
|
74
|
+
| Property/Method | Description |
|
|
75
|
+
|----------------|-------------|
|
|
76
|
+
| `StyleSheet.hairlineWidth` | Thinnest visible line width (always `1` in v3) |
|
|
77
|
+
| `StyleSheet.absoluteFill` | Shorthand for `{ position: 'absolute', left: 0, right: 0, top: 0, bottom: 0 }` |
|
|
78
|
+
| `StyleSheet.absoluteFillObject` | Same object as `absoluteFill` |
|
|
79
|
+
| `StyleSheet.compose(a, b)` | Compose two styles |
|
|
80
|
+
| `StyleSheet.flatten(style)` | Flatten a style array into a single object |
|
|
81
|
+
|
|
82
|
+
### StyleSheet.addChangeListener(listener)
|
|
83
|
+
|
|
84
|
+
Subscribe to Unistyles dependency changes:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
const unsubscribe = StyleSheet.addChangeListener((dependencies: UnistyleDependency[]) => {
|
|
88
|
+
// dependencies is an array of what changed (Theme, Breakpoints, Orientation, etc.)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// Later:
|
|
92
|
+
unsubscribe()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## UnistylesRuntime
|
|
98
|
+
|
|
99
|
+
Singleton providing read-only access to device/app state and methods to change themes.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { UnistylesRuntime } from 'react-native-unistyles'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Read-only properties
|
|
106
|
+
|
|
107
|
+
| Property | Type | Description |
|
|
108
|
+
|----------|------|-------------|
|
|
109
|
+
| `colorScheme` | `'light' \| 'dark' \| 'unspecified'` | OS color scheme |
|
|
110
|
+
| `themeName` | `string \| undefined` | Current active theme name |
|
|
111
|
+
| `breakpoint` | `string \| undefined` | Current active breakpoint name |
|
|
112
|
+
| `hasAdaptiveThemes` | `boolean` | Whether adaptive themes are enabled |
|
|
113
|
+
| `screen` | `{ width: number, height: number }` | Screen dimensions |
|
|
114
|
+
| `insets` | `{ top, bottom, left, right, ime: number }` | Safe area insets + keyboard (ime) |
|
|
115
|
+
| `orientation` | `'portrait' \| 'landscape'` | Current orientation |
|
|
116
|
+
| `isPortrait` | `boolean` | Shorthand for portrait check |
|
|
117
|
+
| `isLandscape` | `boolean` | Shorthand for landscape check |
|
|
118
|
+
| `pixelRatio` | `number` | Device pixel ratio |
|
|
119
|
+
| `fontScale` | `number` | User font scale preference |
|
|
120
|
+
| `rtl` | `boolean` | Whether layout direction is RTL |
|
|
121
|
+
| `contentSizeCategory` | `IOSContentSizeCategory \| AndroidContentSizeCategory` | Accessibility text size |
|
|
122
|
+
| `breakpoints` | `UnistylesBreakpoints` | Registered breakpoints object |
|
|
123
|
+
|
|
124
|
+
### Sub-objects
|
|
125
|
+
|
|
126
|
+
| Property | Type | Description |
|
|
127
|
+
|----------|------|-------------|
|
|
128
|
+
| `statusBar` | `UnistylesStatusBar` | Status bar dimensions and controls |
|
|
129
|
+
| `navigationBar` | `UnistylesNavigationBar` | Navigation bar dimensions and controls (Android) |
|
|
130
|
+
|
|
131
|
+
### Methods
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
// Switch theme
|
|
135
|
+
UnistylesRuntime.setTheme('dark')
|
|
136
|
+
|
|
137
|
+
// Get theme object by name
|
|
138
|
+
const darkTheme = UnistylesRuntime.getTheme('dark')
|
|
139
|
+
|
|
140
|
+
// Update theme values at runtime (triggers re-style of affected components)
|
|
141
|
+
UnistylesRuntime.updateTheme('light', currentTheme => ({
|
|
142
|
+
...currentTheme,
|
|
143
|
+
colors: { ...currentTheme.colors, primary: '#ff0000' }
|
|
144
|
+
}))
|
|
145
|
+
|
|
146
|
+
// Enable/disable adaptive themes
|
|
147
|
+
UnistylesRuntime.setAdaptiveThemes(true)
|
|
148
|
+
|
|
149
|
+
// Set root view background color
|
|
150
|
+
UnistylesRuntime.setRootViewBackgroundColor('#ffffff')
|
|
151
|
+
|
|
152
|
+
// Enable immersive mode (hide status bar + navigation bar)
|
|
153
|
+
UnistylesRuntime.setImmersiveMode(true)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## StatusBar
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { StatusBar } from 'react-native-unistyles'
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| Property/Method | Type | Description |
|
|
165
|
+
|----------------|------|-------------|
|
|
166
|
+
| `width` | `number` | Status bar width |
|
|
167
|
+
| `height` | `number` | Status bar height |
|
|
168
|
+
| `setHidden(hidden, animation?)` | `(boolean, 'none' \| 'fade' \| 'slide') => void` | Show/hide status bar |
|
|
169
|
+
| `setStyle(style, animated?)` | `('default' \| 'light' \| 'dark', boolean?) => void` | Set status bar style |
|
|
170
|
+
|
|
171
|
+
Also accessible via `UnistylesRuntime.statusBar`.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## NavigationBar
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import { NavigationBar } from 'react-native-unistyles'
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
| Property/Method | Type | Description |
|
|
182
|
+
|----------------|------|-------------|
|
|
183
|
+
| `width` | `number` | Navigation bar width |
|
|
184
|
+
| `height` | `number` | Navigation bar height |
|
|
185
|
+
| `setHidden(hidden)` | `(boolean) => void` | Show/hide navigation bar (Android) |
|
|
186
|
+
|
|
187
|
+
Also accessible via `UnistylesRuntime.navigationBar`.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## mq (Media Queries)
|
|
192
|
+
|
|
193
|
+
Build media query symbols for breakpoint-based and pixel-based responsive styles.
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
import { mq } from 'react-native-unistyles'
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### API
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
// Width only
|
|
203
|
+
mq.only.width(min?, max?) // returns symbol
|
|
204
|
+
|
|
205
|
+
// Height only
|
|
206
|
+
mq.only.height(min?, max?) // returns symbol
|
|
207
|
+
|
|
208
|
+
// Width AND height
|
|
209
|
+
mq.width(min?, max?).and.height(min?, max?) // returns symbol
|
|
210
|
+
|
|
211
|
+
// Height AND width
|
|
212
|
+
mq.height(min?, max?).and.width(min?, max?) // returns symbol
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Parameters can be:
|
|
216
|
+
- **Breakpoint names**: `'sm'`, `'md'`, `'lg'` (from registered breakpoints)
|
|
217
|
+
- **Pixel values**: `320`, `768`, `1200`
|
|
218
|
+
- **`null`/`undefined`**: unbounded (no min or no max)
|
|
219
|
+
|
|
220
|
+
### Examples
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
mq.only.width('sm', 'md') // width between sm and md breakpoints
|
|
224
|
+
mq.only.width(320, 768) // width between 320px and 768px
|
|
225
|
+
mq.only.width('sm') // width >= sm (no max)
|
|
226
|
+
mq.only.width(null, 600) // width <= 600px
|
|
227
|
+
mq.width('sm', 'lg').and.height(400, 800) // combined width + height
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Used in:
|
|
231
|
+
- Style values (breakpoint-like keys): `{ [mq.only.width(320, 768)]: 16 }`
|
|
232
|
+
- `<Display mq={...}>` and `<Hide mq={...}>` components
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## withUnistyles
|
|
237
|
+
|
|
238
|
+
HOC for wrapping components with theme/runtime-derived props.
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
import { withUnistyles } from 'react-native-unistyles'
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Basic usage — static prop mappings
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
const UniButton = withUnistyles(Button, (theme, rt) => ({
|
|
248
|
+
color: theme.colors.primary,
|
|
249
|
+
size: rt.screen.width > 400 ? 'large' : 'small'
|
|
250
|
+
}))
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### With uniProps — dynamic mappings from component props
|
|
254
|
+
|
|
255
|
+
The wrapped component receives additional `uniProps` that map to theme-derived values:
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
const UniIcon = withUnistyles(Icon, (theme) => ({
|
|
259
|
+
// These become available as props on UniIcon
|
|
260
|
+
}))
|
|
261
|
+
|
|
262
|
+
// The style and contentContainerStyle props are auto-processed
|
|
263
|
+
<UniIcon style={styles.icon} />
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Ref forwarding
|
|
267
|
+
|
|
268
|
+
`withUnistyles` forwards refs automatically:
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
const UniInput = withUnistyles(TextInput, (theme) => ({
|
|
272
|
+
placeholderTextColor: theme.colors.placeholder,
|
|
273
|
+
}))
|
|
274
|
+
|
|
275
|
+
const ref = useRef<TextInput>(null)
|
|
276
|
+
<UniInput ref={ref} />
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## useUnistyles
|
|
282
|
+
|
|
283
|
+
Hook that returns the current theme and mini runtime. **Causes re-renders** when theme or runtime values change.
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import { useUnistyles } from 'react-native-unistyles'
|
|
287
|
+
|
|
288
|
+
const MyComponent = () => {
|
|
289
|
+
const { theme, rt } = useUnistyles()
|
|
290
|
+
// theme: current theme object
|
|
291
|
+
// rt: UnistylesMiniRuntime (screen, insets, breakpoint, colorScheme, etc.)
|
|
292
|
+
|
|
293
|
+
return <Text style={{ color: theme.colors.text }}>{rt.breakpoint}</Text>
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**Prefer `StyleSheet.create(theme => ...)` over `useUnistyles()`** for performance. Use `useUnistyles` only when you need theme/runtime values in component logic (not just styles).
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Display / Hide
|
|
302
|
+
|
|
303
|
+
Conditional rendering components based on media queries.
|
|
304
|
+
|
|
305
|
+
```tsx
|
|
306
|
+
import { Display, Hide, mq } from 'react-native-unistyles'
|
|
307
|
+
|
|
308
|
+
// Show children only when width >= 768
|
|
309
|
+
<Display mq={mq.only.width(768)}>
|
|
310
|
+
<SidePanel />
|
|
311
|
+
</Display>
|
|
312
|
+
|
|
313
|
+
// Hide children when width < 768
|
|
314
|
+
<Hide mq={mq.only.width(null, 768)}>
|
|
315
|
+
<MobileNav />
|
|
316
|
+
</Hide>
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## ScopedTheme
|
|
322
|
+
|
|
323
|
+
Force a specific theme for a subtree, independent of the global theme.
|
|
324
|
+
|
|
325
|
+
```tsx
|
|
326
|
+
import { ScopedTheme } from 'react-native-unistyles'
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Props are **mutually exclusive** — use only one:
|
|
330
|
+
|
|
331
|
+
| Prop | Type | Description |
|
|
332
|
+
|------|------|-------------|
|
|
333
|
+
| `name` | `keyof UnistylesThemes` | Force a specific theme |
|
|
334
|
+
| `invertedAdaptive` | `boolean` | Use the opposite adaptive theme |
|
|
335
|
+
| `reset` | `boolean` | Reset to the global theme (undo parent ScopedTheme) |
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
// Force dark theme in this subtree
|
|
339
|
+
<ScopedTheme name="dark">
|
|
340
|
+
<Card />
|
|
341
|
+
</ScopedTheme>
|
|
342
|
+
|
|
343
|
+
// Invert: if global is light, this subtree gets dark (and vice versa)
|
|
344
|
+
<ScopedTheme invertedAdaptive>
|
|
345
|
+
<Footer />
|
|
346
|
+
</ScopedTheme>
|
|
347
|
+
|
|
348
|
+
// Reset to global theme (undo ancestor ScopedTheme)
|
|
349
|
+
<ScopedTheme reset>
|
|
350
|
+
<Header />
|
|
351
|
+
</ScopedTheme>
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Types
|
|
357
|
+
|
|
358
|
+
### UnistylesVariants\<T\>
|
|
359
|
+
|
|
360
|
+
Extract variant types from a stylesheet for use in component props:
|
|
361
|
+
|
|
362
|
+
```tsx
|
|
363
|
+
import type { UnistylesVariants } from 'react-native-unistyles'
|
|
364
|
+
|
|
365
|
+
const styles = StyleSheet.create(theme => ({
|
|
366
|
+
button: {
|
|
367
|
+
variants: {
|
|
368
|
+
size: { small: { padding: 4 }, large: { padding: 16 } },
|
|
369
|
+
color: { primary: { backgroundColor: 'blue' }, secondary: { backgroundColor: 'gray' } },
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}))
|
|
373
|
+
|
|
374
|
+
type ButtonVariants = UnistylesVariants<typeof styles>
|
|
375
|
+
// { size?: 'small' | 'large'; color?: 'primary' | 'secondary' }
|
|
376
|
+
|
|
377
|
+
type Props = { title: string } & ButtonVariants
|
|
378
|
+
|
|
379
|
+
const Button = ({ title, ...variants }: Props) => {
|
|
380
|
+
styles.useVariants(variants)
|
|
381
|
+
return <TouchableOpacity style={styles.button}><Text>{title}</Text></TouchableOpacity>
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### UnistylesValues
|
|
386
|
+
|
|
387
|
+
The type of individual style entries in a Unistyles stylesheet.
|
|
388
|
+
|
|
389
|
+
### IOSContentSizeCategory / AndroidContentSizeCategory
|
|
390
|
+
|
|
391
|
+
Enums for accessibility text size categories:
|
|
392
|
+
|
|
393
|
+
```tsx
|
|
394
|
+
import type { IOSContentSizeCategory, AndroidContentSizeCategory } from 'react-native-unistyles'
|
|
395
|
+
|
|
396
|
+
// iOS values: 'accessibilityExtraExtraExtraLarge', 'xxxLarge', 'xxLarge', 'xLarge',
|
|
397
|
+
// 'Large', 'Medium', 'Small', 'xSmall', 'unspecified'
|
|
398
|
+
// Android values: 'Small', 'Default', 'Large', 'ExtraLarge', 'Huge', 'ExtraHuge', 'ExtraExtraHuge'
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### UnistyleDependency
|
|
402
|
+
|
|
403
|
+
Enum for change listener dependencies:
|
|
404
|
+
|
|
405
|
+
```tsx
|
|
406
|
+
import { UnistyleDependency } from 'react-native-unistyles'
|
|
407
|
+
|
|
408
|
+
// Values: Theme, ThemeName, Breakpoints, ColorScheme, ContentSizeCategory,
|
|
409
|
+
// Orientation, Insets, Ime, PixelRatio, FontScale, Rtl,
|
|
410
|
+
// NavigationBar, StatusBar, Dimensions, AdaptiveThemes
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## Web-Only Exports
|
|
416
|
+
|
|
417
|
+
```tsx
|
|
418
|
+
import { getWebProps } from 'react-native-unistyles/web-only'
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### getWebProps(style)
|
|
422
|
+
|
|
423
|
+
For custom web components that don't support Unistyles' auto-processing:
|
|
424
|
+
|
|
425
|
+
```tsx
|
|
426
|
+
const { className, style: webStyle } = getWebProps(styles.container)
|
|
427
|
+
return <div className={className} style={webStyle}>...</div>
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## Reanimated Exports
|
|
433
|
+
|
|
434
|
+
```tsx
|
|
435
|
+
import { useAnimatedTheme, useAnimatedVariantColor } from 'react-native-unistyles/reanimated'
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### useAnimatedTheme()
|
|
439
|
+
|
|
440
|
+
Returns a `SharedValue<Theme>` for use inside Reanimated worklets:
|
|
441
|
+
|
|
442
|
+
```tsx
|
|
443
|
+
const animatedTheme = useAnimatedTheme()
|
|
444
|
+
|
|
445
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
446
|
+
backgroundColor: animatedTheme.value.colors.background,
|
|
447
|
+
}))
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### useAnimatedVariantColor(style, colorKey)
|
|
451
|
+
|
|
452
|
+
Animate color transitions when variants change:
|
|
453
|
+
|
|
454
|
+
```tsx
|
|
455
|
+
const animatedColor = useAnimatedVariantColor(styles.button, 'backgroundColor')
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## SSR Exports
|
|
461
|
+
|
|
462
|
+
For server-side rendering with Next.js:
|
|
463
|
+
|
|
464
|
+
```tsx
|
|
465
|
+
import {
|
|
466
|
+
useServerUnistyles,
|
|
467
|
+
getServerUnistyles,
|
|
468
|
+
hydrateServerUnistyles,
|
|
469
|
+
resetServerUnistyles
|
|
470
|
+
} from 'react-native-unistyles'
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
| Function | Description |
|
|
474
|
+
|----------|-------------|
|
|
475
|
+
| `useServerUnistyles(settings?)` | React hook returning style elements for SSR (App Router) |
|
|
476
|
+
| `getServerUnistyles(settings?)` | Returns React element with styles for SSR (Pages Router) |
|
|
477
|
+
| `hydrateServerUnistyles()` | Call on client to hydrate server-rendered styles |
|
|
478
|
+
| `resetServerUnistyles()` | Reset server styles between requests |
|
|
479
|
+
|
|
480
|
+
Settings: `{ includeRNWStyles?: boolean }`
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
## Native Components
|
|
485
|
+
|
|
486
|
+
Pre-styled components that work with Unistyles out of the box:
|
|
487
|
+
|
|
488
|
+
```tsx
|
|
489
|
+
import { View } from 'react-native-unistyles/components/native/View'
|
|
490
|
+
import { Text } from 'react-native-unistyles/components/native/Text'
|
|
491
|
+
import { Pressable } from 'react-native-unistyles/components/native/Pressable'
|
|
492
|
+
// etc.
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
These are automatically created by the Babel plugin — you typically don't import them directly. They exist for edge cases where the plugin can't detect a component.
|