@onlynative/components 0.0.0-alpha.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/README.md +105 -0
- package/dist/appbar/index.d.ts +90 -0
- package/dist/appbar/index.js +1030 -0
- package/dist/avatar/index.d.ts +46 -0
- package/dist/avatar/index.js +250 -0
- package/dist/button/index.d.ts +41 -0
- package/dist/button/index.js +468 -0
- package/dist/card/index.d.ts +31 -0
- package/dist/card/index.js +263 -0
- package/dist/checkbox/index.d.ts +25 -0
- package/dist/checkbox/index.js +308 -0
- package/dist/chip/index.d.ts +62 -0
- package/dist/chip/index.js +467 -0
- package/dist/icon-button/index.d.ts +10 -0
- package/dist/icon-button/index.js +592 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +3681 -0
- package/dist/keyboard-avoiding-wrapper/index.d.ts +36 -0
- package/dist/keyboard-avoiding-wrapper/index.js +98 -0
- package/dist/layout/index.d.ts +98 -0
- package/dist/layout/index.js +282 -0
- package/dist/list/index.d.ts +60 -0
- package/dist/list/index.js +302 -0
- package/dist/radio/index.d.ts +25 -0
- package/dist/radio/index.js +252 -0
- package/dist/switch/index.d.ts +37 -0
- package/dist/switch/index.js +332 -0
- package/dist/text-field/index.d.ts +52 -0
- package/dist/text-field/index.js +510 -0
- package/dist/types-D3hlyvz-.d.ts +51 -0
- package/dist/typography/index.d.ts +28 -0
- package/dist/typography/index.js +78 -0
- package/llms.txt +458 -0
- package/package.json +202 -0
package/llms.txt
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
# @onlynative/components — MD3 UI Components for React Native
|
|
2
|
+
|
|
3
|
+
> Version: 0.1.1-alpha.3
|
|
4
|
+
> Peer deps: @onlynative/core >=0.1.1-alpha.3, react >=18, react-native >=0.72, react-native-safe-area-context >=4
|
|
5
|
+
> Optional: @expo/vector-icons >=14 (only needed for icon props)
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Import via subpath (preferred): `import { X } from '@onlynative/components/x'`
|
|
10
|
+
Import via root: `import { X } from '@onlynative/components'`
|
|
11
|
+
|
|
12
|
+
### Component override pattern
|
|
13
|
+
|
|
14
|
+
All interactive components follow a 3-tier override system. Merge order: theme defaults → variant → semantic props → style props (last wins).
|
|
15
|
+
|
|
16
|
+
Standard override props on interactive components:
|
|
17
|
+
- `containerColor?: string` — Root container background. Hover/press state-layer colors auto-derived.
|
|
18
|
+
- `contentColor?: string` — Content (label + icons) color. State-layer colors auto-derived.
|
|
19
|
+
- `labelStyle?: StyleProp<TextStyle>` — Text-specific overrides (does not affect icons).
|
|
20
|
+
- `style` — Root container style.
|
|
21
|
+
|
|
22
|
+
Disabled state always uses standard MD3 disabled treatment (38% onSurface) regardless of overrides.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
### Typography
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { Typography } from '@onlynative/components/typography'
|
|
30
|
+
|
|
31
|
+
<Typography variant="headlineMedium" color="#333">Hello</Typography>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Props:
|
|
35
|
+
- `children: ReactNode` — Content to display. Accepts strings, numbers, or nested elements.
|
|
36
|
+
- `variant?: 'displayLarge' | 'displayMedium' | 'displaySmall' | 'headlineLarge' | 'headlineMedium' | 'headlineSmall' | 'titleLarge' | 'titleMedium' | 'titleSmall' | 'bodyLarge' | 'bodyMedium' | 'bodySmall' | 'labelLarge' | 'labelMedium' | 'labelSmall'` — Default: `'bodyMedium'`. MD3 type scale role. Controls font size, weight, line height, and letter spacing.
|
|
37
|
+
- `color?: string` — Override the text color. Takes priority over `style.color`. Defaults to the theme's `onSurface` color.
|
|
38
|
+
- `style?: StyleProp<TextStyle>` — Additional text styles. Can override the default theme color via `style.color` when no `color` prop is set.
|
|
39
|
+
- `as?: ComponentType<TextProps>` — Default: `Text`. Override the underlying text component (e.g. Animated.Text).
|
|
40
|
+
- Inherits `TextProps` (except `children`, `style`)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### Button
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { Button } from '@onlynative/components/button'
|
|
48
|
+
|
|
49
|
+
<Button variant="filled" leadingIcon="plus" onPress={handlePress}>Create</Button>
|
|
50
|
+
<Button variant="outlined">Cancel</Button>
|
|
51
|
+
<Button variant="tonal" containerColor="#E8DEF8" contentColor="#1D192B">Custom</Button>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Props:
|
|
55
|
+
- `children: string` — Text label rendered inside the button.
|
|
56
|
+
- `variant?: 'filled' | 'elevated' | 'outlined' | 'text' | 'tonal'` — Default: `'filled'`. Visual variant. Controls background, border, and text color.
|
|
57
|
+
- `leadingIcon?: string` — Name of a MaterialCommunityIcons icon to show before the label.
|
|
58
|
+
- `trailingIcon?: string` — Name of a MaterialCommunityIcons icon to show after the label.
|
|
59
|
+
- `iconSize?: number` — Default: `18`. Size of leading and trailing icons in dp.
|
|
60
|
+
- `containerColor?: string` — Override the container (background) color. State-layer colors (hover, press) are derived automatically.
|
|
61
|
+
- `contentColor?: string` — Override the content (label and icon) color. State-layer colors are derived automatically when no containerColor is set.
|
|
62
|
+
- `labelStyle?: StyleProp<TextStyle>` — Additional style applied to the label text.
|
|
63
|
+
- Inherits `PressableProps` (except `children`)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### IconButton
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { IconButton } from '@onlynative/components/icon-button'
|
|
71
|
+
|
|
72
|
+
<IconButton icon="heart" variant="filled" accessibilityLabel="Like" onPress={handleLike} />
|
|
73
|
+
<IconButton icon="heart-outline" selectedIcon="heart" selected={liked} variant="tonal" accessibilityLabel="Like" onPress={toggle} />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Props:
|
|
77
|
+
- `icon: string` — MaterialCommunityIcons icon name to display.
|
|
78
|
+
- `selectedIcon?: string` — Icon to display when `selected` is `true` (toggle mode).
|
|
79
|
+
- `iconColor?: string` — Overrides the automatic icon color derived from the variant and state.
|
|
80
|
+
- `contentColor?: string` — Override the content (icon) color. Takes precedence over `iconColor` when both are provided.
|
|
81
|
+
- `containerColor?: string` — Override the container (background) color. State-layer colors (hover, press) are derived automatically.
|
|
82
|
+
- `style?: PressableProps['style']` — Custom style applied to the root container.
|
|
83
|
+
- `onPress?: () => void` — Called when the button is pressed.
|
|
84
|
+
- `disabled?: boolean` — Default: `false`. Disables the button.
|
|
85
|
+
- `variant?: 'filled' | 'tonal' | 'outlined' | 'standard'` — Default: `'filled'`. Visual style variant.
|
|
86
|
+
- `selected?: boolean` — Enables toggle mode. The button changes appearance based on selected/unselected state.
|
|
87
|
+
- `size?: 'small' | 'medium' | 'large'` — Default: `'medium'`. Physical size of the touch target and icon container.
|
|
88
|
+
- `accessibilityLabel: string` — Required — icon-only buttons must have a label for screen readers.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### AppBar
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { AppBar } from '@onlynative/components/appbar'
|
|
96
|
+
|
|
97
|
+
<AppBar title="Home" variant="small" />
|
|
98
|
+
<AppBar title="Details" canGoBack onBackPress={router.back} insetTop />
|
|
99
|
+
<AppBar title="Settings" variant="center-aligned" actions={[
|
|
100
|
+
{ icon: 'magnify', accessibilityLabel: 'Search', onPress: onSearch },
|
|
101
|
+
{ icon: 'dots-vertical', accessibilityLabel: 'More', onPress: onMore },
|
|
102
|
+
]} />
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Props:
|
|
106
|
+
- `title: string` — Title text displayed in the bar.
|
|
107
|
+
- `variant?: 'small' | 'center-aligned' | 'medium' | 'large'` — Default: `'small'`. Layout variant.
|
|
108
|
+
- `colorScheme?: 'surface' | 'surfaceContainerLowest' | 'surfaceContainerLow' | 'surfaceContainer' | 'surfaceContainerHigh' | 'surfaceContainerHighest' | 'primary' | 'primaryContainer'` — Default: `'surface'`. Color scheme that determines the default container and content colors. `containerColor` and `contentColor` props override these defaults.
|
|
109
|
+
- `canGoBack?: boolean` — Default: `false`. When `true`, renders a back button in the leading slot.
|
|
110
|
+
- `onBackPress?: () => void` — Called when the auto-rendered back button is pressed.
|
|
111
|
+
- `insetTop?: boolean` — Default: `false`. When `true`, wraps the bar in a SafeAreaView that handles the top inset.
|
|
112
|
+
- `elevated?: boolean` — Default: `false`. When `true`, adds shadow/elevation to indicate the bar is scrolled.
|
|
113
|
+
- `leading?: ReactNode` — Custom leading content. When provided, overrides `canGoBack`.
|
|
114
|
+
- `trailing?: ReactNode` — Custom trailing content. When provided, overrides `actions`.
|
|
115
|
+
- `actions?: AppBarAction[]` — Array of icon-button actions rendered in the trailing slot.
|
|
116
|
+
- `containerColor?: string` — Override the container (background) color. Applied to both normal and elevated states.
|
|
117
|
+
- `contentColor?: string` — Override the content (title and icon) color.
|
|
118
|
+
- `titleStyle?: StyleProp<TextStyle>` — Additional style applied to the title text.
|
|
119
|
+
- `style?: StyleProp<ViewStyle>` — Custom style applied to the root container.
|
|
120
|
+
|
|
121
|
+
AppBarAction:
|
|
122
|
+
- `icon: string` — MaterialCommunityIcons icon name to render.
|
|
123
|
+
- `accessibilityLabel: string` — Accessibility label for screen readers (required).
|
|
124
|
+
- `onPress?: () => void` — Called when the action icon is pressed.
|
|
125
|
+
- `disabled?: boolean` — Default: `false`. Disables the action icon.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### Card
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { Card } from '@onlynative/components/card'
|
|
133
|
+
|
|
134
|
+
<Card variant="elevated">{children}</Card>
|
|
135
|
+
<Card variant="outlined" onPress={handlePress}>{children}</Card>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Props:
|
|
139
|
+
- `children: ReactNode` — Content rendered inside the card surface.
|
|
140
|
+
- `variant?: 'elevated' | 'filled' | 'outlined'` — Default: `'elevated'`. Surface style variant.
|
|
141
|
+
- `onPress?: () => void` — When provided, the card becomes interactive (Pressable). Omit to render as a plain View.
|
|
142
|
+
- `disabled?: boolean` — Default: `false`. Disables the press interaction and reduces opacity. Only effective when `onPress` is provided.
|
|
143
|
+
- `containerColor?: string` — Override the container (background) color. State-layer colors (hover, press) are derived automatically.
|
|
144
|
+
- Inherits `ViewProps`
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### Chip
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { Chip } from '@onlynative/components/chip'
|
|
152
|
+
|
|
153
|
+
<Chip variant="assist" leadingIcon="calendar">Today</Chip>
|
|
154
|
+
<Chip variant="filter" selected={isSelected} onPress={toggle}>Active</Chip>
|
|
155
|
+
<Chip variant="input" avatar={<Avatar />} onClose={handleRemove}>John</Chip>
|
|
156
|
+
<Chip variant="suggestion" onPress={handleSuggest}>Try this</Chip>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Props:
|
|
160
|
+
- `children: string` — Text label rendered inside the chip.
|
|
161
|
+
- `variant?: 'assist' | 'filter' | 'input' | 'suggestion'` — Default: `'assist'`. Chip type variant. Controls appearance, allowed interactions, and icon behavior.
|
|
162
|
+
- `elevated?: boolean` — Default: `false`. Whether the chip uses an elevated surface instead of an outline border. Available on `assist`, `filter`, and `suggestion` variants. Ignored on `input` variant (always outlined).
|
|
163
|
+
- `selected?: boolean` — Whether the chip is in a selected (toggled-on) state. Only meaningful for the `filter` variant. Ignored by other variants.
|
|
164
|
+
- `leadingIcon?: string` — Name of a MaterialCommunityIcons icon to show before the label.
|
|
165
|
+
- `iconSize?: number` — Default: `18`. Size of the leading icon in dp.
|
|
166
|
+
- `avatar?: ReactNode` — Custom avatar content (e.g. a small Image or View) to render before the label. Only applicable to the `input` variant. Takes precedence over `leadingIcon`.
|
|
167
|
+
- `onClose?: () => void` — Callback fired when the close/remove icon is pressed. When provided, renders a trailing close icon. Only renders on `input` and `filter` (when selected) variants.
|
|
168
|
+
- `containerColor?: string` — Override the container (background) color. State-layer colors (hover, press) are derived automatically.
|
|
169
|
+
- `contentColor?: string` — Override the content (label and icon) color. State-layer colors are derived automatically when no containerColor is set.
|
|
170
|
+
- `labelStyle?: StyleProp<TextStyle>` — Additional style applied to the label text.
|
|
171
|
+
- Inherits `PressableProps` (except `children`)
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
### Checkbox
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import { Checkbox } from '@onlynative/components/checkbox'
|
|
179
|
+
|
|
180
|
+
<Checkbox value={checked} onValueChange={setChecked} />
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Props:
|
|
184
|
+
- `value?: boolean` — Default: `false`. Whether the checkbox is checked.
|
|
185
|
+
- `onValueChange?: (value: boolean) => void` — Callback fired when the checkbox is toggled. Receives the new value.
|
|
186
|
+
- `containerColor?: string` — Override the container (box) color when checked. State-layer colors (hover, press) are derived automatically.
|
|
187
|
+
- `contentColor?: string` — Override the checkmark icon color.
|
|
188
|
+
- Inherits `PressableProps` (except `children`)
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### Radio
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
import { Radio } from '@onlynative/components/radio'
|
|
196
|
+
|
|
197
|
+
<Radio value={selected} onValueChange={setSelected} />
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Props:
|
|
201
|
+
- `value?: boolean` — Default: `false`. Whether the radio button is selected.
|
|
202
|
+
- `onValueChange?: (value: boolean) => void` — Callback fired when the radio is pressed. Receives the new value.
|
|
203
|
+
- `containerColor?: string` — Override the outer ring and inner dot color when selected. State-layer colors (hover, press) are derived automatically.
|
|
204
|
+
- `contentColor?: string` — Override the outer ring color when unselected.
|
|
205
|
+
- Inherits `PressableProps` (except `children`)
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### Switch
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
import { Switch } from '@onlynative/components/switch'
|
|
213
|
+
|
|
214
|
+
<Switch value={on} onValueChange={setOn} />
|
|
215
|
+
<Switch value={on} onValueChange={setOn} selectedIcon="check" unselectedIcon="close" />
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Props:
|
|
219
|
+
- `value?: boolean` — Default: `false`. Whether the switch is toggled on.
|
|
220
|
+
- `onValueChange?: (value: boolean) => void` — Callback fired when the switch is toggled. Receives the new value.
|
|
221
|
+
- `selectedIcon?: string` — Default: `'check'`. Name of a MaterialCommunityIcons icon to show on the thumb when selected.
|
|
222
|
+
- `unselectedIcon?: string` — Name of a MaterialCommunityIcons icon to show on the thumb when unselected. When provided, the thumb renders at the larger selected size.
|
|
223
|
+
- `containerColor?: string` — Override the track color. State-layer colors (hover, press) are derived automatically.
|
|
224
|
+
- `contentColor?: string` — Override the thumb and icon color.
|
|
225
|
+
- Inherits `PressableProps` (except `children`)
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
### TextField
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import { TextField } from '@onlynative/components/text-field'
|
|
233
|
+
|
|
234
|
+
<TextField label="Email" variant="outlined" value={email} onChangeText={setEmail} />
|
|
235
|
+
<TextField label="Password" variant="filled" error errorText="Required" />
|
|
236
|
+
<TextField label="Search" leadingIcon="magnify" trailingIcon="close" onTrailingIconPress={clear} />
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Props:
|
|
240
|
+
- `label?: string` — Floating label text. Animates above the input when focused or filled.
|
|
241
|
+
- `variant?: 'filled' | 'outlined'` — Default: `'filled'`. Container style.
|
|
242
|
+
- `supportingText?: string` — Helper text displayed below the field. Hidden when `error` or `errorText` is active.
|
|
243
|
+
- `errorText?: string` — Error message. When provided, implicitly sets `error` to `true` and replaces `supportingText`.
|
|
244
|
+
- `error?: boolean` — Default: `false`. When `true`, renders the field in error state with error colors.
|
|
245
|
+
- `disabled?: boolean` — Default: `false`. Disables text input and reduces opacity.
|
|
246
|
+
- `leadingIcon?: string` — MaterialCommunityIcons icon name rendered at the start of the field.
|
|
247
|
+
- `trailingIcon?: string` — MaterialCommunityIcons icon name rendered at the end of the field.
|
|
248
|
+
- `onTrailingIconPress?: () => void` — Called when the trailing icon is pressed.
|
|
249
|
+
- `containerColor?: string` — Override the container (background) color. Disabled state still uses the standard disabled appearance.
|
|
250
|
+
- `contentColor?: string` — Override the content (input text and icon) color. Error and disabled states take precedence.
|
|
251
|
+
- `inputStyle?: StyleProp<TextStyle>` — Additional style applied to the text input element.
|
|
252
|
+
- Inherits `TextInputProps` (except `placeholderTextColor`, `editable`)
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
### Layout Components
|
|
257
|
+
|
|
258
|
+
#### Layout
|
|
259
|
+
|
|
260
|
+
Full-screen safe area wrapper.
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
import { Layout } from '@onlynative/components/layout'
|
|
264
|
+
|
|
265
|
+
<Layout>{children}</Layout>
|
|
266
|
+
<Layout immersive>{/* No safe area insets */}</Layout>
|
|
267
|
+
<Layout edges={['top', 'bottom']}>{children}</Layout>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Props:
|
|
271
|
+
- `immersive?: boolean` — Default: `false`. When `true`, removes all safe area insets for full-screen layout.
|
|
272
|
+
- `edges?: Edge[]` — Explicit set of safe-area edges to apply. Overrides `immersive` when provided.
|
|
273
|
+
- `style?: StyleProp<ViewStyle>` — Additional styles applied to the SafeAreaView container.
|
|
274
|
+
- Inherits `PropsWithChildren`
|
|
275
|
+
|
|
276
|
+
#### Box
|
|
277
|
+
|
|
278
|
+
Base layout primitive with spacing shorthand props.
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
import { Box } from '@onlynative/components/layout'
|
|
282
|
+
|
|
283
|
+
<Box p="md" bg={theme.colors.surface}>{children}</Box>
|
|
284
|
+
<Box px="lg" py="sm" gap="md">{children}</Box>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Props:
|
|
288
|
+
- `p?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Padding on all sides
|
|
289
|
+
- `px?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Horizontal padding (paddingStart + paddingEnd)
|
|
290
|
+
- `py?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Vertical padding (paddingTop + paddingBottom)
|
|
291
|
+
- `pt?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Padding top
|
|
292
|
+
- `pb?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Padding bottom
|
|
293
|
+
- `ps?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Padding start (left in LTR, right in RTL)
|
|
294
|
+
- `pe?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Padding end (right in LTR, left in RTL)
|
|
295
|
+
- `m?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Margin on all sides
|
|
296
|
+
- `mx?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Horizontal margin (marginStart + marginEnd)
|
|
297
|
+
- `my?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Vertical margin (marginTop + marginBottom)
|
|
298
|
+
- `mt?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Margin top
|
|
299
|
+
- `mb?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Margin bottom
|
|
300
|
+
- `ms?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Margin start
|
|
301
|
+
- `me?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Margin end
|
|
302
|
+
- `gap?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Gap between children
|
|
303
|
+
- `rowGap?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Row gap between children
|
|
304
|
+
- `columnGap?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number` — Column gap between children
|
|
305
|
+
- `flex?: number` — Flex value
|
|
306
|
+
- `align?: FlexAlignType` — Align items along the cross axis
|
|
307
|
+
- `bg?: string` — Background color
|
|
308
|
+
- Inherits `ViewProps`
|
|
309
|
+
|
|
310
|
+
#### Row
|
|
311
|
+
|
|
312
|
+
Horizontal flex container (extends Box).
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
import { Row } from '@onlynative/components/layout'
|
|
316
|
+
|
|
317
|
+
<Row gap="sm" align="center">{children}</Row>
|
|
318
|
+
<Row wrap>{/* Wraps to next line */}</Row>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Props:
|
|
322
|
+
- `wrap?: boolean` — Default: `false`. Whether children should wrap to the next line when they overflow.
|
|
323
|
+
- `inverted?: boolean` — Default: `false`. Reverses the layout direction (`row-reverse`).
|
|
324
|
+
|
|
325
|
+
#### Column
|
|
326
|
+
|
|
327
|
+
Vertical flex container (extends Box).
|
|
328
|
+
|
|
329
|
+
```tsx
|
|
330
|
+
import { Column } from '@onlynative/components/layout'
|
|
331
|
+
|
|
332
|
+
<Column gap="md">{children}</Column>
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Props:
|
|
336
|
+
- `inverted?: boolean` — Default: `false`. Reverses the layout direction (`column-reverse`).
|
|
337
|
+
|
|
338
|
+
#### Grid
|
|
339
|
+
|
|
340
|
+
Equal-width column grid (extends Row).
|
|
341
|
+
|
|
342
|
+
```tsx
|
|
343
|
+
import { Grid } from '@onlynative/components/layout'
|
|
344
|
+
|
|
345
|
+
<Grid columns={3} gap="sm">{children}</Grid>
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Props:
|
|
349
|
+
- `columns: number` — Number of equal-width columns.
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
### List
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import { List, ListItem, ListDivider } from '@onlynative/components/list'
|
|
358
|
+
|
|
359
|
+
<List>
|
|
360
|
+
<ListItem headlineText="Title" supportingText="Subtitle" onPress={handlePress} />
|
|
361
|
+
<ListDivider />
|
|
362
|
+
<ListItem
|
|
363
|
+
headlineText="With Icon"
|
|
364
|
+
leadingContent={<Icon name="star" />}
|
|
365
|
+
trailingContent={<Switch value={on} onValueChange={setOn} />}
|
|
366
|
+
/>
|
|
367
|
+
</List>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
#### List
|
|
371
|
+
|
|
372
|
+
Container for list items.
|
|
373
|
+
|
|
374
|
+
Props:
|
|
375
|
+
- `children: ReactNode` — Content rendered inside the list container.
|
|
376
|
+
- `style?: StyleProp<ViewStyle>`
|
|
377
|
+
- Inherits `ViewProps`
|
|
378
|
+
|
|
379
|
+
#### ListItem
|
|
380
|
+
|
|
381
|
+
Props:
|
|
382
|
+
- `headlineText: string` — Primary text displayed on the list item.
|
|
383
|
+
- `supportingText?: string` — Secondary text displayed below the headline.
|
|
384
|
+
- `overlineText?: string` — Text displayed above the headline (e.g. category label).
|
|
385
|
+
- `trailingSupportingText?: string` — Short text displayed at the trailing edge (e.g. "100+", timestamp).
|
|
386
|
+
- `leadingContent?: ReactNode` — Content rendered before the text block (icon, avatar, image, checkbox).
|
|
387
|
+
- `trailingContent?: ReactNode` — Content rendered after the text block (icon, switch, checkbox).
|
|
388
|
+
- `onPress?: () => void` — When provided, the item becomes interactive (Pressable). Omit to render as a plain View.
|
|
389
|
+
- `disabled?: boolean` — Default: `false`. Disables the press interaction and reduces opacity. Only effective when `onPress` is provided.
|
|
390
|
+
- `containerColor?: string` — Override the container (background) color. State-layer colors (hover, press) are derived automatically.
|
|
391
|
+
- `supportingTextNumberOfLines?: number` — Default: `1`. Maximum number of lines for supportingText before truncating.
|
|
392
|
+
- `style?: StyleProp<ViewStyle>`
|
|
393
|
+
- Inherits `ViewProps`
|
|
394
|
+
|
|
395
|
+
#### ListDivider
|
|
396
|
+
|
|
397
|
+
Props:
|
|
398
|
+
- `inset?: boolean` — Default: `false`. When true, adds a leading inset so the divider aligns with text that follows a leading icon (56dp from the start edge).
|
|
399
|
+
- `style?: StyleProp<ViewStyle>`
|
|
400
|
+
- Inherits `ViewProps`
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
### KeyboardAvoidingWrapper
|
|
405
|
+
|
|
406
|
+
```tsx
|
|
407
|
+
import { KeyboardAvoidingWrapper } from '@onlynative/components/keyboard-avoiding-wrapper'
|
|
408
|
+
|
|
409
|
+
<KeyboardAvoidingWrapper>
|
|
410
|
+
<TextField label="Name" />
|
|
411
|
+
<TextField label="Email" />
|
|
412
|
+
</KeyboardAvoidingWrapper>
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Props:
|
|
416
|
+
- `behavior?: 'padding' | 'height' | 'position'` — Default: `'padding'`. Keyboard avoidance strategy.
|
|
417
|
+
- `keyboardVerticalOffset?: number` — Default: `0`. Extra offset added to the keyboard height calculation. Useful for accounting for headers or tab bars.
|
|
418
|
+
- `enabled?: boolean` — Default: `true`. Enable or disable the keyboard avoiding behavior.
|
|
419
|
+
- `scrollViewProps?: ScrollViewProps` — Props forwarded to the inner `ScrollView`.
|
|
420
|
+
- `onKeyboardShow?: (event: KeyboardEvent) => void` — Called when the keyboard is about to show (iOS) or has shown (Android).
|
|
421
|
+
- `onKeyboardHide?: (event: KeyboardEvent) => void` — Called when the keyboard is about to hide (iOS) or has hidden (Android).
|
|
422
|
+
- `style?: StyleProp<ViewStyle>` — Style applied to the outer `KeyboardAvoidingView`.
|
|
423
|
+
- `contentContainerStyle?: StyleProp<ViewStyle>` — Style applied to the inner `ScrollView` contentContainerStyle.
|
|
424
|
+
- Inherits `PropsWithChildren`
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
### Avatar
|
|
429
|
+
|
|
430
|
+
```tsx
|
|
431
|
+
import { Avatar } from '@onlynative/components/avatar'
|
|
432
|
+
|
|
433
|
+
<Avatar imageUri="https://example.com/photo.jpg" size="large" />
|
|
434
|
+
<Avatar icon="account" size="medium" containerColor="#E8DEF8" />
|
|
435
|
+
<Avatar label="JD" size="small" />
|
|
436
|
+
<Avatar icon="plus" onPress={handleAdd} accessibilityLabel="Add user" />
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Props:
|
|
440
|
+
- `imageUri?: string` — URI of the image to display. Takes priority over `icon` and `label`.
|
|
441
|
+
- `icon?: string` — MaterialCommunityIcons icon name. Takes priority over `label` when `imageUri` is not set.
|
|
442
|
+
- `label?: string` — Text initials to display (1–2 characters recommended). Shown when `imageUri` and `icon` are not set.
|
|
443
|
+
- `size?: 'xSmall' | 'small' | 'medium' | 'large' | 'xLarge'` — Default: `'medium'`. Size of the avatar.
|
|
444
|
+
- `containerColor?: string` — Override the container (background) color. State-layer colors (hover, press) are derived automatically when `onPress` is set.
|
|
445
|
+
- `contentColor?: string` — Override the content (icon / initials) color.
|
|
446
|
+
- `style?: StyleProp<ViewStyle>` — Custom style applied to the root container.
|
|
447
|
+
- `onPress?: () => void` — When provided, the avatar becomes interactive (Pressable).
|
|
448
|
+
- `accessibilityLabel?: string` — Required when `onPress` is provided — labels the button for screen readers.
|
|
449
|
+
- Inherits `ViewProps` (except `style`)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## Icons
|
|
455
|
+
|
|
456
|
+
All icon props accept `MaterialCommunityIcons` names from `@expo/vector-icons`. Browse available icons at https://pictogrammers.com/library/mdi/.
|
|
457
|
+
|
|
458
|
+
`@expo/vector-icons` is an optional peer dependency — only install it if you use icon props (`leadingIcon`, `trailingIcon`, `icon`).
|
package/package.json
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onlynative/components",
|
|
3
|
+
"version": "0.0.0-alpha.0",
|
|
4
|
+
"description": "Material Design 3 UI components for React Native — Button, Card, Chip, TextField, and more.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"react-native": "src/index.ts",
|
|
11
|
+
"source": "src/index.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"react-native": "./src/index.ts",
|
|
16
|
+
"browser": "./src/index.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./typography": {
|
|
20
|
+
"types": "./dist/typography/index.d.ts",
|
|
21
|
+
"react-native": "./src/typography/index.ts",
|
|
22
|
+
"browser": "./src/typography/index.ts",
|
|
23
|
+
"default": "./dist/typography/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./layout": {
|
|
26
|
+
"types": "./dist/layout/index.d.ts",
|
|
27
|
+
"react-native": "./src/layout/index.ts",
|
|
28
|
+
"browser": "./src/layout/index.ts",
|
|
29
|
+
"default": "./dist/layout/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./button": {
|
|
32
|
+
"types": "./dist/button/index.d.ts",
|
|
33
|
+
"react-native": "./src/button/index.ts",
|
|
34
|
+
"browser": "./src/button/index.ts",
|
|
35
|
+
"default": "./dist/button/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./icon-button": {
|
|
38
|
+
"types": "./dist/icon-button/index.d.ts",
|
|
39
|
+
"react-native": "./src/icon-button/index.ts",
|
|
40
|
+
"browser": "./src/icon-button/index.ts",
|
|
41
|
+
"default": "./dist/icon-button/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./appbar": {
|
|
44
|
+
"types": "./dist/appbar/index.d.ts",
|
|
45
|
+
"react-native": "./src/appbar/index.ts",
|
|
46
|
+
"browser": "./src/appbar/index.ts",
|
|
47
|
+
"default": "./dist/appbar/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./card": {
|
|
50
|
+
"types": "./dist/card/index.d.ts",
|
|
51
|
+
"react-native": "./src/card/index.ts",
|
|
52
|
+
"browser": "./src/card/index.ts",
|
|
53
|
+
"default": "./dist/card/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./chip": {
|
|
56
|
+
"types": "./dist/chip/index.d.ts",
|
|
57
|
+
"react-native": "./src/chip/index.ts",
|
|
58
|
+
"browser": "./src/chip/index.ts",
|
|
59
|
+
"default": "./dist/chip/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./checkbox": {
|
|
62
|
+
"types": "./dist/checkbox/index.d.ts",
|
|
63
|
+
"react-native": "./src/checkbox/index.ts",
|
|
64
|
+
"browser": "./src/checkbox/index.ts",
|
|
65
|
+
"default": "./dist/checkbox/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./radio": {
|
|
68
|
+
"types": "./dist/radio/index.d.ts",
|
|
69
|
+
"react-native": "./src/radio/index.ts",
|
|
70
|
+
"browser": "./src/radio/index.ts",
|
|
71
|
+
"default": "./dist/radio/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./switch": {
|
|
74
|
+
"types": "./dist/switch/index.d.ts",
|
|
75
|
+
"react-native": "./src/switch/index.ts",
|
|
76
|
+
"browser": "./src/switch/index.ts",
|
|
77
|
+
"default": "./dist/switch/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./text-field": {
|
|
80
|
+
"types": "./dist/text-field/index.d.ts",
|
|
81
|
+
"react-native": "./src/text-field/index.ts",
|
|
82
|
+
"browser": "./src/text-field/index.ts",
|
|
83
|
+
"default": "./dist/text-field/index.js"
|
|
84
|
+
},
|
|
85
|
+
"./list": {
|
|
86
|
+
"types": "./dist/list/index.d.ts",
|
|
87
|
+
"react-native": "./src/list/index.ts",
|
|
88
|
+
"browser": "./src/list/index.ts",
|
|
89
|
+
"default": "./dist/list/index.js"
|
|
90
|
+
},
|
|
91
|
+
"./keyboard-avoiding-wrapper": {
|
|
92
|
+
"types": "./dist/keyboard-avoiding-wrapper/index.d.ts",
|
|
93
|
+
"react-native": "./src/keyboard-avoiding-wrapper/index.ts",
|
|
94
|
+
"browser": "./src/keyboard-avoiding-wrapper/index.ts",
|
|
95
|
+
"default": "./dist/keyboard-avoiding-wrapper/index.js"
|
|
96
|
+
},
|
|
97
|
+
"./avatar": {
|
|
98
|
+
"types": "./dist/avatar/index.d.ts",
|
|
99
|
+
"react-native": "./src/avatar/index.ts",
|
|
100
|
+
"browser": "./src/avatar/index.ts",
|
|
101
|
+
"default": "./dist/avatar/index.js"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"typesVersions": {
|
|
105
|
+
"*": {
|
|
106
|
+
"typography": [
|
|
107
|
+
"dist/typography/index.d.ts"
|
|
108
|
+
],
|
|
109
|
+
"layout": [
|
|
110
|
+
"dist/layout/index.d.ts"
|
|
111
|
+
],
|
|
112
|
+
"button": [
|
|
113
|
+
"dist/button/index.d.ts"
|
|
114
|
+
],
|
|
115
|
+
"icon-button": [
|
|
116
|
+
"dist/icon-button/index.d.ts"
|
|
117
|
+
],
|
|
118
|
+
"appbar": [
|
|
119
|
+
"dist/appbar/index.d.ts"
|
|
120
|
+
],
|
|
121
|
+
"card": [
|
|
122
|
+
"dist/card/index.d.ts"
|
|
123
|
+
],
|
|
124
|
+
"chip": [
|
|
125
|
+
"dist/chip/index.d.ts"
|
|
126
|
+
],
|
|
127
|
+
"checkbox": [
|
|
128
|
+
"dist/checkbox/index.d.ts"
|
|
129
|
+
],
|
|
130
|
+
"radio": [
|
|
131
|
+
"dist/radio/index.d.ts"
|
|
132
|
+
],
|
|
133
|
+
"switch": [
|
|
134
|
+
"dist/switch/index.d.ts"
|
|
135
|
+
],
|
|
136
|
+
"text-field": [
|
|
137
|
+
"dist/text-field/index.d.ts"
|
|
138
|
+
],
|
|
139
|
+
"list": [
|
|
140
|
+
"dist/list/index.d.ts"
|
|
141
|
+
],
|
|
142
|
+
"keyboard-avoiding-wrapper": [
|
|
143
|
+
"dist/keyboard-avoiding-wrapper/index.d.ts"
|
|
144
|
+
],
|
|
145
|
+
"avatar": [
|
|
146
|
+
"dist/avatar/index.d.ts"
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"publishConfig": {
|
|
151
|
+
"access": "public"
|
|
152
|
+
},
|
|
153
|
+
"files": [
|
|
154
|
+
"dist",
|
|
155
|
+
"llms.txt"
|
|
156
|
+
],
|
|
157
|
+
"license": "MIT",
|
|
158
|
+
"repository": {
|
|
159
|
+
"type": "git",
|
|
160
|
+
"url": "https://github.com/onlynative/ui.git",
|
|
161
|
+
"directory": "packages/components"
|
|
162
|
+
},
|
|
163
|
+
"homepage": "https://github.com/onlynative/ui",
|
|
164
|
+
"keywords": [
|
|
165
|
+
"react-native",
|
|
166
|
+
"material-design-3",
|
|
167
|
+
"ui-components",
|
|
168
|
+
"md3",
|
|
169
|
+
"material-you"
|
|
170
|
+
],
|
|
171
|
+
"scripts": {
|
|
172
|
+
"build": "tsup",
|
|
173
|
+
"typecheck": "tsc --noEmit",
|
|
174
|
+
"test": "jest --passWithNoTests"
|
|
175
|
+
},
|
|
176
|
+
"peerDependencies": {
|
|
177
|
+
"@expo/vector-icons": ">=14.0.0",
|
|
178
|
+
"@onlynative/core": ">=0.0.0-alpha.0",
|
|
179
|
+
"react": ">=18.0.0",
|
|
180
|
+
"react-native": ">=0.72.0",
|
|
181
|
+
"react-native-safe-area-context": ">=4.0.0"
|
|
182
|
+
},
|
|
183
|
+
"peerDependenciesMeta": {
|
|
184
|
+
"@expo/vector-icons": {
|
|
185
|
+
"optional": true
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"devDependencies": {
|
|
189
|
+
"@react-native/babel-preset": "^0.81.5",
|
|
190
|
+
"@onlynative/core": "workspace:*",
|
|
191
|
+
"@onlynative/utils": "workspace:*",
|
|
192
|
+
"@testing-library/react-native": "^13.3.3",
|
|
193
|
+
"@types/jest": "^29.5.14",
|
|
194
|
+
"@types/react": "^19.0.0",
|
|
195
|
+
"jest": "^29.7.0",
|
|
196
|
+
"react": "19.1.0",
|
|
197
|
+
"react-native": "0.81.5",
|
|
198
|
+
"react-test-renderer": "19.1.0",
|
|
199
|
+
"tsup": "^8.0.0",
|
|
200
|
+
"typescript": "^5.0.0"
|
|
201
|
+
}
|
|
202
|
+
}
|