The post Master Gradient Text Animations: A Beginner-Friendly Guide with CSS appeared first on Th?nk And Grow.
]]>Try to get the code with this PlayGround
Let’s create a text element with a beautiful gradient color that changes smoothly when hovered over.
Step 1: Set Up Your HTML
First, create a basic HTML structure. Add a div element with a class name like text-gradient-purple-coral. This class will be styled later.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gradient Text Animation</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="text-gradient-purple-coral">Hover Over This Text</div>
</body>
</html>
The div is the container for the text we want to style. In this example, the text says “Hover Over This Text.”
Step 2: Write the CSS
Now let’s add the CSS to create the gradient text effect. Open a file named styles.css and include the following code:
.text-gradient-purple-coral {
font-size: 2.5rem; /* Makes the text large and noticeable */
font-weight: bold; /* Adds emphasis to the text */
background: -webkit-linear-gradient(-70deg, #8250df, #d42a32); /* Gradient colors */
-webkit-background-clip: text; /* Ensures the gradient is clipped to the text */
-webkit-text-fill-color: transparent; /* Makes the background gradient visible */
-webkit-box-decoration-break: clone; /* Ensures proper decoration for wrapped text */
transition: all 2s ease-in-out 0.5s; /* Smooth transition for hover effects */
}
/* Hover effect */
.text-gradient-purple-coral:hover {
background: -webkit-linear-gradient(-70deg, #f40915, #380d88); /* New gradient colors on hover */
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
transition: all 2s ease-in-out 0.5s;
}
Key CSS Properties Explained
Here’s a detailed breakdown of what each CSS property does:
1. -webkit-linear-gradient:
This defines the gradient colors. In the example above, #8250df (a purple shade) transitions to #d42a32 (a coral red). The -70deg sets the gradient angle.
2. -webkit-background-clip: text:
This ensures the gradient is applied only to the text.
3. -webkit-text-fill-color: transparent:
Makes the text’s fill transparent, so the gradient background becomes visible.
4. transition:
Adds a smooth effect when the gradient changes on hover.
5. Hover Effect:
When the user hovers over the text, the gradient changes to a new combination (#f40915 to #380d88) with the same smooth transition.
Step 3: Test and View
Customizing the Effect
You can personalize this effect by:
Here’s the complete code for your reference:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gradient Text Animation</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="text-gradient-purple-coral">Hover Over This Text</div>
</body>
</html>
CSS
.text-gradient-purple-coral {
font-size: 2.5rem;
font-weight: bold;
background: -webkit-linear-gradient(-70deg, #8250df, #d42a32);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-box-decoration-break: clone;
transition: all 2s ease-in-out 0.5s;
}
.text-gradient-purple-coral:hover {
background: -webkit-linear-gradient(-70deg, #f40915, #380d88);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
transition: all 2s ease-in-out 0.5s;
}
Creating dynamic gradient effects with hover animations is an easy way to enhance your website’s design. With just a few lines of CSS, you can add a professional and polished look to your projects. Try experimenting with colors and timings to make it uniquely yours!
The post Master Gradient Text Animations: A Beginner-Friendly Guide with CSS appeared first on Th?nk And Grow.
]]>The post Creating Stylish Folded Tags in ReactJS Using Clip-Path appeared first on Th?nk And Grow.
]]>Custom tags and badges are a great way to add visual flair to your React applications. In this article, we’ll walk through creating a FoldedTag component with unique folded corners using clip-path. We’ll dive into the implementation, styling, and how to use this component effectively.


Try to play on Playground
The FoldedTag component is a visually appealing badge with folded corners that you can easily customize. It includes:
Component Code (FoldedTag.js)
Here’s the implementation of the FoldedTag component in React:
import React from "react";
import styles from "../styles.module.scss";
import PropTypes from "prop-types";
const FoldedTag = ({ text, color, hiddenFoldLeft = false, hiddenFoldRight = false }) => {
const lightBg = color?.light || "#1c1c22";
const darkBg = color?.dark || "#000000";
return (
<div className="relative inline-flex items-center justify-center">
{/* Left Folded Corner */}
{!hiddenFoldRight && (
<>
<div
style={{ backgroundColor: lightBg }}
className={`absolute top-0 left-0 -translate-x-[9.5px] w-[10px] h-[6px] ${styles.clipFoldedLeft}`}
></div>
<div
style={{ backgroundColor: darkBg }}
className={`absolute top-0 left-0 -translate-x-[9.5px] w-[10px] h-[6px] ${styles.clipPentagonLeft}`}
></div>
</>
)}
{/* Right Folded Corner */}
{!hiddenFoldLeft && (
<>
<div
style={{ backgroundColor: lightBg }}
className={`absolute top-0 right-0 translate-x-[9.5px] w-[10px] h-[6px] ${styles.clipFoldedRight}`}
></div>
<div
style={{ backgroundColor: darkBg }}
className={`absolute top-0 right-0 translate-x-[9.5px] w-[10px] h-[6px] ${styles.clipPentagonRight}`}
></div>
</>
)}
<span
style={{ backgroundColor: lightBg }}
className="text-white uppercase font-bold text-[10px] sm:text-sm rounded-b-[10px] py-1 px-2.5 sm:px-5 whitespace-nowrap"
>
{text}
</span>
</div>
);
};
FoldedTag.propTypes = {
color: PropTypes.object,
text: PropTypes.string,
hiddenFoldLeft: PropTypes.bool,
hiddenFoldRight: PropTypes.bool
};
export default FoldedTag;
The folded corners are achieved using clip-path, a powerful CSS property that creates custom shapes. Below is the SCSS file defining the styles for this component:
Styles (styles.module.scss)
.clipPathTriangle {
clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
/* Folded left corner */
.clipFoldedLeft {
clip-path: polygon(10% 0%, 10% 0%, 32.592% 2.8%, 51.078% 10.4%, 65.867% 21.6%, 77.363% 35.2%,
85.975% 50%, 92.109% 64.8%, 96.171% 78.4%, 98.57% 89.6%, 99.71% 97.2%, 100% 100%, 100% 0%, 10% 0%);
}
.clipPentagonLeft {
clip-path: polygon(100% 100%, 100% 100%, 99.855% 97.2%, 99.286% 89.6%, 98.091% 78.4%, 96.067% 64.8%,
93.013% 50%, 88.725% 35.2%, 83.002% 21.6%, 75.642% 10.4%, 66.442% 2.8%, 55.2% 0%, 55.2% 0%,
43.667% 2.8%, 33.677% 10.4%, 25.152% 21.6%, 18.014% 35.2%, 12.188% 50%, 7.594% 64.8%, 4.155% 78.4%,
1.795% 89.6%, 0.436% 97.2%, 0% 100%, 100% 100%);
}
/* Folded right corner */
.clipFoldedRight {
clip-path: polygon(90% 0%, 90% 0%, 67.408% 2.8%, 48.922% 10.4%, 34.133% 21.6%, 22.637% 35.2%, 14.025% 50%,
7.891% 64.8%, 3.829% 78.4%, 1.43% 89.6%, 0.29% 97.2%, 0% 100%, 0% 0%, 90% 0%);
}
.clipPentagonRight {
clip-path: polygon(0% 100%, 0% 100%, 0.145% 97.2%, 0.714% 89.6%, 1.909% 78.4%, 3.933% 64.8%, 6.988% 50%,
11.275% 35.2%, 16.998% 21.6%, 24.358% 10.4%, 33.558% 2.8%, 44.8% 0%, 44.8% 0%, 56.333% 2.8%, 66.323%
10.4%, 74.848% 21.6%, 81.986% 35.2%, 87.813% 50%, 92.406% 64.8%, 95.845% 78.4%, 98.205% 89.6%, 99.564%
97.2%, 100% 100%, 0% 100%);
}
import React from "react";
import FoldedTag from "./components/FoldedTag";
const App = () => {
return (
<div className="flex flex-col items-center space-y-4">
<FoldedTag
text="New"
color={{ light: "#FF5733", dark: "#C70039" }}
/>
<FoldedTag
text="Sale"
color={{ light: "#33FF57", dark: "#239B56" }}
hiddenFoldLeft
/>
<FoldedTag
text="Hot"
color={{ light: "#3357FF", dark: "#1B4F72" }}
hiddenFoldRight
/>
</div>
);
};
export default App;
The FoldedTag component is a stylish way to add custom tags or labels to your React applications. With clip-path, you can create intricate shapes that enhance your UI while keeping the implementation clean and reusable.
Would you like to explore more advanced customization or animations for this component? Let me know through my email: [email protected]
Feel free to customize the colors, shapes, and sizes to suit your needs. Happy coding! 
The post Creating Stylish Folded Tags in ReactJS Using Clip-Path appeared first on Th?nk And Grow.
]]>The post Understanding the Magic Behind the Gradient Border Effect in CSS appeared first on Th?nk And Grow.
]]>In this article, we’ll break down a beautifully crafted CSS technique that creates a gradient border effect using a combination of pseudo-elements, gradients, and advanced masking techniques. Let’s dive into the mechanics and understand how this effect works.

