Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

How to add Color Picker in NextJS ?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article, we are going to learn how we can add a color picker in NextJS. NextJS is a React-based framework. It has the power to Develop beautiful Web applications for different platforms like Windows, Linux, and mac. 

Approach: To add our color picker we are going to use the react-color-palette package. The react-color-palette package helps us to integrate different types of color pickers. So first, we will install the react-color-palette package, and then we will add a color picker on our homepage.

Create NextJS Application: You can create a new NextJs project using the below command:

npx create-next-app gfg


Install the required package: Now we will install the react-color-palette package using the below command:

npm i react-color-palette

Project Structure: It will look like this.

Adding the Color Picker: After installing the package we can easily add color picker on any page in our app. For this example, we are going to add color picker to our homepage.


import React from 'react';
import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/lib/css/styles.css";
export default function SkeletonLoading(){
  const [color, setColor] = useColor("hex", "#121212");
  return (
      <h2>NextJs Color Picker - GeeksforGeeks</h2>
      <ColorPicker width={456} height={228} color={color} 
                   onChange={setColor} hideHSV dark />

Explanation: In the above example first, we are importing the Color Picker component and after that, we are using useColor hook to store the value of the selected color. Then we are adding our color picker using the imported component.

Steps to run the application: Run the below command in the terminal to run the app.

npm run dev


My Personal Notes arrow_drop_up
Last Updated : 02 Feb, 2023
Like Article
Save Article
Similar Reads
Related Tutorials