react-native-blur-vibe 0.1.6 → 0.1.7
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 +374 -181
- package/android/src/main/java/com/blurvibe/BlurVibeView.kt +7 -5
- package/android/src/main/java/com/blurvibe/BlurVibeViewApi31.kt +448 -0
- package/android/src/main/java/com/blurvibe/BlurVibeViewManager.kt +70 -17
- package/ios/BlurVibeView.swift +28 -27
- package/ios/BlurVibeViewManager.m +9 -9
- package/ios/Views/BlurVibeSwiftUIView.swift +109 -16
- package/ios/Views/ProgressiveBlurView.swift +255 -0
- package/lib/commonjs/BlurVibeViewNativeComponent.ts +10 -16
- package/lib/commonjs/BlurView.js +34 -7
- package/lib/commonjs/BlurView.js.map +1 -1
- package/lib/module/BlurVibeViewNativeComponent.ts +10 -16
- package/lib/module/BlurView.js +34 -7
- package/lib/module/BlurView.js.map +1 -1
- package/lib/typescript/commonjs/src/BlurVibeViewNativeComponent.d.ts +4 -14
- package/lib/typescript/commonjs/src/BlurVibeViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/BlurView.d.ts +27 -8
- package/lib/typescript/commonjs/src/BlurView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +236 -18
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/BlurVibeViewNativeComponent.d.ts +4 -14
- package/lib/typescript/module/src/BlurVibeViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/BlurView.d.ts +27 -8
- package/lib/typescript/module/src/BlurView.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +236 -18
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/BlurVibeViewNativeComponent.ts +10 -16
- package/src/BlurView.tsx +34 -7
- package/src/types.ts +267 -18
package/README.md
CHANGED
|
@@ -6,243 +6,436 @@ A modern, actively maintained blur view for React Native. Works on <b>iOS</b> an
|
|
|
6
6
|
|
|
7
7
|
> The key difference from other blur libraries: `overlayColor` works on **both iOS and Android** — letting you control blur visibility the same way CSS `backdrop-filter` + `background-color` works on the web.
|
|
8
8
|
<br></br>
|
|
9
|
+
|
|
10
|
+
|
|
9
11
|
[](https://www.npmjs.com/package/react-native-blur-vibe)
|
|
10
12
|
[](https://github.com/I-am-Pritam-20/react-native-blur-vibe/actions/workflows/build-ios.yml)
|
|
11
13
|
[](https://github.com/I-am-Pritam-20/react-native-blur-vibe/actions/workflows/build-android.yml)
|
|
12
14
|
[](https://opensource.org/licenses/MIT)
|
|
13
|
-
|
|
15
|
+
<div align="left">
|
|
16
|
+
<p>
|
|
17
|
+
<img src="https://img.shields.io/badge/iOS-13%2B-blue?style=flat-square" alt="iOS 13+" />
|
|
18
|
+
<img src="https://img.shields.io/badge/Android-API%2021%2B-green?style=flat-square" alt="Android API 21+" />
|
|
19
|
+
</p>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
14
22
|
---
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Existing libraries like `@react-native-community/blur` and `react-native-blurview` suffer from:
|
|
19
|
-
- Build failures with React Native 0.73+ and the New Architecture
|
|
20
|
-
- Android 16KB page size build errors
|
|
21
|
-
- `overlayColor` only working on Android, not iOS
|
|
22
|
-
- Unmaintained or slow to update
|
|
23
|
-
`react-native-blur-vibe` is built from the ground up for modern React Native, with CI builds on every commit.
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
|
|
25
25
|
---
|
|
26
|
-
|
|
27
|
-
##
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
The `overlayColor` alpha channel is what controls blur visibility:
|
|
40
|
-
|
|
41
|
-
| `overlayColor` | Result |
|
|
42
|
-
|-----------------|---------------------------------------------|
|
|
43
|
-
| `#00000000` | Fully transparent → pure blur shows through |
|
|
44
|
-
| `#00000080` | Semi-transparent black tint over blur |
|
|
45
|
-
| `#FFFFFFFF` | Fully opaque white → blur completely hidden |
|
|
46
|
-
| `#FFFFFF30` | Frosted glass / white tint effect |
|
|
47
|
-
|
|
48
|
-
**This works on both iOS and Android.** Not just Android like other libraries.
|
|
49
|
-
|
|
26
|
+
|
|
27
|
+
## Platform matrix
|
|
28
|
+
|
|
29
|
+
| Feature | iOS 13+ | Android API 31+ | Android API 21–30 |
|
|
30
|
+
|---|---|---|---|
|
|
31
|
+
| Backdrop blur | ✅ | ✅ | ✅ |
|
|
32
|
+
| Overlay tint | ✅ | ✅ | ✅ |
|
|
33
|
+
| Progressive blur | ✅ | ✅ | ❌ |
|
|
34
|
+
| Noise texture | ✅ | ✅ | ❌ |
|
|
35
|
+
| `blurType` | ✅ | ❌ | ❌ |
|
|
36
|
+
| `blurRadius` downsample | ❌ | ❌ | ✅ |
|
|
37
|
+
|
|
50
38
|
---
|
|
51
39
|
|
|
52
|
-
<details>
|
|
53
|
-
<summary><h3>Screenshots (Expand to see)</h3></summary>
|
|
54
|
-
<table>
|
|
55
|
-
<tr>
|
|
56
|
-
<td align="center"> <h3>Android</h3>
|
|
57
|
-
<img width="244" height="462" alt="Android-Demo" src="https://github.com/user-attachments/assets/e1cd120e-1ce1-4bba-aef1-4182aa023fbb" />
|
|
58
|
-
</td>
|
|
59
|
-
<td align="center"> <h3>iOS</h3>
|
|
60
|
-
<img width="244" height="462" alt="iPhone-Demo" src="https://github.com/user-attachments/assets/4b8ad035-d2ff-471e-b3e6-a645c87ea066" />
|
|
61
|
-
</td>
|
|
62
|
-
</tr>
|
|
63
|
-
</table>
|
|
64
|
-
</details>
|
|
65
|
-
|
|
66
40
|
## Installation
|
|
67
|
-
|
|
41
|
+
|
|
68
42
|
```sh
|
|
69
|
-
yarn add react-native-blur-vibe
|
|
70
|
-
# or
|
|
71
43
|
npm install react-native-blur-vibe
|
|
44
|
+
# or
|
|
45
|
+
yarn add react-native-blur-vibe
|
|
72
46
|
```
|
|
73
|
-
|
|
47
|
+
|
|
74
48
|
### iOS
|
|
75
|
-
|
|
49
|
+
|
|
76
50
|
```sh
|
|
77
51
|
cd ios && pod install
|
|
78
52
|
```
|
|
79
|
-
|
|
80
|
-
Minimum
|
|
81
|
-
|
|
53
|
+
|
|
54
|
+
Minimum deployment target: **iOS 13.0**
|
|
55
|
+
|
|
82
56
|
### Android
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
57
|
+
|
|
58
|
+
Minimum SDK: **API 21** (Android 5.0)
|
|
59
|
+
|
|
60
|
+
No extra configuration required. The package automatically picks the best blur engine for the running API level.
|
|
61
|
+
|
|
88
62
|
---
|
|
89
|
-
|
|
90
|
-
##
|
|
91
|
-
|
|
63
|
+
|
|
64
|
+
## Quick start
|
|
65
|
+
|
|
92
66
|
```tsx
|
|
93
67
|
import { BlurView } from 'react-native-blur-vibe';
|
|
94
|
-
import { StyleSheet, ImageBackground
|
|
95
|
-
|
|
96
|
-
export default function
|
|
68
|
+
import { StyleSheet, ImageBackground } from 'react-native';
|
|
69
|
+
|
|
70
|
+
export default function Card() {
|
|
97
71
|
return (
|
|
98
|
-
<ImageBackground source={require('./
|
|
99
|
-
{/* Pure blur — transparent overlay */}
|
|
100
|
-
<BlurView
|
|
101
|
-
blurAmount={15}
|
|
102
|
-
blurType="systemMaterial"
|
|
103
|
-
overlayColor="#00000000"
|
|
104
|
-
style={styles.blur}
|
|
105
|
-
/>
|
|
106
|
-
|
|
107
|
-
{/* Dark tinted blur — like a modal backdrop */}
|
|
72
|
+
<ImageBackground source={require('./bg.jpg')} style={styles.container}>
|
|
108
73
|
<BlurView
|
|
109
|
-
blurAmount={
|
|
110
|
-
overlayColor="#
|
|
111
|
-
style={
|
|
74
|
+
blurAmount={25}
|
|
75
|
+
overlayColor="#FFFFFF20"
|
|
76
|
+
style={StyleSheet.absoluteFill}
|
|
112
77
|
/>
|
|
113
|
-
|
|
114
|
-
{/* Frosted glass card */}
|
|
115
|
-
<BlurView
|
|
116
|
-
blurAmount={10}
|
|
117
|
-
blurType="systemUltraThinMaterialLight"
|
|
118
|
-
overlayColor="#FFFFFF25"
|
|
119
|
-
style={styles.card}
|
|
120
|
-
>
|
|
121
|
-
<Text style={styles.text}>Frosted Glass Card</Text>
|
|
122
|
-
</BlurView>
|
|
123
78
|
</ImageBackground>
|
|
124
79
|
);
|
|
125
80
|
}
|
|
126
|
-
|
|
127
|
-
const styles = StyleSheet.create({
|
|
128
|
-
image: { flex: 1 },
|
|
129
|
-
blur: { ...StyleSheet.absoluteFillObject },
|
|
130
|
-
card: {
|
|
131
|
-
margin: 20,
|
|
132
|
-
padding: 20,
|
|
133
|
-
borderRadius: 16,
|
|
134
|
-
},
|
|
135
|
-
text: { color: 'white', fontSize: 18 },
|
|
136
|
-
});
|
|
137
81
|
```
|
|
138
|
-
|
|
82
|
+
|
|
139
83
|
---
|
|
140
|
-
|
|
84
|
+
|
|
141
85
|
## Props
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
|
146
|
-
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
86
|
+
|
|
87
|
+
### `blurAmount`
|
|
88
|
+
|
|
89
|
+
| | |
|
|
90
|
+
|---|---|
|
|
91
|
+
| Type | `number` |
|
|
92
|
+
| Default | `10` |
|
|
93
|
+
| Platform | iOS + Android |
|
|
94
|
+
|
|
95
|
+
Blur intensity from `0` (no blur) to `100` (maximum blur).
|
|
96
|
+
|
|
97
|
+
Approximate CSS `backdrop-filter` equivalents:
|
|
98
|
+
|
|
99
|
+
| `blurAmount` | CSS equivalent | Visual feel |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `5` | `backdrop-blur-sm` (4px) | Subtle hint |
|
|
102
|
+
| `15` | `backdrop-blur` (8px) | Light glass |
|
|
103
|
+
| `25` | `backdrop-blur-md` (12px) | Standard card |
|
|
104
|
+
| `50` | `backdrop-blur-xl` (24px) | Heavy glass |
|
|
105
|
+
| `75` | `backdrop-blur-2xl` | Dense blur |
|
|
106
|
+
| `100` | `backdrop-blur-3xl` | Maximum |
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
<BlurView blurAmount={30} style={StyleSheet.absoluteFill} />
|
|
110
|
+
```
|
|
111
|
+
|
|
153
112
|
---
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
113
|
+
|
|
114
|
+
### `overlayColor`
|
|
115
|
+
|
|
116
|
+
| | |
|
|
117
|
+
|---|---|
|
|
118
|
+
| Type | `string` |
|
|
119
|
+
| Default | `"transparent"` (iOS) · `"#00000030"` (Android) |
|
|
120
|
+
| Platform | iOS + Android |
|
|
121
|
+
|
|
122
|
+
RGBA color composited **on top of** the blur. Equivalent to:
|
|
123
|
+
|
|
124
|
+
```css
|
|
125
|
+
backdrop-filter: blur(Xpx);
|
|
126
|
+
background-color: <overlayColor>;
|
|
157
127
|
```
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
128
|
+
|
|
129
|
+
The alpha channel controls how much blur shows through:
|
|
130
|
+
|
|
131
|
+
| Value | Effect |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `"#00000000"` | Transparent — pure blur, no tint |
|
|
134
|
+
| `"#00000040"` | 25% black tint — dark frosted glass |
|
|
135
|
+
| `"#FFFFFF30"` | 19% white tint — light frosted glass |
|
|
136
|
+
| `"#FF000080"` | 50% red tint |
|
|
137
|
+
| `"#000000FF"` | Fully opaque — blur hidden |
|
|
138
|
+
|
|
139
|
+
Supported formats: `"transparent"`, `"#RGB"`, `"#RRGGBB"`, `"#RRGGBBAA"`
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<BlurView blurAmount={20} overlayColor="#FFFFFF25" style={StyleSheet.absoluteFill} />
|
|
165
143
|
```
|
|
166
|
-
|
|
144
|
+
|
|
167
145
|
---
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
146
|
+
|
|
147
|
+
### `blurType`
|
|
148
|
+
|
|
149
|
+
| | |
|
|
150
|
+
|---|---|
|
|
151
|
+
| Type | `BlurType` |
|
|
152
|
+
| Default | `"light"` |
|
|
153
|
+
| Platform | **iOS only** — ignored on Android |
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
**Adaptive styles** (change with light/dark mode — recommended):
|
|
157
|
+
|
|
158
|
+
| Value | Description |
|
|
159
|
+
|---|---|
|
|
160
|
+
| `"light"` | Light frosted glass |
|
|
161
|
+
| `"dark"` | Dark frosted glass |
|
|
162
|
+
| `"extraLight"` | Brighter than light |
|
|
163
|
+
| `"regular"` | System default |
|
|
164
|
+
| `"prominent"` | Higher contrast |
|
|
165
|
+
| `"systemUltraThinMaterial"` | Thinnest, most transparent |
|
|
166
|
+
| `"systemThinMaterial"` | Thin material |
|
|
167
|
+
| `"systemMaterial"` | Medium — iOS sheet background |
|
|
168
|
+
| `"systemThickMaterial"` | Thick material |
|
|
169
|
+
| `"systemChromeMaterial"` | For toolbars / nav bars |
|
|
170
|
+
|
|
171
|
+
Also available: `Light` and `Dark` suffixed variants (e.g. `"systemMaterialDark"`) for explicit mode control. See `BlurType` in types for the full list.
|
|
172
|
+
|
|
173
|
+
❗On Android, use `overlayColor` to control the tint instead.
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
<BlurView blurType="systemMaterial" blurAmount={100} style={StyleSheet.absoluteFill} />
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### `reducedTransparencyFallbackColor`
|
|
182
|
+
|
|
183
|
+
| | |
|
|
184
|
+
|---|---|
|
|
185
|
+
| Type | `string` |
|
|
186
|
+
| Default | `"#F2F2F2"` |
|
|
187
|
+
| Platform | iOS + Android |
|
|
188
|
+
|
|
189
|
+
Solid color shown when blur is unavailable:
|
|
190
|
+
- **iOS**: User enabled *Settings → Accessibility → Display & Text Size → Reduce Transparency*
|
|
191
|
+
- **Android**: Device API level < 21
|
|
192
|
+
|
|
193
|
+
Should provide sufficient contrast without the blur. Use a semi-opaque version of your background color.
|
|
194
|
+
|
|
172
195
|
```tsx
|
|
173
196
|
<BlurView
|
|
174
|
-
blurAmount={
|
|
175
|
-
|
|
197
|
+
blurAmount={20}
|
|
198
|
+
reducedTransparencyFallbackColor="#1C1C1ECC"
|
|
176
199
|
style={StyleSheet.absoluteFill}
|
|
177
200
|
/>
|
|
178
201
|
```
|
|
179
|
-
|
|
180
|
-
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### `blurRadius`
|
|
206
|
+
|
|
207
|
+
| | |
|
|
208
|
+
|---|---|
|
|
209
|
+
| Type | `number` (integer 1–8) |
|
|
210
|
+
| Default | `4` |
|
|
211
|
+
| Platform | **Android API < 31 only** — ignored on API 31+ and iOS |
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
| Value | Pixels captured | Quality | Speed |
|
|
215
|
+
|---|---|---|---|
|
|
216
|
+
| `1` | Full res | Sharpest | Slowest |
|
|
217
|
+
| `4` | 1/16 (default) | Good | Fast |
|
|
218
|
+
| `8` | 1/64 | Softer | Fastest |
|
|
219
|
+
|
|
220
|
+
On **Android API 31+** the blur runs at full resolution on the GPU — this prop has no effect.
|
|
221
|
+
|
|
181
222
|
```tsx
|
|
223
|
+
<BlurView blurAmount={20} blurRadius={4} style={StyleSheet.absoluteFill} />
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### `progressiveBlurDirection`
|
|
229
|
+
|
|
230
|
+
| | |
|
|
231
|
+
|---|---|
|
|
232
|
+
| Type | `ProgressiveBlurDirection` |
|
|
233
|
+
| Default | `"none"` |
|
|
234
|
+
| Platform | **iOS + Android API 31+** — Android API < 31 shows uniform blur |
|
|
235
|
+
|
|
236
|
+
Direction the blur intensity fades across the view.
|
|
237
|
+
|
|
238
|
+
| Value | Blur starts at | Fades towards |
|
|
239
|
+
|---|---|---|
|
|
240
|
+
| `"none"` | — uniform blur — | — |
|
|
241
|
+
| `"topToBottom"` | Top edge | Bottom edge |
|
|
242
|
+
| `"bottomToTop"` | Bottom edge | Top edge |
|
|
243
|
+
| `"leftToRight"` | Left edge | Right edge |
|
|
244
|
+
| `"rightToLeft"` | Right edge | Left edge |
|
|
245
|
+
| `"radial"` | Center | Outer edges |
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
// Sticky header — full blur at top, fades to nothing at bottom
|
|
182
250
|
<BlurView
|
|
183
|
-
blurAmount={
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
251
|
+
blurAmount={40}
|
|
252
|
+
progressiveBlurDirection="topToBottom"
|
|
253
|
+
progressiveStartIntensity={1}
|
|
254
|
+
progressiveEndIntensity={0}
|
|
255
|
+
style={StyleSheet.absoluteFill}
|
|
187
256
|
/>
|
|
188
257
|
```
|
|
189
|
-
|
|
190
|
-
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
### `progressiveStartIntensity`
|
|
262
|
+
|
|
263
|
+
| | |
|
|
264
|
+
|---|---|
|
|
265
|
+
| Type | `number` (0.0–1.0) |
|
|
266
|
+
| Default | `1.0` |
|
|
267
|
+
| Platform | **iOS + Android API 31+** |
|
|
268
|
+
|
|
269
|
+
Blur intensity at the **start** of the gradient direction.
|
|
270
|
+
|
|
271
|
+
- `1.0` — full blur at `blurAmount` intensity
|
|
272
|
+
- `0.0` — completely transparent / no blur
|
|
273
|
+
|
|
274
|
+
"Start" depends on `progressiveBlurDirection`:
|
|
275
|
+
- `"topToBottom"` → top edge
|
|
276
|
+
- `"bottomToTop"` → bottom edge
|
|
277
|
+
- `"leftToRight"` → left edge
|
|
278
|
+
- `"rightToLeft"` → right edge
|
|
279
|
+
- `"radial"` → center
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
### `progressiveEndIntensity`
|
|
284
|
+
|
|
285
|
+
| | |
|
|
286
|
+
|---|---|
|
|
287
|
+
| Type | `number` (0.0–1.0) |
|
|
288
|
+
| Default | `0.0` |
|
|
289
|
+
| Platform | **iOS + Android API 31+** |
|
|
290
|
+
|
|
291
|
+
Blur intensity at the **end** of the gradient direction.
|
|
292
|
+
|
|
293
|
+
"End" is the opposite edge/point from `progressiveStartIntensity`.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
### `noiseFactor`
|
|
298
|
+
|
|
299
|
+
| | |
|
|
300
|
+
|---|---|
|
|
301
|
+
| Type | `number` (0.0–1.0) |
|
|
302
|
+
| Default | `0.08` |
|
|
303
|
+
| Platform | **iOS + Android API 31+** — Android API < 31 silently ignores |
|
|
304
|
+
|
|
305
|
+
Noise grain overlay strength. Adds a subtle static grain texture on top of the blur, mimicking the micro-texture of real ground glass and making the blur feel more physical and premium.
|
|
306
|
+
|
|
307
|
+
| Value | Effect |
|
|
308
|
+
|---|---|
|
|
309
|
+
| `0` | No noise — clean digital blur |
|
|
310
|
+
| `0.08` | Subtle, barely perceptible (default) |
|
|
311
|
+
| `0.15` | Noticeable grain (Haze library default) |
|
|
312
|
+
| `0.30` | Heavy grain |
|
|
313
|
+
|
|
191
314
|
```tsx
|
|
315
|
+
<BlurView blurAmount={50} noiseFactor={0.12} style={StyleSheet.absoluteFill} />
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Usage examples
|
|
321
|
+
|
|
322
|
+
### Basic frosted glass card
|
|
323
|
+
|
|
324
|
+
```tsx
|
|
325
|
+
import { BlurView } from 'react-native-blur-vibe';
|
|
326
|
+
import { StyleSheet, View, Text, ImageBackground } from 'react-native';
|
|
327
|
+
|
|
328
|
+
function FrostedCard() {
|
|
329
|
+
return (
|
|
330
|
+
<ImageBackground source={require('./bg.jpg')} style={styles.bg}>
|
|
331
|
+
<View style={styles.card}>
|
|
332
|
+
<BlurView
|
|
333
|
+
blurAmount={30}
|
|
334
|
+
overlayColor="#FFFFFF20"
|
|
335
|
+
noiseFactor={0.1}
|
|
336
|
+
style={StyleSheet.absoluteFill}
|
|
337
|
+
/>
|
|
338
|
+
<Text style={styles.title}>Hello</Text>
|
|
339
|
+
</View>
|
|
340
|
+
</ImageBackground>
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Sticky header with progressive blur
|
|
346
|
+
|
|
347
|
+
```tsx
|
|
348
|
+
// Full blur at top, fades to nothing — used by iOS App Library, Spotlight
|
|
192
349
|
<BlurView
|
|
193
|
-
blurAmount={
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
{
|
|
199
|
-
|
|
350
|
+
blurAmount={40}
|
|
351
|
+
overlayColor="#00000020"
|
|
352
|
+
progressiveBlurDirection="topToBottom"
|
|
353
|
+
progressiveStartIntensity={1}
|
|
354
|
+
progressiveEndIntensity={0}
|
|
355
|
+
style={[StyleSheet.absoluteFill, { height: 120 }]}
|
|
356
|
+
/>
|
|
200
357
|
```
|
|
201
|
-
|
|
202
|
-
###
|
|
358
|
+
|
|
359
|
+
### Bottom sheet scrim
|
|
360
|
+
|
|
361
|
+
```tsx
|
|
362
|
+
// No blur at top, full blur at bottom — bottom sheet background
|
|
363
|
+
<BlurView
|
|
364
|
+
blurAmount={50}
|
|
365
|
+
overlayColor="#00000040"
|
|
366
|
+
progressiveBlurDirection="bottomToTop"
|
|
367
|
+
progressiveStartIntensity={1}
|
|
368
|
+
progressiveEndIntensity={0}
|
|
369
|
+
style={StyleSheet.absoluteFill}
|
|
370
|
+
/>
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Music player card (dark frosted glass)
|
|
374
|
+
|
|
203
375
|
```tsx
|
|
204
376
|
<BlurView
|
|
205
|
-
blurAmount={
|
|
377
|
+
blurAmount={60}
|
|
378
|
+
blurType="systemMaterial" // iOS: system material
|
|
379
|
+
overlayColor="#00000050" // Android: dark tint
|
|
380
|
+
noiseFactor={0.12}
|
|
381
|
+
style={StyleSheet.absoluteFill}
|
|
382
|
+
/>
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Pure blur, no tint
|
|
386
|
+
|
|
387
|
+
```tsx
|
|
388
|
+
// Maximum blur, fully transparent overlay
|
|
389
|
+
<BlurView
|
|
390
|
+
blurAmount={50}
|
|
206
391
|
overlayColor="#00000000"
|
|
207
392
|
style={StyleSheet.absoluteFill}
|
|
208
393
|
/>
|
|
209
394
|
```
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
## Architecture support
|
|
214
|
-
|
|
215
|
-
| Architecture | iOS | Android |
|
|
216
|
-
|---|---|---|
|
|
217
|
-
| Old Architecture (JSC/Bridge) | ✅ | ✅ |
|
|
218
|
-
| New Architecture (Fabric/JSI) | ✅ | ✅ |
|
|
219
|
-
| Expo (bare workflow) | ✅ | ✅ |
|
|
220
|
-
| Expo Go | ❌ (native module) | ❌ |
|
|
221
|
-
|
|
222
|
-
---
|
|
223
|
-
|
|
224
|
-
## Android API compatibility
|
|
225
|
-
|
|
226
|
-
| Android API | Blur Method | Notes |
|
|
227
|
-
|---|---|---|
|
|
228
|
-
| 31+ (Android 12) | `RenderEffect` | Hardware accelerated, best quality |
|
|
229
|
-
| 21–30 | `RenderScript` | Bitmap-based, `blurRadius` tunable |
|
|
230
|
-
| < 21 | `reducedTransparencyFallbackColor` | Solid color only |
|
|
231
|
-
|
|
232
|
-
---
|
|
233
395
|
|
|
234
|
-
|
|
396
|
+
### Inside a Modal
|
|
235
397
|
|
|
236
|
-
|
|
398
|
+
Works out of the box — the blur root is automatically scoped to the nearest `Screen` or `ReactRootView`.
|
|
237
399
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
400
|
+
```tsx
|
|
401
|
+
<Modal visible={visible} transparent>
|
|
402
|
+
<BlurView
|
|
403
|
+
blurAmount={20}
|
|
404
|
+
overlayColor="#00000060"
|
|
405
|
+
style={StyleSheet.absoluteFill}
|
|
406
|
+
/>
|
|
407
|
+
<View style={styles.content}>{/* content */}</View>
|
|
408
|
+
</Modal>
|
|
409
|
+
```
|
|
241
410
|
|
|
242
|
-
|
|
411
|
+
### Inside FlatList / FlashList cards
|
|
243
412
|
|
|
244
|
-
|
|
413
|
+
```tsx
|
|
414
|
+
<FlatList
|
|
415
|
+
data={items}
|
|
416
|
+
renderItem={({ item }) => (
|
|
417
|
+
<ImageBackground source={{ uri: item.image }} style={styles.card}>
|
|
418
|
+
<BlurView
|
|
419
|
+
blurAmount={20}
|
|
420
|
+
overlayColor="#FFFFFF15"
|
|
421
|
+
style={StyleSheet.absoluteFill}
|
|
422
|
+
/>
|
|
423
|
+
<Text>{item.title}</Text>
|
|
424
|
+
</ImageBackground>
|
|
425
|
+
)}
|
|
426
|
+
/>
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## TypeScript
|
|
430
|
+
|
|
431
|
+
Full TypeScript support with detailed JSDoc on every prop.
|
|
432
|
+
|
|
433
|
+
```ts
|
|
434
|
+
import type { BlurViewProps, BlurType, ProgressiveBlurDirection } from 'react-native-blur-vibe';
|
|
435
|
+
```
|
|
245
436
|
|
|
246
437
|
---
|
|
247
438
|
|
|
248
|
-
|
|
439
|
+
## License
|
|
440
|
+
|
|
441
|
+
MIT ©[Pritam Nanda](https://github.com/I-am-Pritam-20)
|
|
@@ -41,10 +41,12 @@ class BlurVibeView(context: Context) : BlurViewGroup(context, null) {
|
|
|
41
41
|
private const val MAX_BLUR_AMOUNT = 100f
|
|
42
42
|
private const val MAX_BLUR_RADIUS = 25f // QmBlurView Gaussian kernel designed for 0-25
|
|
43
43
|
|
|
44
|
-
// Maps 0–100 blurAmount to 0–25 QmBlurView radius range
|
|
44
|
+
// Maps 0–100 blurAmount to 0–25 QmBlurView radius range.
|
|
45
|
+
// Uses a squared curve so low values (0–30) stay subtle and mid-high values
|
|
46
|
+
// (50–100) produce the strong frosted-glass spread seen in CSS backdrop-blur-md/lg/xl.
|
|
45
47
|
private fun mapBlurAmountToRadius(amount: Float): Float {
|
|
46
|
-
val
|
|
47
|
-
return
|
|
48
|
+
val t = amount.coerceIn(MIN_BLUR_AMOUNT, MAX_BLUR_AMOUNT) / MAX_BLUR_AMOUNT // 0.0–1.0
|
|
49
|
+
return t * t * MAX_BLUR_RADIUS // quadratic: more spread at higher values
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -52,8 +54,8 @@ class BlurVibeView(context: Context) : BlurViewGroup(context, null) {
|
|
|
52
54
|
super.setBackgroundColor(currentOverlayColor)
|
|
53
55
|
clipChildren = true
|
|
54
56
|
clipToOutline = true
|
|
55
|
-
blurRounds =
|
|
56
|
-
super.setDownsampleFactor(
|
|
57
|
+
blurRounds = 2 // 2 passes = smooth Gaussian spread (frosted glass quality)
|
|
58
|
+
super.setDownsampleFactor(4.0f) // 1/4 res — eliminates pixelation, still fast
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
override fun onAttachedToWindow() {
|