question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extending colors does not work as the name implies and does not allow for border-opacity

See original GitHub issue

When a color is extended like this:

module.exports = {
  theme: {
    extend: {
      colors: {
        'pink': {
          '000': '#fdf5f7ff'
        }
      }
    }
  }
}

then 2 things happen:

  1. the color definitions on pink are overwritten completely (and not overridden), which means that all the definitions on 100, 200, 300 etc get lost ; they must be redefined. extend makes me expect a different behaviour, which is to add to the color definition and/or update an existing one, but not loosing other definitions (which is what happens with boxShadow, e.g.).

  2. Once a color is extended / overwritten, it is not possible to use opacity on the border color.

While existing colors get redefined like this:

/* generated CSS taken from the Chrome DevTools */
.text-gray-900 {
    --text-opacity: 1;
    color: #1a202c;
    color: rgba(26, 32, 44, var(--text-opacity));
}

overwritten colors do not receive that kind of treatment. A usage like this

//- pug
div(class="border-l border-b border-pink-500 border-opacity-25")

is translated (or actually not translated) to this:

/* generated CSS taken from the Chrome DevTools */
.border-l {
    border-left-width: 1px;
}

.border-b {
    border-bottom-width: 1px;
}
.border-opacity-25 {
    --border-opacity: 0.25;
}
.border-pink-500 {
    border-color: rgba(115,27,56,1);
}

This also happens with “new” color keys, e.g. pink-bright: colors seem to always be translated to rgba adding 1 for the alpha channel and ignoring the CSS variable --border-opacity.

I am not sure if these are “expected behaviours” or missed out on something in the documentation - if so, I apologise for wasting your time!

In any case: Thank you very much!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rowildcommented, Jun 3, 2020

@estevanmaito Your answer is soooo valuable!!! Thank you a million times! I didn’t realise my 8 digit hex code! Thank you so much for pointing that out to me!

(I use a Hex3rgba converter in VScode, along the way I defined the colors as rgba values, and when converting back to HEX I missed out the last ff completely, also because of the font that makes two consecutive Fs very, very narrow… Again: thank you very, very much!!!)

Also, he docu points out spreading - fantastic! Should have thought of that, since it is used throughout tailwindcss anyway!

Gratefully closing this issue! Have a good day!

0reactions
ryanfitzercommented, Sep 19, 2020

Exactly what I was just trying to think through. Thanks so much for your quick responses!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending colors does not work as the name implies ... - GitHub
Once a color is extended / overwritten, it is not possible to use opacity on the border color. While existing colors get redefined...
Read more >
Can't figure out why my Tailwind borders aren't showing
I had to add tw-border-solid for some reason. First time ever I've had to do that.
Read more >
Customizing Colors - Tailwind CSS
If you don't have a set of completely custom colors in mind for your project, you can curate your colors from our complete...
Read more >
Configuring Variants - Tailwind CSS
Each property is a core plugin name pointing to an array of variants to ... all the variants you'd like to enable, not...
Read more >
border-color - CSS: Cascading Style Sheets - MDN Web Docs
Syntax · When one value is specified, it applies the same color to all four sides. · When two values are specified, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found