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.

RGBA option for token values

See original GitHub issue

Use this template if you want to request a new feature, or a change to an existing feature.

If you are reporting a bug or problem, please use the bug template instead.

Summary

rgba() tokens to the Carbon theme variables so that we can apply the theme based on what the adopter defines. Currently need to do a linear-gradient with the $ui-background with an opacity 0.6. We need the option to set the opacity of the token becuase currently our scss styles are not able to recognice rgba($ui-background, 0.6)

Clarify if you are asking for design, development, or both design and development.

Justification

Creating a image component with a gradient where the design requests this functionality.

image

Desired UX and success metrics

Describe the full user experience for this feature. Also define the metrics by which we can measure success/failure for the user.

“Must have” functionality

Highlight any “must have” needs and functionality for the request.

This should not be a full list of functionality; the Carbon team will work with you to define functionality based on the desired UX.

Specific timeline issues / requests

Do you want this work within a specific time period? Is it related to an upcoming release?

NB: The Carbon team will try to work with your timeline, but it’s not guaranteed. The earlier you make a request in advance of a desired delivery date, the better!

Available extra resources

What resources do you have to assist this effort?

Carbon is a collaborative system. We encourage teams to build components and submit them for integration as either add-ons or core components.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ariellalgilmorecommented, Jul 15, 2021

Hi @joshblack sorry for the delay. We are using the css custom property feature flag but when adding the alpha value to rgba($ui-background, 0.6) the opacity does come into effect.

cc: @proeung

1reaction
tay1orjonescommented, Dec 16, 2022

I was curious if there are any other specific uses you know have for having RGBA-specific tokens?

@laurenmrice I can’t really think of any solid use cases for RGBA tokens - to my knowledge none of our established patterns rely on transparency.

Looking again at the original use case provided by @ariellalgilmore, I think the best course of action would be to recommend using the color functions built into sass to support “transparentizing” the existing hex values.

Here’s an example of transparent gradients using the existing tokens and the sass color function adjust()

@use 'sass:color';
@use '@carbon/react/scss/colors';

.gradient {
  background: radial-gradient(
      color.adjust(colors.$yellow-50, $alpha: -0.7) 40px,
      transparent 0,
      transparent 100%
    ),
    radial-gradient(
      color.adjust(colors.$blue-40, $alpha: -0.5) 40px,
      transparent 0,
      transparent 100%
    ),
    radial-gradient(
      color.adjust(colors.$red-30, $alpha: -0.3) 40px,
      transparent 0,
      transparent 100%
    ),
    snow;
  background-blend-mode: multiply;
  background-size: 100px 100px;
  background-position: 0 0, 33px 33px, -33px -33px;
}

For now I don’t see a need to add RGBA values to the tokens themselves. If anyone has further info or use cases to consider, let us know and we can discuss reopening this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Design Tokens - Lightning Design System
Design tokens are the visual design atoms of the design system ... These RGBA values need to be updated if BRAND_BACKGROUND_DARK changes, solves...
Read more >
Color Tokens - Tokens Studio for Figma
There are multiple ways you can write color tokens: Hex: #ff0000; RGB: rgb(255, 0, 0); RGBA: rgba(255, 0 ...
Read more >
How do I apply opacity to a CSS color variable? - Stack Overflow
Show activity on this post. For using rgba() with general css variable, try this: Declare your color inside :root, but don't use rgb()...
Read more >
Theming with CSS variables in RGBA - CodePen
Next, I extracted a variable for the RGB color from the declaration above. CSS variables can hold any value, and luckily they resolve...
Read more >
Design tokens cheatsheet - UX Collective
These are the raw values in code such as color values (HEX, rgba), absolute and relative length units, percentages, numbers, etc. Base Variables....
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