The Wayback Machine - https://web.archive.org/web/20241115152705/https://www.geeksforgeeks.org/how-to-use-radial-gradient-in-tailwind-css/
Open In App

How to use Radial Gradient in Tailwind CSS ?

Last Updated : 24 Jun, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

A radial gradient is a graphical effect where colors transition in a circular or elliptical pattern. By default, the first color starts at the center and fades out to the edge of the element. Tailwind CSS makes it easy to implement radial gradients with its utility classes.

We can use the below approaches to achieve a Radial gradient in Tailwind CSS:

The Radial Gradient in Tailwind CSS as a Circle

A radial gradient as a circle will create a circular pattern with a color that fades to another color towards the edge. The bg-[ ] utility in Tailwind CSS is used to set arbitrary background values, and the radial-gradient() function is utilized to create the gradient.

Example: Implementation of using radial gradient in Tailwind CSS as a circle.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" 
          content="width=device-width,
                   initial-scale=1.0" />
    <title>Radial Gradient</title>
    <script src=
"https://cdn.tailwindcss.com"></script>
</head>

<body class="flex flex-col 
             items-center">

    <h3 class="text-center
               text-2xl 
               text-green-800"> 
      Radial Gradient as a Circle
      </h3>
    <div class="container grid grid-cols-2 gap-8 p-4">
        <div class="box border-4 border-red-600 
                    bg-[radial-gradient(circle_at_center,
                    _var(--tw-gradient-stops))]  
                    from-teal-300 via-gray-100  
                    to-blue-300">
            <h3 class="mb-4 p-12 text-2xl"> 
              circle at center
            </h3>
        </div>
        <div class="box border-4 border-red-600 
                    bg-[radial-gradient(circle_at_top,
                    _var(--tw-gradient-stops))]   
                    from-teal-300 via-gray-100  
                    to-blue-300">
            <h3 class="mb-4 p-12 text-2xl"> 
              circle at Top
              </h3>
        </div>
        <div
            class="box border-4 border-red-600  
                   bg-[radial-gradient(circle_at_bottom,
                   _var(--tw-gradient-stops))]
                   from-teal-300 via-gray-100 to-blue-300">
            <h3 class="mb-4 p-12 text-2xl">
              circle at bottom 
              </h3>
        </div>

        <div class="box border-4 border-red-600   
                    bg-[radial-gradient(circle_at_top_left,
                    _var(--tw-gradient-stops))]
                    from-teal-300 via-gray-100  
                    to-blue-300">
            <h3 class="mb-4 p-12 text-2xl"> 
              circle at top Left
              </h3>
        </div>
    </div>
</body>

</html>

Output:

move3p2
Output

The Radial Gradient in Tailwind CSS as an Ellipse

A radial gradient as an ellipse creates an elliptical pattern where one color transitions to another color towards the edge. The bg-[ ] class is used for arbitrary background values, while the radial-gradient() function sets the gradient with specific parameters for shape and position. The _var(--tw-gradient-stops) dynamically sets color stops.

Example: Implementation of using radial gradient in Tailwind CSS as an Ellipse.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" 
          content="width=device-width,
                   initial-scale=1.0" />
    <title>Radial Gradient</title>
    <script src=
"https://cdn.tailwindcss.com"></script>
</head>

<body class="flex flex-col
             items-center">

    <h3 class="text-center
               text-2xl 
               text-green-800"> 
      Radial Gradient as an Ellipse 
      </h3>
    <div class="container grid 
                grid-cols-2 gap-8 p-4">
        <div
            class="box border-4 border-red-600 
                   bg-[radial-gradient(ellipse_at_center,
                   _var(--tw-gradient-stops))]  
                   from-teal-300 via-gray-100  
                   to-blue-300">
            <h3 class="mb-4 p-12 text-2xl">
              Ellipse at center
            </h3>
        </div>
        <div class="box border-4 border-red-600 
                    bg-[radial-gradient(ellipse_at_top,
                    _var(--tw-gradient-stops))]
                    from-teal-300 via-gray-100  
                    to-blue-300">
            <h3 class="mb-4 p-12 text-2xl"> 
              Ellipse at Top
              </h3>
        </div>
        <div class="box border-4 border-red-600  
                    bg-[radial-gradient(ellipse_at_bottom,
                    _var(--tw-gradient-stops))]
                    from-teal-300 via-gray-100  
                    to-blue-300">
            <h3 class="mb-4 p-12 text-2xl">
              Ellipse at bottom 
              </h3>
        </div>

        <div class="box border-4 border-red-600   
                    bg-[radial-gradient(ellipse_at_top_left,
                    _var(--tw-gradient-stops))]
                    from-teal-300 via-gray-100 
                    to-blue-300">
            <h3 class="mb-4 p-12 text-2xl"> 
              Ellipse at top Left
              </h3>
        </div>
    </div>
</body>

</html>

Output:

movep200
Output

Using Tailwind CSS, you can easily create stunning radial gradients either in circular or elliptical shapes. By using the bg-[ ] utility and radial-gradient() function, you can define custom gradients that enhance the visual appeal of your web elements.


