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
barry2y ago
Just go to tailwind page and get the hex values
fotoflo
fotoflo2y ago
and use comments in the code ... ok
SuplenC
SuplenC2y ago
if you have your own colors and want to use tailwind colors you can use const colors = require('tailwindcss/colors')
fotoflo
fotoflo2y ago
i dont have my own colors i just want to alias their names
fotoflo
fotoflo2y ago
fotoflo
fotoflo2y ago
i think like this but add the 600
barry
barry2y ago
But what’s indigo-400 then
SuplenC
SuplenC2y 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
fotoflo2y ago
fotoflo
fotoflo2y ago
@SuplenC thats getting very close
barry
barry2y ago
lol Personally I would just copy the hex value and get on with it 😂
SuplenC
SuplenC2y 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
SuplenC2y 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
SuplenC2y ago
having a 500 value as a base
fotoflo
fotoflo2y 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
barry2y ago
Yeah I just don’t see how this is better than the other way
fotoflo
fotoflo2y ago
fotoflo
fotoflo2y ago
i think this is good
SuplenC
SuplenC2y 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
barry2y ago
primaryLight: “#FFF” vs primaryLight: colors.white
fotoflo
fotoflo2y 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
SuplenC2y ago
no problem
Want results from more Discord servers?
Add your server