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.

Utilities: separate text color from background color

See original GitHub issue

Prerequisites

Proposal

For better color themes support, users need to be able to use different colors in text and background. How it’s currently implemented:

.text-primary {
    --text-opacity: 1;
    color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity));
}

.bg-primary {
    --bg-opacity: 1;
    color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity));
}

If i override --bs-primary-rgb in .text-primary, the following scenario fails:

<div class="bg-primary bg-opacity-25 text-primary">

Because .bg-primary also inherits new RGB value. In dark theme, text color should be lighter than background color. And current implementation makes it impossible to apply different color without introducing a new color map for text color specifically and a bunch of new color classes.

Motivation and context

To improve theming support

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ffooddcommented, Jan 17, 2022

This scenario is supposed to fail since primary represents a color and you’re using the same for background and foreground.

There’s no need to allow finer tuning since this use-case does not match how and why our utilities (and color palette) work.

Simply use another utility for one of tour color.

0reactions
ffooddcommented, Jan 19, 2022

I’m sorry but I don’t get the point. Utilities are named after design tokens (in that case, colors). Having primary matching distinct values would totally fail Bootstrap’s conventions.

Moreover, whatever the reason are (and for sure using.bg-primary.text-primary shouldn’t be a thing) one is already able to change color palettes used for each utilities, by overriding it through the utilities API.

We don’t support dark themes for now, that could be something to revisit when we do.

For now I really don’t see how and why we could consider this. Names matching values is the current purpose of utilities, and your suggestion defeats the whole point.

BTW I really think your example doesn’t help. Providing a real use case (and maybe a test case) would have helped to understand your request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Colors - Bootstrap
Convey meaning through color with a handful of color utility classes. Includes support for styling links with hover states, too. Color .text-primary .text- ......
Read more >
Change text color based on brightness of the covered ...
It can be applied to still and moving elements. Does this work for background-colors?
Read more >
Contextual Utility Classes for Color with Custom Properties
To achieve this, we'll need to specify our text and background colors with utility classes (containing our custom properties).
Read more >
Text Color - Tailwind CSS
Class Properties Preview text‑inherit color: inherit Aa text‑current color: currentColor Aa text‑transparent color: transparent Aa
Read more >
Bootstrap Text colors -- Tutorials with advanced examples
Bootstrap Text colors. Convey meaning through color with a handful of color utility classes. Includes support for styling links with hover states, too....
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