Convert Figma logo to code with AI

Kureev logoreact-native-blur

React Native Blur component

3,817
565
3,817
230

Top Related Projects

A <LinearGradient /> component for react-native

SVG library for React Native, React Native Web, and plain React web projects.

React Native Cross-Platform WebView

A Camera component for React Native. Also supports barcode scanning!

React Native Mapview component for iOS + Android

Quick Overview

React-Native-Blur is a component library for React Native that provides customizable blur effects for iOS and Android applications. It allows developers to easily add blurred backgrounds or overlays to their React Native components, enhancing the visual appeal and depth of their user interfaces.

Pros

  • Easy integration with existing React Native projects
  • Supports both iOS and Android platforms
  • Offers various blur types and customization options
  • Provides good performance with native implementations

Cons

  • Limited documentation and examples
  • Some reported issues with compatibility on certain Android devices
  • Requires linking native dependencies, which can be challenging for some developers
  • May not work with Expo managed workflow without ejecting

Code Examples

  1. Basic blur view:
import { BlurView } from '@react-native-community/blur';

const MyComponent = () => (
  <BlurView
    style={styles.absolute}
    blurType="light"
    blurAmount={10}
  />
);
  1. Blurred background with content:
import { BlurView } from '@react-native-community/blur';

const MyComponent = () => (
  <BlurView
    style={styles.container}
    blurType="dark"
    blurAmount={5}
  >
    <Text style={styles.text}>Content on top of blur</Text>
  </BlurView>
);
  1. Dynamic blur amount:
import React, { useState } from 'react';
import { BlurView } from '@react-native-community/blur';
import { Slider } from 'react-native';

const MyComponent = () => {
  const [blurAmount, setBlurAmount] = useState(10);

  return (
    <BlurView
      style={styles.container}
      blurType="light"
      blurAmount={blurAmount}
    >
      <Slider
        value={blurAmount}
        onValueChange={setBlurAmount}
        minimumValue={0}
        maximumValue={25}
      />
    </BlurView>
  );
};

Getting Started

  1. Install the package:

    npm install @react-native-community/blur
    
  2. Link native dependencies:

    npx react-native link @react-native-community/blur
    
  3. Import and use in your React Native component:

    import { BlurView } from '@react-native-community/blur';
    
    const MyComponent = () => (
      <BlurView
        style={styles.absolute}
        blurType="light"
        blurAmount={10}
      />
    );
    
  4. For iOS, add the following to your Podfile:

    pod 'RNBlur', :path => '../node_modules/@react-native-community/blur'
    

    Then run pod install in your iOS folder.

Competitor Comparisons

A <LinearGradient /> component for react-native

Pros of react-native-linear-gradient

  • More actively maintained with recent updates and releases
  • Supports a wider range of gradient types (linear, radial, and angular)
  • Better documentation and examples provided in the README

Cons of react-native-linear-gradient

  • Limited to gradient effects, while react-native-blur offers blur effects
  • Slightly larger package size due to additional gradient features
  • May require more setup for certain gradient types

Code Comparison

react-native-linear-gradient:

import LinearGradient from 'react-native-linear-gradient';

<LinearGradient
  colors={['#4c669f', '#3b5998', '#192f6a']}
  style={styles.linearGradient}
>
  <Text style={styles.buttonText}>Sign in with Facebook</Text>
</LinearGradient>

react-native-blur:

import { BlurView } from '@react-native-community/blur';

<BlurView
  style={styles.absolute}
  blurType="light"
  blurAmount={10}
  reducedTransparencyFallbackColor="white"
/>

Both libraries offer easy-to-use components for enhancing UI effects in React Native applications. react-native-linear-gradient provides more options for gradient effects, while react-native-blur focuses on blur effects. The choice between the two depends on the specific visual requirements of your project.

SVG library for React Native, React Native Web, and plain React web projects.

Pros of react-native-svg

  • More comprehensive SVG support, allowing for complex vector graphics
  • Active development and maintenance, with frequent updates
  • Larger community and better documentation

Cons of react-native-svg

  • Larger package size due to more extensive features
  • Steeper learning curve for basic use cases
  • May require more setup and configuration

Code Comparison

react-native-svg:

import Svg, { Circle, Rect } from 'react-native-svg';

<Svg height="100" width="100">
  <Rect x="0" y="0" width="100" height="100" fill="black" />
  <Circle cx="50" cy="50" r="30" fill="yellow" />
</Svg>

react-native-blur:

import { BlurView } from 'react-native-blur';

<BlurView
  style={styles.absolute}
  blurType="light"
  blurAmount={10}
/>

While react-native-svg focuses on rendering vector graphics, react-native-blur is specifically designed for creating blur effects. react-native-svg offers more flexibility for creating complex graphics, while react-native-blur provides a simpler API for adding blur effects to existing components. The choice between the two depends on the specific requirements of your project, with react-native-svg being more suitable for general-purpose vector graphics and react-native-blur being ideal for quick and easy blur effects.

React Native Cross-Platform WebView

Pros of react-native-webview

  • More comprehensive functionality for web content rendering
  • Actively maintained with frequent updates
  • Extensive documentation and community support

Cons of react-native-webview

  • Larger package size and potential performance overhead
  • May require additional configuration for complex use cases
  • Not specifically optimized for blur effects

Code Comparison

react-native-webview:

import { WebView } from 'react-native-webview';

<WebView
  source={{ uri: 'https://example.com' }}
  style={{ flex: 1 }}
