React Chakra UI Gradients allow you to add stylish and visually appealing backgrounds. Gradients are a blend of two or more colors that transition smoothly from one to another. In this article, we will learn about the implementation of the Gradients in Chakra UI.
Prerequisites:
Approach:
We have used the ChakraProvider wrapper component that ensures the availability of Chakra UI styles and theming throughout the application. We have created a text gradient and different styles of box gradient by using the bgGradient and bgClip properties. bgGradient property is used to create a background gradient effect and bgClip property is used to create a text gradient.
You can use different types of CSS gradient such as Linear, Radial, Conic etc.. inside bgGradient property. It also support different directions such as to-t(to top), to-tr(to top right), to-r(to right), to-br(to bottom right), to-b(to bottom) etc...
Steps to Create React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app gfg
Step 2: After creating your project folder(i.e. gfg), move to it by using the following command:
cd gfg
Step 3: After creating the React application, Install the required package using the following command:
npm i @chakra-ui/react @emotion/react @emotion/styled framer-motion
Project Structure:

The updated dependencies in package.json file:
"dependencies": {
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"framer-motion": "^11.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
Example: The below example is demonstrating the use of Gradient in Chakra UI.
JavaScript
//File path: src/App.js
import {
ChakraProvider,
Box, Heading
}
from '@chakra-ui/react';
function App() {
return (
<>
<ChakraProvider>
<Box textAlign="center">
<Heading
bgClip="text"
bgGradient="linear(to-r, #ff005a, #0a60eb)">
Chakra UI Gradient | GeeksForGeeks
</Heading>
</Box>
<Box display='flex' justifyContent='center'
mx='50px' my='20px' gap='15px'>
<Box height='200px' width='200px'
bgGradient='linear(red 15%, green 35%, blue 50%)'>
</Box>
<Box height='200px' width='200px'
bgGradient='linear(to-t, red, green, blue)'>
</Box>
<Box height='200px' width='200px'
bgGradient='linear(to-tr, red, green, blue)'>
</Box>
<Box height='200px' width='200px'
bgGradient='linear(to-b, red, green, blue)'>
</Box>
<Box height='200px' width='200px'
bgGradient='linear(to-br, red, green, blue)'>
</Box>
<Box height='200px' width='200px'
bgGradient='linear(to-l, red, green, blue)'>
</Box>
</Box>
</ChakraProvider>
</>
);
}
export default App;
To run the application use the following command:
npm run start
Output: Now go to http://localhost:3000 in your browser:

Similar Reads
React Chakra UI Navigation
React Chakra UI Navigation Bar is used in every website to make it more user-friendly so that the navigation through the website becomes easy and the user can directly search for the topic of their interest. Prerequisites:NPM and NodeReact JSHTML, CSS, and JavaScriptReactJS ChakraUIWe will use the f
3 min read
React Chakra UI Filter
React Chakra UI Filter is the component that is used to apply filter and backdrop filters to the various elements. Using this component, we can adjust the grayscale, blur, brightness, contrast, and more properties of the elements. The simple Image can be adjusted in various appearances by controllin
3 min read
React Chakra UI Grid Layout
React Chakra UI Grid Layout is an incredibly powerful and flexible component designed to streamline the creation of responsive and aesthetically pleasing grid-based designs within web applications. As an integral part of the Chakra UI library, this grid layout system offers developers a seamless int
2 min read
React Chakra UI Overlay
Chakra UI, a comprehensive React component library, introduces the concept of Overlays serving as dynamic visual elements that are superimposed on the main content, providing additional context, functionality, or notifications. Although Chakra UI doesn't have a standalone "Overlay" component, it off
4 min read
React Chakra UI Other
Chakra UI is a useful tool that allows users to design appealing and practical websites and applications in a quick and easy way. It provides a variety of ready-to-use components that can be personalized and adjusted to meet different project needs, thus streamlining web development and making it mo
6 min read
React Chakra UI Position
The Chakra UI library is a popular React UI library that helps build advanced and customizable user interfaces. One essential aspect of building UI is positioning the elements at the right positions on the screen. Prerequisites: NPM & NodeReact JSReactJS ChakraUIHTML, CSS, and JavaScriptChakra U
4 min read
React Chakra UI Data Display
React Chakra UIÂ Data Display is the component that can be embedded in the React application to display various data components. All these components are for data visualization purposes for an interactive and user-friendly interface. The various data components include Card, Badges, List, Table, Tag,
3 min read
React Chakra UI Overlay Drawer
React Chakra UI Overlay Drawer enhances web app navigation, integrating smoothly with Chakra UI. It offers intuitive access to extra content, without disrupting the main interface. Simple and customizable, it elevates user engagement and satisfaction. Prerequisites:NPM and NodeReactHTML, CSS, and Ja
2 min read
React Chakra UI Form Number Input
React Chakra UI Form Number Input is a powerful and user-friendly component tailored for efficient numeric data entry in web applications. Built on the Chakra UI foundation, this component seamlessly integrates into React applications, providing developers with a simple yet customizable solution for
2 min read
React Chakra UI Other Show/Hide
React Chakra UI Show and Hide components are used to show or hide children elements when a specific media query matches. We can provide custom media query to the Show and Hide components or use the predefined responsive size defined by Chakra UI. Prerequisites:NPM & NodeReact JSHTML, CSS and Jav
2 min read