How to add glowing text in react js?
June 22, 2024Hi Friends π,
Welcome To aHoisting!
To add glowing text in react js, you can use animation: glow 1.5s infinite alternate;
. It will add glowing text in react js.
Today, I am going to show you, how to add 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. To do this, add the following line to the top of your component file.
import React from 'react';
import './App.css';
Step 3: Create a Component.
You can use className="glowing-text-dynamic"
to add glowing text in react js.
<div className="glowing-text-dynamic">
aHoisting Dynamic Glowing Text
</div>
Define the add glowing text example.
The below code is an example of a React. You have to import ./App.css
and set animation: glow 1.5s infinite alternate;
to add glowing text in react js.
App.js
import React from 'react';
import './App.css';
function App() {
return (
<div className="glowing-text-dynamic">
aHoisting Dynamic Glowing Text
</div>
);
}
export default App;
App.css
.glowing-text-dynamic {
font-size: 2rem;
color: #fff;
text-shadow: 0 0 5px #0ff, 0 0 10px #0ff, 0 0 20px #0ff;
animation: glow 1.5s infinite alternate;
}
@keyframes glow {
from {
text-shadow: 0 0 5px #0ff, 0 0 10px #0ff, 0 0 20px #0ff;
}
to {
text-shadow: 0 0 10px #0ff, 0 0 20px #0ff, 0 0 40px #0ff, 0 0 80px #0ff;
}
}
In the above code example, I have used the @keyframes glow
and add glowing text in react js.
Check the output of the above code.
All the best π