How to create glowing text in react js?

Hi Friends πŸ‘‹,

Welcome To aHoisting!

To create glowing text in react js, you can use style={{textShadow: `0 0 5px ${color}, 0 0 10px ${color}, 0 0 20px ${color}, 0 0 40px ${color}`,}}. It will create glowing text in react js.

Today, I am going to show you, how to create glowing text in react js.

Table of contents

  • Install and create a new React app.
  • Import react component.
  • Create a Component.

Let’s start with the first step.

Step 1: Install and create a new React app.

First you have to install the React project. You should use create-react-app command to create a new React project.

npx create-react-app my-app
cd my-app
npm start

Step 2: Import react component.

After installing, you have to import your React component.

import React, { useState } from 'react'; 
import './App.css';

Step 3: Create a Component.

You can use className="dynamic-glowing-text" to create glowing text in react js.

<div>
  <input
    type="color"
    value={color}
    onChange={handleColorChange}
    style={{ marginBottom: '10px' }}
      />
  <div
    className="dynamic-glowing-text"
      style={{
        textShadow: `0 0 5px ${color}, 0 0 10px ${color}, 0 0 20px ${color}, 0 0 40px ${color}`,
        }}
      >
        Dynamic Glowing Text
      </div>
    </div>

Create glowing text example.

The below code is an example of a React. You have to import react and set style={{textShadow: `0 0 5px ${color}, 0 0 10px ${color}, 0 0 20px ${color}, 0 0 40px ${color}`,}} to create glowing text in react js.

App.js

import React, { useState } from 'react'; 
import './App.css';

const GlowingText = () => {
  const [color, setColor] = useState('#00f');

  const handleColorChange = (event) => {
    setColor(event.target.value);
  };

  return (
    <div>
      <input
        type="color"
        value={color}
        onChange={handleColorChange}
        style={{ marginBottom: '10px' }}
      />
      <div
        className="dynamic-glowing-text"
        style={{
          textShadow: `0 0 5px ${color}, 0 0 10px ${color}, 0 0 20px ${color}, 0 0 40px ${color}`,
        }}
      >
        Dynamic Glowing Text
      </div>
    </div>
  );
};

export default GlowingText;

App.css

.glowing-text-animated {
  font-size: 2rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 5px #00f, 0 0 10px #00f, 0 0 20px #00f, 0 0 40px #00f;
}

@keyframes glow {
  0% {
    text-shadow: 
      0 0 5px #00f, 
      0 0 10px #00f, 
      0 0 20px #00f, 
      0 0 40px #00f;
  }
  100% {
    text-shadow: 
      0 0 10px #ff0, 
      0 0 20px #ff0, 
      0 0 40px #ff0, 
      0 0 80px #ff0;
  }
}

In the above code example, I have used the style={{textShadow: `0 0 5px ${color}, 0 0 10px ${color}, 0 0 20px ${color}, 0 0 40px ${color}`,}} to create glowing text in react js.

Check the output of the above code.

React, create, glowing, text

All the best πŸ‘