Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@mythologi/react-native-blur
Advanced tools
Mythologi-XR/react-native-blur
A component for UIVisualEffectView's blur and vibrancy effect on iOS, and BlurView on Android.
yarn add @react-native-community/blur
or npm:
npm install --save @react-native-community/blur
react-native link @react-native-community/blur
npx pod-install
Or, if you already have installed Cocoapods on your system:
cd ios && pod install
build.gradle
, this library will detect the presence of the following properties:buildscript {...}
allprojects {...}
/**
+ Project-wide Gradle configuration properties
*/
ext {
compileSdkVersion = 27
targetSdkVersion = 27
buildToolsVersion = "27.0.3"
}
import { BlurView, VibrancyView } from '@react-native-community/blur'
Properties:
blurType
(String)
xlight
- extra light blur typelight
- light blur typedark
- dark blur typeextraDark
- extra dark blur type (tvOS only)regular
- regular blur type (iOS 10+ and tvOS only)prominent
- prominent blur type (iOS 10+ and tvOS only)chromeMaterial
- An adaptable blur effect that creates the appearance of the system chrome.material
- An adaptable blur effect that creates the appearance of a material with normal thickness.thickMaterial
- An adaptable blur effect that creates the appearance of a material that is thicker than normal.thinMaterial
- An adaptable blur effect that creates the appearance of an ultra-thin material.ultraThinMaterial
- An adaptable blur effect that creates the appearance of an ultra-thin material.chromeMaterialDark
- A blur effect that creates the appearance of an ultra-thin material and is always dark.materialDark
- A blur effect that creates the appearance of a thin material and is always dark.thickMaterialDark
- A blur effect that creates the appearance of a material with normal thickness and is always dark.thinMaterialDark
- A blur effect that creates the appearance of a material that is thicker than normal and is always dark.ultraThinMaterialDark
- A blur effect that creates the appearance of the system chrome and is always dark.chromeMaterialLight
- An adaptable blur effect that creates the appearance of the system chrome.materialLight
- An adaptable blur effect that creates the appearance of a material with normal thickness.thickMaterialLight
- An adaptable blur effect that creates the appearance of a material that is thicker than normal.thinMaterialLight
- An adaptable blur effect that creates the appearance of a thin material.ultraThinMaterialLight
- An adaptable blur effect that creates the appearance of an ultra-thin material.blurAmount
(Default: 10, Number)
0-100
- Adjusts blur intensityreducedTransparencyFallbackColor
(Color) (iOS only)
black, white, #rrggbb, etc
- background color to use if accessibility setting ReduceTransparency is enabledNote: The maximum
blurAmount
on Android is 32, so higher values will be clamped to 32.
Complete usage example that works on iOS and Android:
import React, { Component } from 'react'
import { View, Image, Text, StyleSheet } from 'react-native'
import { BlurView } from '@react-native-community/blur'
export default class Menu extends Component {
render() {
return (
<View style={styles.container}>
<Image key={'blurryImage'} source={{ uri }} style={styles.absolute} />
<Text style={styles.absolute}>Hi, I am some blurred text</Text>
{/* in terms of positioning and zIndex-ing everything before the BlurView will be blurred */}
<BlurView
style={styles.absolute}
blurType="light"
blurAmount={10}
reducedTransparencyFallbackColor="white"
/>
<Text>I'm the non blurred text because I got rendered on top of the BlurView</Text>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
justifyContent: 'center',
alignItems: 'center',
},
absolute: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
},
})
In this example, the Image
component will be blurred, because the BlurView
in positioned on top. But the Text
will stay unblurred.
If the accessibility setting Reduce Transparency
is enabled the BlurView
will use reducedTransparencyFallbackColor
as it's background color rather than blurring. If no reducedTransparencyFallbackColor
is provided, theBlurView
will use the default fallback color (white, black, or grey depending on blurType
)
Uses the same properties as BlurView
(blurType
, blurAmount
, and reducedTransparencyFallbackColor
).
The vibrancy effect lets the content underneath a blurred view show through more vibrantly
(Note:
VibrancyView
is only supported on iOS. Also note that theVibrancyView
must contain nested views.)
import { VibrancyView } from '@react-native-community/blur'
export default class Menu extends Component {
render() {
return (
<Image source={{ uri }} style={styles.absolute}>
<VibrancyView blurType="light" style={styles.flex}>
<Text>Hi, I am some vibrant text.</Text>
</VibrancyView>
</Image>
)
}
}
Android uses the BlurView.
If you only need to support iOS, then you can safely ignore these limitations.
In addition to blurType
and blurAmount
, Android has some extra props that can be used to override the default behavior (or configure Android-specific behavior):
blurRadius
(Number - between 0 and 25) - Manually adjust the blur radius. (Default: matches iOS blurAmount)downsampleFactor
(Number - between 0 and 25) - Scales down the image before blurring (Default: matches iOS blurAmount)overlayColor
(Color) - Set a custom overlay color (Default color based on iOS blurType)This project includes an example React Native app, which was used to make the GIF in this README. You can run the apps by following these steps:
git clone https://github.com/Mythologi-XR/react-native-blur.git
example
cd react-native-blur/example
npm install
react-native run-ios
react-native run-android
Feel free to create an issue.
FAQs
React Native Blur component
The npm package @mythologi/react-native-blur receives a total of 0 weekly downloads. As such, @mythologi/react-native-blur popularity was classified as not popular.
We found that @mythologi/react-native-blur demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.