Similar Reads

CSS repeating-radial-gradient() Function
The repeating-radial-gradient() function is an inbuilt function in CSS that is used to repeat radial gradients. Syntax:  background-image: repeating-radial-gradient(shape size at position, start-color, ..., last-color); Parameters: This function accepts many parameters which are listed below:  shape: This parameter is used to define the shape of th
3 min read
CSS radial-gradient() Function
The radial-gradient() function in CSS is used to create attractive background effects. It creates a gradient that starts from a central point and spreads outward. By default, the gradient begins in the center of the element and smoothly fades to the final color at the edges. You can customize the shape, size, position, and colors of the gradient to
3 min read
How to create Radial Menu in CSS ?
There are so many ways to create a radial menu by using the CSS property. The font icon, letters, and or image are used in the radial menu. That radial button can be linked with the sites. Set the position, height, and width of a radial button by using CSS. There is another approach using JavaScript to create a radial menu. Example 1: This example
3 min read
CSS Radial Gradients
CSS Radial Gradients are used for creating visually appealing backgrounds on web pages. This inbuilt CSS function allows you to create a smooth transition between two or more colors, originating from a central point and expanding outward in a circular or elliptical shape. By default, the gradient starts at the center of the element and transitions
3 min read
Tailwind CSS Gradient Color Stops
This class accepts more than one value in tailwind CSS. All the properties are covered as in class form. It is the alternative to the CSS Gradients property. Gradient Color Stops classes: from-transparent: This class is used to set the start color transparency.from-current: This class is used to adopt the parent color for the element that will use
2 min read
How to apply background image with linear gradient using Tailwind CSS ?
In this article, we will see how to apply background images with a linear gradient using Tailwind CSS. Tailwind CSS is a highly customizable, utility-first CSS framework from which we can use utility classes to build any design. To apply background images with linear gradients we use the background image utility of Tailwind CSS. It is the alternati
2 min read
How to Change the Direction of a Gradient in Tailwind CSS ?
In Tailwind CSS, you can change the direction of a gradient using the bg-gradient-to utility class. For example, bg-gradient-to-r sets the gradient from left to right, while bg-gradient-to-b sets it from top to bottom. Choose the appropriate direction class to achieve the desired gradient orientation. Table of Content Using Utility classesUsing Cus
3 min read
How To Make A Button Linear Gradient Color Border In Tailwind CSS?
Creating visually appealing buttons can significantly enhance the user interface of your web application. One popular design trend is the use of linear gradient borders. In this article, we'll explore how to make a button with a linear gradient color border using Tailwind CSS. A button with a linear gradient color border can add a visually appealin
3 min read
How to Create Glowing Background Gradient Effects in Tailwind CSS?
Glowing background gradient effects can add a dynamic and visually appealing element to your web design. In Tailwind CSS, achieving this effect involves combining gradient utilities with custom styles. This guide will explore different methods to create glowing gradient effects. These are the following approaches to create Glowing Background Gradie
2 min read
How to Create Gradient Text with Tailwind CSS?
Gradient text adds visual appeal to user interfaces enhancing the design and attracting attention to important elements. we will learn how to create gradient text using Tailwind CSS in a React project. Gradient text can add a vibrant and visually appealing effect to your UI and make important headlines or elements stand out. PrerequisitesReactJSTai
3 min read
What is the use of the tailwind.config.js file in Tailwind CSS ?
The tailwind.config.js file in Tailwind CSS serves as a central configuration hub for customizing the framework. It allows you to define colors, fonts, breakpoints, and more, tailoring Tailwind to fit your project's specific design and functionality requirements. Syntax:/** @type {import('tailwindcss').Config} */module.exports = { content: [], them
1 min read
Create a Radial Bar Chart using Recharts in ReactJS
Rechart JS is a library that is used for creating charts for React JS. This library is used for building Line charts, Bar charts, Pie charts, etc, with the help of React and D3 (Data-Driven Documents).   A Radial Bar chart is a categorical bar chart that is displayed in polar coordinates. It is also known as a circular bar chart. It is used to show
3 min read
Chart.js Radial Axes
Chart.js Radical Axes are designed for radar and polar area chart types, overlaying the chart area rather than positioned on the edges. There is one radical axis which is by default and other visual components are angle lines, grid lines, point labels, and ticks. These visual components provide various customization options which include changing c
5 min read
How To Add Gradient Background With Tailwind?
Gradient backgrounds are a common design element that can give your website depth and visual appeal. You can make both linear and radial gradients with Tailwind CSS without writing any custom CSS. With minimal effort, you can apply stunning gradients to your elements by using Tailwind's utility classes, which streamline the process. Approach To Add
2 min read
How to use Linear Gradient in CSS?
The linear gradient in CSS is a type of gradient where colors transition in a straight line, either vertically, horizontally, or at any specified angle. The gradient in CSS can be often used to add smooth color transitions to the backgrounds, buttons, or other UI elements. Linear gradients can enhance the look and feel of the webpage by adding dept
5 min read
How to use CSS Animations with Tailwind CSS ?
Tailwind CSS classes are used to style elements and apply animations effortlessly. Utilize Tailwind's animation utility classes to add dynamic visual effects. Combine Tailwind CSS with custom CSS animations for versatile and engaging web designs. Table of Content Tailwind CSS Animation Utility ClassesCSS Animations with Tailwind CSS and JavaScriptT
3 min read
How CSS transition work with linear gradient background button?
In CSS, you can smoothly make transitions between two or more colors. CSS has two types of gradients: Linear gradient: It goes down/up/left/right/diagonally and makes smooth transitions of colors. To make a linear transition you first have to choose two color stops. Color stops are the color among which you want to make the transitions. You can als
1 min read
Create a Gradient Text Effect using HTML and CSS
This article will show the approach to add a gradient effect on text using the background-clip CSS property. The final output of text using this effect is shown below. The CSS properties that would be used are flexbox, background-clip, and -webkit-background-clip and the background. HTML Section: This section contains the HTML markup that will cont
3 min read
How to create linear gradient background using CSS ?
In CSS, we can use the background-color property to set the background color of an element to a specific color. Sometimes we want to add more styling to the element when setting the background color by using the linear-gradient property. CSS linear-gradient property lets you display smooth transitions between two or more colors. Syntax: background-
4 min read
How to create gradient search button using HTML and CSS ?
In this article, we will see how to create a gradient search button using HTML & CSS, along with knowing its basic implementation through the examples. The creation of a gradient search button involves the CSS linear-gradient() function, which sets the background color of the button. Here, we have designed the button with rounded edges, and a h
4 min read
How to create a gradient navbar using HTML and Inline CSS ?
A gradient navbar is a stylish way to make your website look modern and professional. In this article, we will show you how to create a gradient navbar using HTML only. No CSS or JavaScript is required. Approach: Please refer linear-gradient() method to create a gradient background. This HTML code uses the "style" attribute to add inline styling to
4 min read
How to apply gradient as the mask using CSS ?
In this article, we will learn how to include the gradient as the mask layer in CSS, along with understanding their basic implementation with the help of suitable examples. The Mask Property with a Gradient is used to create a mask layer, that can be utilized for rendering or hiding the area of the content of an element. There are mainly 2 types of
3 min read
How to Add a Gradient Overlay to Text with CSS?
Adding a gradient overlay to text can create visually appealing effects that enhance the design of a website. CSS provides various techniques to apply gradients to text. Table of Content Approach 1: Using background-clipApproach 2: Using a MaskApproach 3: Using SVGGradient Overlay to Text using background-clip PropertyThe background-clip property w
2 min read
How to Set Transparency with Linear Gradient in CSS ?
In web design, colors, and gradients play a vital role in crafting visually appealing websites. Incorporating transparency into specific elements can further enhance their visual impact. We'll explore three methods for achieving transparency with linear gradients in CSS including, background image, linear gradients with RGBA colors, and HSLA colors
3 min read
How to set gradient border color in CSS?
CSS Gradient Color applies two or more colors by smoothly transitioning between the colors. In this article, we will see how to set the Gradient Border Color of an element using CSS. Gradient Border Color enhances the styling of the element. Set the Gradient Border using border-image propertyThe border-image property allows you to use an image or a
2 min read
CSS Combine background image with gradient overlay
CSS gradients allow for smooth transitions between two or more colors and can be combined with background images to create visually appealing designs. By using the background-image property, you can overlay gradients on top of background images to enhance their appearance. Table of Content 1. Using linear-gradient2. Using radial-gradientSyntaxFor l
3 min read
CSS Linear Gradient
CSS Linear Gradient is a built-in function that enables you to create smooth transitions between two or more colors along a straight line. This function is highly versatile, allowing you to specify the starting point and direction (or angle) of the gradient, thereby determining the flow of colors. Whether for backgrounds, borders, or text, linear g
3 min read
How to Create Gradient Color of Progress Bar in CSS?
Creating a gradient color progress bar can add a visually appealing element to your webpage. Gradients provide smooth transitions between colors, making the progress bar more attractive and enhancing the user experience. These are the different approaches to creating a gradient color progress bar using CSS: Table of Content Using linear-gradientUsi
2 min read
How to create linear gradient text using HTML and CSS ?
The linear-gradient is used to create eye-catching text effects, particularly suitable for dark-themed websites or applications. This method involves filling text with linear-gradient color codes, making it look attractive and bold. Linear-gradient text effects are ideal for dark themes and provide a modern, stylish appearance. In this article, we
3 min read
How to create linear-gradient color generator using HTML, CSS and JavaScript ?
Creating a background generator using HTML, CSS, and JavaScript is an excellent way to add interactive and visually appealing features to your web projects. This tool allows users to generate gradient backgrounds based on their selected color values. In this article, we'll walk you through the steps to build a background generator, including settin
2 min read
three90RightbarBannerImg