React Native Blur component
Go to file
yqrashawn 6342461049
chore: add compiled lib folder, don't rely on package.json hooks
2023-02-16 15:07:15 +08:00
.vscode refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
android Update build.gradle 2023-01-14 02:53:39 +05:30
example Allow transparent blur-type for ios 2023-01-16 03:01:34 +05:30
ios Allow transparent blur-type for ios 2023-01-16 03:01:34 +05:30
lib chore: add compiled lib folder, don't rely on package.json hooks 2023-02-16 15:07:15 +08:00
scripts refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
src Allow transparent blur-type for ios 2023-01-16 03:01:34 +05:30
.editorconfig refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
.gitattributes refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
.gitignore refactor: migrate example app to use RNTA (#484) 2022-07-29 12:23:36 +02:00
.watchmanconfig Rebuild react-native-blur for RN-0.11.4 2015-10-05 22:42:23 +02:00
.yarnrc refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
CONTRIBUTING.md refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
LICENSE refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
README.md Allow transparent blur-type for ios 2023-01-16 03:01:34 +05:30
babel.config.js refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
lefthook.yml refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
package.json chore: release 4.3.0 2022-11-03 17:55:13 +01:00
react-native-blur.podspec feat: Add Fabric support (#493) 2022-11-03 17:50:33 +01:00
tsconfig.build.json refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
tsconfig.json refactor: typescript, hooks, build.gradle & podspec fixes and moved to bob (#476) 2022-07-21 13:19:30 +02:00
yarn.lock feat: Add Fabric support (#493) 2022-11-03 17:50:33 +01:00

README.md

@react-native-community/blur

npm version

A component for UIVisualEffectView's blur and vibrancy effect on iOS, and BlurView on Android.

Current Maintainers:

Content

Installation

yarn add @react-native-community/blur

Install native dependencies (iOS only):

cd ios && pod install

Usage

BlurView

Property Possible Values Default Platform
blurType See blurType below - All
blurAmount 0 - 100 (The maximum blurAmount on Android is 32, so higher values will be clamped to 32) 10 All
reducedTransparencyFallbackColor Any color - iOS only
blurRadius 0 - 25 Matches iOS blurAmount Android only
downsampleFactor 0 - 25 Matches iOS blurAmount Android only
overlayColor Any color Default color based on iOS blurType Android only

blurType

Name Description
xlight extra light blur type
light light blur type
dark dark blur type
extraDark extra dark blur type (tvOS only)
regular regular blur type (iOS 10+ and tvOS only)
prominent prominent blur type (iOS 10+ and tvOS only)
transparent transparent blur type (iOS 10+ and tvOS only)

blurType (iOS 13 only)

Name Description
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.
chromeMaterial An adaptable blur effect that creates the appearance of the system chrome.
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.

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 function Menu() {
  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, theBlurViewwill use the default fallback color (white, black, or grey depending on blurType)

VibrancyView

Uses the same properties as BlurView (blurType, blurAmount, and reducedTransparencyFallbackColor).

The vibrancy effect lets the content underneath a blurred view show through more vibrantly

VibrancyView is only supported on iOS. Also note that the VibrancyView must contain nested views

import { VibrancyView } from "@react-native-community/blur";

export default function Menu() {
  return (
    <Image source={{ uri }} style={styles.absolute}>
      <VibrancyView blurType="light" style={styles.flex}>
      <Text>Hi, I am some vibrant text.</Text>
      </VibrancyView>
    </Image>
  )
}

Example React Native App

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:

Clone the repository

git clone https://github.com/react-native-community/react-native-blur.git

Install dependencies

yarn

Run the app

yarn example android/ios

Questions?

Feel free to create an issue