Skip to content

Commit b7a5286

Browse files
committed
docs: add 3.11 versioned docs
1 parent 94ada4b commit b7a5286

37 files changed

Lines changed: 3305 additions & 0 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Guides",
3+
"position": 5
4+
}
6.22 MB
Loading
6.28 MB
Loading
5.1 MB
Loading
2.67 MB
Loading
5.83 MB
Loading
3.82 MB
Loading
14.3 MB
Loading
5.72 MB
Loading
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: Dimming the Background
3+
description: Control the bottom sheet's dimming behavior.
4+
keywords: [bottom sheet dimming, bottom sheet background, inline bottom sheet, maps bottom sheet]
5+
---
6+
7+
import dimming from './assets/dimming.gif'
8+
9+
One of the most common use cases for a Bottom Sheet is to present it while still allowing users to interact with background components, such as in a Maps app.
10+
11+
In this guide, you can configure `TrueSheet` to achieve this exact functionality.
12+
13+
<img alt="dimming" src={dimming} width="300"/>
14+
15+
## How?
16+
17+
You can easily disable the dimmed background of the sheet by setting [`dimmed`](../reference/configuration#dimmed) to `false`.
18+
19+
```tsx {5}
20+
export const App = () => {
21+
return (
22+
<TrueSheet
23+
detents={['auto', 0.69, 1]}
24+
dimmed={false}
25+
>
26+
<View />
27+
</TrueSheet>
28+
)
29+
}
30+
```
31+
32+
### Dimmed by Detent Index
33+
34+
To further customize the dimming behavior, [`dimmedDetentIndex`](../reference/configuration#dimmeddetentindex) is also available. Set the [detent](../reference/configuration#detents) `index` at which you want the sheet to start dimming.
35+
36+
```tsx {5}
37+
export const App = () => {
38+
return (
39+
<TrueSheet
40+
detents={['auto', 0.69, 1]}
41+
dimmedDetentIndex={1} // Dim will start at 69% ✅
42+
>
43+
<View />
44+
</TrueSheet>
45+
)
46+
}
47+
```
48+
49+
:::info
50+
`dimmedDetentIndex` is ignored if `dimmed` is set to `false`.
51+
:::
52+
53+
## Customizing Dimming Alpha
54+
55+
You can dynamically control the dimming opacity based on the sheet's position using `ReanimatedTrueSheet` with `animatedPosition`.
56+
57+
:::tip
58+
Learn more about Reanimated integration in the [Reanimated guide](reanimated).
59+
:::
60+
61+
```tsx {2-3,7,9-11,14-21}
62+
import { ReanimatedTrueSheet, ReanimatedTrueSheetProvider, useReanimatedTrueSheet } from '@lodev09/react-native-true-sheet/reanimated'
63+
import Animated, { useAnimatedStyle } from 'react-native-reanimated'
64+
import { StyleSheet } from 'react-native'
65+
66+
export const App = () => {
67+
return (
68+
<ReanimatedTrueSheetProvider>
69+
<View style={styles.container}>
70+
<CustomBackdrop />
71+
<Sheet />
72+
</View>
73+
</ReanimatedTrueSheetProvider>
74+
)
75+
}
76+
77+
const CustomBackdrop = () => {
78+
const { animatedPosition } = useReanimatedTrueSheet()
79+
80+
const backdropStyle = useAnimatedStyle(() => ({
81+
opacity: animatedPosition.value * 0.5, // Adjust multiplier for desired alpha
82+
}))
83+
84+
return <Animated.View style={[StyleSheet.absoluteFill, styles.backdrop, backdropStyle]} />
85+
}
86+
87+
const Sheet = () => {
88+
return (
89+
<ReanimatedTrueSheet
90+
detents={[0.25, 0.5, 1]}
91+
dimmed={false}
92+
>
93+
<View />
94+
</ReanimatedTrueSheet>
95+
)
96+
}
97+
98+
const styles = StyleSheet.create({
99+
container: {
100+
flex: 1,
101+
},
102+
backdrop: {
103+
backgroundColor: 'black',
104+
},
105+
})
106+
```
107+
108+
This allows you to create custom dimming effects that respond to the sheet's movement in real-time.

0 commit comments

Comments
 (0)