Tailwindcss: [Feature Proposal] RGBA Backgrounds

Created on 14 Mar 2020  路  1Comment  路  Source: tailwindlabs/tailwindcss

0.5 from the below class might not be the best way to handle it, but this is what I figure out so far.

<div class="bg-rgba-000000/0.5">
  I have an rgba background.
</div>

00000 - color in hex
0.5 - opacity

Thanks.

Might be similar:
https://github.com/tailwindcss/tailwindcss/issues/342

Most helpful comment

Planning to implement this in a future version but in a composable way using CSS custom properties, so you could do something like:

<div class="bg-red-500 bg-opacity-25">

Where those classes are defined something like:

.bg-red-500 {
  --background-color-opacity: 1;
  background-color: rgba(245,101,101, var(--background-color-opacity));
}

.bg-opacity-25 {
  --background-color-opacity: 0.25;
}

We'd support the same thing for text color and border color too 馃憤

>All comments

Planning to implement this in a future version but in a composable way using CSS custom properties, so you could do something like:

<div class="bg-red-500 bg-opacity-25">

Where those classes are defined something like:

.bg-red-500 {
  --background-color-opacity: 1;
  background-color: rgba(245,101,101, var(--background-color-opacity));
}

.bg-opacity-25 {
  --background-color-opacity: 0.25;
}

We'd support the same thing for text color and border color too 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Quineone picture Quineone  路  3Comments

afuno picture afuno  路  3Comments

ouun picture ouun  路  3Comments

Tjoosten picture Tjoosten  路  3Comments

dbpolito picture dbpolito  路  3Comments