You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This package is not compatible with [Expo Go](https://docs.expo.dev/get-started/expo-go/). Use this with [Expo CNG](https://docs.expo.dev/workflow/continuous-native-generation/) instead.
| sizes |[`SheetSize[]`](#sheetsize)|`["medium", "large"]`| Array of sizes you want the sheet to support. Maximum of _**3 sizes**_ only! **_collapsed_**, **_half-expanded_**, and **_expanded_**. Example: `size={["auto", "60%", "large"]}`| ✅ | ✅ |
69
-
| name |`string`| - | The name to reference this sheet. It has to be **_unique_**. You can then present this sheet globally using its name. | ✅ | ✅ |
| FooterComponent |`ComponentType<...> \| ReactElement`| - | A component that floats at the bottom of the sheet. Accepts a functional `Component` or `ReactElement`. | ✅ | ✅ |
75
-
| dismissible |`boolean`|`true`| If set to `false`, the sheet will prevent interactive dismissal via dragging or clicking outside of it. | ✅ | ✅ |
76
-
| grabber |`boolean`|`true`| Shows a grabber (or handle). Native on IOS and styled `View` on Android. | ✅ | ✅ |
77
-
| grabberProps |[`TrueSheetGrabberProps`](#truesheetgrabberprops)| - | Overrides the grabber props for android. || ✅ |
78
-
| blurTint |[`BlurTint`](#blurtint)| - | The blur effect style on IOS. Overrides `backgroundColor` if set. Example: `"light"`, `"dark"`, etc. | ✅ ||
79
-
| scrollRef |`RefObject<...>`| - | The main scrollable ref that the sheet should handle on IOS. | ✅ ||
80
-
81
-
## Methods
82
-
83
-
```tsx
84
-
const sheet =useRef<TrueSheet>(null)
85
-
86
-
const resize = () => {
87
-
sheet.current?.resize(1)
88
-
}
89
-
90
-
const dismiss = () => {
91
-
sheet.current?.dismiss()
92
-
}
93
-
94
-
return (
95
-
<View>
96
-
<ButtononPress={resize}title="Resize to 80%" />
97
-
<ButtononPress={dismiss}title="Dimiss" />
98
-
<TrueSheetsizes={['auto', '80%']}ref={sheet}>
99
-
// ...
100
-
</TrueSheet>
101
-
</View>
102
-
)
103
-
```
104
-
105
-
| Name | Parameters | Description |
106
-
| - | - | - |
107
-
| present |`index: number = 0`| Present the modal sheet. Optionally accepts a size `index`. See `sizes` prop. |
108
-
| resize |`index: number`| Resizes the sheet programmatically by `index`. This is an alias of the `present(index)` method. |
109
-
| dismiss | - | Dismisses the sheet. |
110
-
111
-
### Static Methods
112
-
113
-
You can also call the above methods statically without having access to a sheet's `ref`. This is particularly useful when you want to present a sheet from anywhere.
114
-
115
-
The API is similar to the ref methods except for the required `name` prop.
| onPresent |[`SizeInfo`](#sizeinfo)| Called when the sheet has been presented. Comes with the size index and value. |
159
-
| onDismiss | - | Called when the sheet has been dismissed. |
160
-
| onSizeChange |[`SizeInfo`](#sizeinfo)| Called when the size of the sheet has changed. Either by dragging or presenting programatically. Comes with the size index and value. |
161
-
162
-
## Types
163
-
164
-
### `SheetSize`
165
-
166
-
```tsx
167
-
<TrueSheetsizes={['auto', '80%', 'large']}>
168
-
// ...
169
-
</TrueSheet>
170
-
```
171
-
172
-
| Value | Description | 🍎 | 🤖 |
173
-
| - | - | - | - |
174
-
|`"auto"`| Auto resize based on content height. |**_16+_**| ✅ |
175
-
|`"small"`| Translates to 25% |**_16+_**| ✅ |
176
-
|`"medium"`| Translates to 50% |**_15+_**| ✅ |
177
-
|`"large"`| Translates to 100% | ✅ | ✅ |
178
-
|`"${number}%"`| Fixed height in % |**_16+_**| ✅ |
179
-
|`number`| Fixed height |**_16+_**| ✅ |
180
-
181
-
> [!NOTE]
182
-
> `auto` is not guaranteed to be accurate if your content depends on various rendering logic. Experiment with it and try to keep your content size as fixed as possible.
183
-
>
184
-
> Alternatively, you can programmatically call [`resize`](#methods) to adjust the sheet size on-the-fly.
185
-
186
-
### `TrueSheetGrabberProps`
187
-
188
-
Grabber props to be used for android grabber or handle.
189
-
190
-
| Prop | Type | Default | Description |
191
-
| - | - | - | - |
192
-
| visible |`boolean`|`true`| Is grabber visible. |
193
-
| color |`ColorValue`|`"rgba(73,69,79,0.4)"`| Grabber color according to M3 specs. |
194
-
| height |`number`|`4`| Grabber height according to M3 specs. |
195
-
| width |`number`|`32`| Grabber width according to M3 specs. |
196
-
| topOffset |`number`|`0`| Grabber top position offset. |
197
-
198
-
### `BlurTint`
199
-
200
-
Blur tint that is mapped into native values in IOS.
201
-
202
-
```tsx
203
-
<TrueSheetblurTint="dark">
204
-
// ...
205
-
</TrueSheet>
206
-
```
207
-
208
-
| Value |
209
-
| - |
210
-
|`"light"`|
211
-
|`"dark"`|
212
-
|`"default"`|
213
-
|`"extraLight"`|
214
-
|`"regular"`|
215
-
|`"prominent"`|
216
-
|`"systemUltraThinMaterial"`|
217
-
|`"systemThinMaterial"`|
218
-
|`"systemMaterial"`|
219
-
|`"systemThickMaterial"`|
220
-
|`"systemChromeMaterial"`|
221
-
|`"systemUltraThinMaterialLight"`|
222
-
|`"systemThinMaterialLight"`|
223
-
|`"systemMaterialLight"`|
224
-
|`"systemThickMaterialLight"`|
225
-
|`"systemChromeMaterialLight"`|
226
-
|`"systemUltraThinMaterialDark"`|
227
-
|`"systemThinMaterialDark"`|
228
-
|`"systemMaterialDark"`|
229
-
|`"systemThickMaterialDark"`|
230
-
|`"systemChromeMaterialDark"`|
231
-
232
-
### `SizeInfo`
233
-
234
-
`Object` that comes with some events.
235
-
236
-
```tsx
237
-
{
238
-
index: 1,
239
-
value: 69
240
-
}
241
-
```
242
-
243
-
| Property | Type | Description |
244
-
| - | - | - |
245
-
| index |`number`| The size index from the provided sizes. See `sizes` prop. |
246
-
| value |`number`| The actual height value of the size. |
247
-
248
-
## Testing
249
-
250
-
When using `jest`, simply mock the entire package.
251
-
252
-
```tsx
253
-
jest.mock('@lodev09/react-native-true-sheet')
254
-
```
255
-
256
-
## Troubleshooting
257
-
258
-
### Presenting a sheet on top of an existing sheet on **IOS**
259
-
260
-
On IOS, presenting a sheet on top of an existing sheet will cause error.
261
-
262
-
```console
263
-
Attempt to present <TrueSheet.TrueSheetViewController: 0x11829f800> on <UIViewController: 0x10900eb10> (from <RNSScreen: 0x117dbf400>) which is already presenting <TrueSheet.TrueSheetViewController: 0x11a0b9200>
264
-
```
265
-
266
-
There are _two_ ways to resolve this.
267
-
268
-
1. Dismiss the "parent" sheet first
269
-
```tsx
270
-
const presentSheet2 =async () => {
271
-
awaitsheet1.current?.dismiss() // Wait for sheet 1 to dismiss ✅
272
-
awaitsheet2.current?.present() // Sheet 2 will now present 🎉
OnIOS, navigatingtoa [ReactNavigation](https://reactnavigation.org) screen from within the Sheet can cause issues. To resolve this, dismiss the sheet before navigating!
340
-
341
-
Example:
342
-
```tsx
343
-
const sheet = useRef<TrueSheet>(null)
344
-
345
-
const navigate = async () => {
346
-
await sheet.current?.dismiss() // wait for the sheet to dismiss ✅
347
-
navigation.navigate('SomeScreen') // navigate to the screen 🎉
348
-
}
349
-
350
-
return (
351
-
<TrueSheet ref={sheet}>
352
-
<Button onPress={navigate} title="Navigate to SomeScreen" />
0 commit comments