Logo

dev-resources.site

for different kinds of informations.

How to Add Blurred Text in React Native

Published at
2/15/2024
Categories
reactnative
blur
expo
text
Author
tgmarinhodev
Categories
4 categories in total
reactnative
open
blur
open
expo
open
text
open
Author
12 person written this
tgmarinhodev
open
How to Add Blurred Text in React Native

If you're looking for a stylish way to hide certain information in your React Native app, adding blurred text can be a visually appealing solution. In this tutorial, I'll show you how to integrate blurred text into your components using React Native easily.

Step 1: Installation

Depending on your development environment, you may need to install the expo-blur package if you're using Expo or react-native-blur for standard React Native projects. You can do this by running the following command:



yarn add expo-blur


Enter fullscreen mode Exit fullscreen mode

or



yarn add react-native-blur
cd ios && pod-install



Enter fullscreen mode Exit fullscreen mode

Step 2: Creating the Component

Let's start by creating a component called Blurred. This component will accept two optional parameters: intensity and tint. You can use the following code:



import { ReactNode } from 'react'
import { BlurView } from 'expo-blur' // or 'react-native-blur' for React Native projects
import { View } from 'native-base'

type BlurredProps = {
  intensity?: number
  tint?: 'light' | 'dark'
  children: ReactNode
}

export const Blurred = ({ intensity = 8, tint = 'light', children }: BlurredProps) => {
  return (
    <View>
      {children}
      <BlurView
        intensity={intensity}
        tint={tint}
        style={{
          position: 'absolute',
          width: '100%',
          height: '100%',
        }}
      />
    </View>
  )
}



Enter fullscreen mode Exit fullscreen mode

Step 3: Adding it to Your Logic

Now, you can use the Blurred component in your logic as follows:



 const Promotion = () => {
  if (!userCanSeePromo) {
    return (
      <Blurred>
        <Typography variant='body1' color='gray.500'>
          {item.promo}
        </Typography>
      </Blurred>
    )
  }

  return (
    <Typography variant='body1' color='gray.500'>
      {item.full_price}
    </Typography>
  )
}



Enter fullscreen mode Exit fullscreen mode

Feel free to adjust the intensity and tint as needed. This will give you a visually appealing effect like the one shown in the image provided.

You will have something like this:

Image description

I used it three times in this card to hide some pieces of information.

You can use it with react-native or even with native-base ui. In my project, I'm using native-base and it works perfectly.

Conclusion

Adding blurred text to your React Native app can enhance its visual appeal and provide a modern touch to your UI. You can just experiment with different intensities and tints to achieve the desired effect in your application.

text Article's
30 articles in total
Favicon
How to work with regular expressions
Favicon
Ultimate Guide to Exam Preparation Materials: Study Smarter, Not Harder
Favicon
The Importance of Earning an IT Certification: Unlocking Career Opportunities in the Digital Age
Favicon
CSS: List of Properties for Text
Favicon
Implementing UTF-8 Encoding in Zig
Favicon
Working with Different File Modes and File Types in Python
Favicon
teste
Favicon
A React component for highlighting text selections within text and HTML content
Favicon
Automatic convert audio notes to text with React
Favicon
How are AI text generators like GPT-3 revolutionizing content creation and storytelling?
Favicon
How to Add Blurred Text in React Native
Favicon
Introducing Speakatoo: Your Ultimate Spanish Text-to-Speech Solution
Favicon
Anonymous texting apps
Favicon
Einfügen eines Textwasserzeichens in PDF mit Java
Favicon
CSS Rainbow Text Effect To Spice Up Your Web Design
Favicon
The Beginner’s Handbook to Enhancing Web Speed: A Focus on Image Optimization
Favicon
Extrahieren von Text und Bildern aus PDF-Dokumenten mit Python
Favicon
Hinzufügen eines Text- oder Bild-Wasserzeichens zu einem Word-Dokument mit Python
Favicon
Comment trouver et remplacer des données dans Excel avec C# et VB.NET
Favicon
Mit Python Text und Bilder aus Word-Dokumenten extrahieren
Favicon
Zalgo Font Generator: Elevate Your Content with Creepy Text
Favicon
A React application that generate summaries of text documents
Favicon
Best Large Language Model APIs in 2023
Favicon
How to show less content in Angular
Favicon
Best AI Content Detection APIs in 2023
Favicon
Lire rapidement ou extraire du texte à partir d'un PDF en Java
Favicon
Unleashing Productivity with Vim - A Powerful Text Editor for All
Favicon
Arabic Text Rendering Issues in JavaFX
Favicon
How to extract text and image from word in Java applications
Favicon
flutter text widget example

Featured ones: