Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can tailwind colors be referenced from CSS?

Tags:

tailwind-css

I have some custom colors in my tailwind.config.js:

colors: {
  primary: {
    500: '#0E70ED',
    600: '#0552b3'
  }
}

I want to use them in my CSS files. Is there a way to replace #0e70ed below with primary-500?

.prose a.custom-link {
  color: #0e70ed;
}
like image 875
Naresh Avatar asked Dec 30 '22 15:12

Naresh


1 Answers

Yes, you can use theme() directive

Your colors

colors: {
  primary: {
    500: '#0E70ED',
    600: '#0552b3'
  }
}

will be available in CSS files as

.prose a.custom-link {
  color: theme('colors.primary.500');
}

More info here

like image 187
Ihar Aliakseyenka Avatar answered Jan 05 '23 15:01

Ihar Aliakseyenka