To get an insight and make it easier to visualize, let’s enjoy the result on this PlayGround
This is the main class applied to the HTML element that will have the gradient border effect. Let’s explore its properties:
.custom-border-gradient {
position: relative;
border-radius: 20px;
box-shadow: 0px 6px 10px 0px rgba(0, 0, 0, 0.25);
background: #ffffff;
z-index: 1;
}
• position: relative: Ensures that the ::before pseudo-element can be positioned relative to this element.
• border-radius: 20px: Applies rounded corners to the element and ensures the border effect follows the same curve.
• box-shadow: Adds a subtle shadow for a more dynamic, three-dimensional look.
• background: Sets the main background color to white.
• z-index: 1: Positions the main content above the pseudo-element to avoid overlapping.
The ::before pseudo-element is where the gradient magic happens. Here’s the full code:
.custom-border-gradient::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 20px;
padding: 3px; /* Matches the border width */
background: linear-gradient(
286.91deg,
rgba(255, 255, 255, 0) 38.34%,
rgba(255, 210, 84, 0.659794) 58.32%,
#ffffff 68.63%,
rgba(255, 210, 84, 0.66) 78.93%,
rgba(153, 153, 153, 0) 100.78%
);
-webkit-mask:
linear-gradient(#fff 0 0) content-box,
linear-gradient(#fff 0 0);
-webkit-mask-composite: destination-out;
mask-composite: exclude;
z-index: -1; /* Position behind the content */
box-sizing: border-box;
}
Key Properties Explained:
Position and Shape
• position: absolute: Places the pseudo-element over the entire parent element.
• top, left, right, bottom: 0: Ensures the pseudo-element fully covers the parent element.
• border-radius: 20px: Matches the parent’s rounded corners to create a seamless effect.
• padding: 3px: Acts as the border thickness, creating the space needed for the gradient effect.
The Gradient
• background: linear-gradient(…): Defines the gradient colors and transitions.
• rgba(255, 255, 255, 0): Creates transparent sections.
• rgba(255, 210, 84, 0.66): Adds soft, golden hues for a vibrant aesthetic.
• #ffffff: Incorporates pure white for smooth transitions.
• The gradient is carefully designed to provide a smooth and visually appealing blend of colors.
Masking for Transparency
• -webkit-mask and mask: These properties create the “cut-out” effect, ensuring the gradient is visible only around the border.
• linear-gradient(#fff 0 0) content-box: Retains the inner content area.
• linear-gradient(#fff 0 0): Removes the gradient inside the main content.
• -webkit-mask-composite: destination-out and mask-composite: exclude: Exclude the central part of the pseudo-element, leaving the gradient visible only at the edges.
Z-index Layering
• z-index: -1: Positions the ::before pseudo-element behind the main content for proper layering.
Box Sizing
• box-sizing: border-box: Ensures the padding does not affect the element’s overall dimensions.
When applied, this CSS code creates a visually stunning gradient border around the element. The pseudo-element works behind the scenes to:
1. Wrap the element with a gradient.
2. Exclude the gradient from the inner content area.
3. Align seamlessly with the element’s rounded corners.
Example Use Case
Here’s a basic example of applying the class in HTML:
<div class="custom-border-gradient">
<p>This is a content block with a gradient border effect!</p>
</div>
When rendered, the block will have a sleek, modern gradient border surrounding it, with the content inside untouched by the effect.
This technique offers several benefits:
• Customizability: You can easily adjust the gradient colors, border radius, or padding to fit your design.
• Modern Aesthetics: Gradient borders are trendy and add a polished look to any UI.
• Efficient Rendering: Using ::before minimizes extra DOM elements, keeping the structure clean.
This CSS gradient border technique is a perfect example of how pseudo-elements and masking can create advanced visual effects with minimal HTML. Whether you’re designing a modern card component, a button, or a decorative section, this approach is versatile and impactful.
Experiment with it, tweak the gradient, and make your designs stand out!
Have questions or want to see this in action? Let me know! 
The post Understanding the Magic Behind the Gradient Border Effect in CSS appeared first on Th?nk And Grow.
]]>