Showing posts with label COLOR. Show all posts
Showing posts with label COLOR. Show all posts

Sunday, December 17, 2023

Global colors Use (Create color Variable) in ReactJS

December 17, 2023 0

 Global colors Use (Create color Variable) in ReactJS 


Step 1

Create a new file names colors.js in your project.


Step 2

Let’s start adding colors to our colors.js file.


import React from 'react';

export const COLOR={
    primary: "green",
    secondary: "red"
}

Step 3

Let’s start to usage.

import { COLORS } from ‘<current dir to parent dir — src/>/values/colors.js’

// { } is very important without this showing error :

export 'default' (imported as 'COLOR') was not found in '../../utils/Mycolor' (possible exports: COLOR)


import { MYCOLOR }  from '../../utils/Mycolor';

// Calling this color here

<Button href='/login' style={{color: 'white' , backgroundColor: MYCOLOR.primary}} >Sign In</Button>