Using existing color names in tailwind config

seems like a good idea to do it this declaritive way instead of copying the underlying colors into the tailwind css... is something like this possible? how do describe it to google? what is the correct syntax? Thank you!!
extend: {
colors: {
primaryLight: "emerald-600",
primaryDark: "emerald-700",
extend: {
colors: {
primaryLight: "emerald-600",
primaryDark: "emerald-700",
23 Replies
barry
barry3y ago
Just go to tailwind page and get the hex values
fotoflo
fotofloOP3y ago
and use comments in the code ... ok
SuplenC
SuplenC3y ago
if you have your own colors and want to use tailwind colors you can use const colors = require('tailwindcss/colors')
fotoflo
fotofloOP3y ago
i dont have my own colors i just want to alias their names
fotoflo
fotofloOP3y ago
fotoflo
fotofloOP3y ago
i think like this but add the 600
barry
barry3y ago
But what’s indigo-400 then
SuplenC
SuplenC3y ago
and instead of writing it primaryLight and primaryDark you can key the values like this: extend: { colors: { primary: { 600: "#HEX", 700: colors.emerald.700, }
fotoflo
fotofloOP3y ago
fotoflo
fotofloOP3y ago
@SuplenC thats getting very close
barry
barry3y ago
lol Personally I would just copy the hex value and get on with it 😂
SuplenC
SuplenC3y ago
if you want to use the emerald as the primary you can define it like this: primary: colors.emerald, And in code use bg-primary-600 You should always have a whole palette ideally
SuplenC
SuplenC3y ago
easy to generate one here https://www.tints.dev/
Tailwind CSS 10-color Palette Generator and API
A fast and flexible, HSL-tweakable palette generator and API for Tailwind CSS
SuplenC
SuplenC3y ago
having a 500 value as a base
fotoflo
fotofloOP3y ago
@barry yeah usually id do that... but now im in "set this thing up right so future me can get on with it and not make mistakes" mode this is cool @SuplenC
barry
barry3y ago
Yeah I just don’t see how this is better than the other way
fotoflo
fotofloOP3y ago
fotoflo
fotofloOP3y ago
i think this is good
SuplenC
SuplenC3y ago
as I said above it should follow the tailwind standards instead of having "primaryLight" and "primaryDark" which not only leave you room for different shades of your primary color but doesn't bound you anyway. If tomorrow you want different color just define it
barry
barry3y ago
primaryLight: “#FFF” vs primaryLight: colors.white
fotoflo
fotofloOP3y ago
@barry much more readable, my design stuff hasnt come out yet it will need to be changed by me a lot as i fuck with it thnak you @SuplenC ill go with this
SuplenC
SuplenC3y ago
no problem
Want results from more Discord servers?
Add your server