/>

react-native-blur:

import { BlurView } from 'react-native-blur';

<BlurView
  style={styles.absolute}
  blurType="light"
  blurAmount={10}
/>

Summary

react-native-webview is a more versatile solution for rendering web content within React Native apps, offering extensive features and ongoing support. However, it may introduce additional complexity and performance considerations compared to the more focused react-native-blur library.

react-native-blur provides a simpler, more lightweight approach specifically for creating blur effects, which can be advantageous for projects primarily concerned with UI aesthetics rather than web content rendering.

The choice between these libraries depends on the specific requirements of your project, with react-native-webview being better suited for comprehensive web integration, while react-native-blur excels in creating efficient blur effects for UI elements.

A Camera component for React Native. Also supports barcode scanning!

Pros of react-native-camera

  • More comprehensive camera functionality, including features like face detection and barcode scanning
  • Active development with frequent updates and bug fixes
  • Extensive documentation and community support

Cons of react-native-camera

  • Larger package size due to its extensive feature set
  • More complex setup and configuration process
  • May require additional permissions and setup for advanced features

Code Comparison

react-native-camera:

import { RNCamera } from 'react-native-camera';

<RNCamera
  style={styles.preview}
  type={RNCamera.Constants.Type.back}
  flashMode={RNCamera.Constants.FlashMode.on}
  androidCameraPermissionOptions={{
    title: 'Permission to use camera',
    message: 'We need your permission to use your camera',
    buttonPositive: 'Ok',
    buttonNegative: 'Cancel',
  }}
/>

react-native-blur:

import { BlurView } from 'react-native-blur';

<BlurView
  style={styles.absolute}
  blurType="light"
  blurAmount={10}
  reducedTransparencyFallbackColor="white"
/>

The code comparison shows that react-native-camera offers more camera-specific options and permissions handling, while react-native-blur focuses on applying blur effects to views. react-native-camera is better suited for applications requiring advanced camera functionality, whereas react-native-blur is ideal for UI enhancements and visual effects.

React Native Mapview component for iOS + Android

Pros of react-native-maps

  • More comprehensive mapping solution with advanced features like custom markers, polylines, and polygons
  • Active development and maintenance with frequent updates and bug fixes
  • Extensive documentation and community support

Cons of react-native-maps

  • Larger package size and potentially higher resource usage
  • More complex setup process, especially for iOS
  • May require additional configuration for certain map providers

Code Comparison

react-native-maps:

import MapView, { Marker } from 'react-native-maps';

<MapView
  initialRegion={{
    latitude: 37.78825,
    longitude: -122.4324,
    latitudeDelta: 0.0922,
    longitudeDelta: 0.0421,
  }}
>
  <Marker coordinate={{ latitude: 37.78825, longitude: -122.4324 }} />
</MapView>

react-native-blur:

import { BlurView } from 'react-native-blur';

<BlurView
  style={styles.absolute}
  blurType="light"
  blurAmount={10}
>
  <Text>I'm blurred!</Text>
</BlurView>

While react-native-maps provides a full-featured mapping solution, react-native-blur focuses on creating blur effects for UI elements. The choice between these libraries depends on the specific requirements of your project. If you need mapping functionality, react-native-maps is the clear choice. However, if you're looking to add visual blur effects to your app's interface, react-native-blur would be more suitable.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

@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

PropertyPossible ValuesDefaultPlatform
blurTypeSee blurType below-All
blurAmount0 - 100 (The maximum blurAmount on Android is 32, so higher values will be clamped to 32)10All
reducedTransparencyFallbackColorAny color-iOS only
blurRadius0 - 25Matches iOS blurAmountAndroid only
downsampleFactor0 - 25Matches iOS blurAmountAndroid only
overlayColorAny colorDefault color based on iOS blurTypeAndroid only

blurType

NameDescription
xlightextra light blur type
lightlight blur type
darkdark blur type
extraDarkextra dark blur type (tvOS only)
regularregular blur type (iOS 10+ and tvOS only)
prominentprominent blur type (iOS 10+ and tvOS only)

blurType (iOS 13 only)

NameDescription
chromeMaterialAn adaptable blur effect that creates the appearance of the system chrome.
materialAn adaptable blur effect that creates the appearance of a material with normal thickness.
thickMaterialAn adaptable blur effect that creates the appearance of a material that is thicker than normal.
chromeMaterialAn adaptable blur effect that creates the appearance of the system chrome.
thinMaterialAn adaptable blur effect that creates the appearance of an ultra-thin material.
ultraThinMaterialAn adaptable blur effect that creates the appearance of an ultra-thin material.
chromeMaterialDarkA blur effect that creates the appearance of an ultra-thin material and is always dark.
materialDarkA blur effect that creates the appearance of a thin material and is always dark.
thickMaterialDarkA blur effect that creates the appearance of a material with normal thickness and is always dark.
thinMaterialDarkA blur effect that creates the appearance of a material that is thicker than normal and is always dark.
ultraThinMaterialDarkA blur effect that creates the appearance of the system chrome and is always dark.
chromeMaterialLightAn adaptable blur effect that creates the appearance of the system chrome.
materialLightAn adaptable blur effect that creates the appearance of a material with normal thickness.
thickMaterialLightAn adaptable blur effect that creates the appearance of a material that is thicker than normal.
thinMaterialLightAn adaptable blur effect that creates the appearance of a thin material.
ultraThinMaterialLightAn 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

NPM DownloadsLast 30 Days