Giter Club home page Giter Club logo

Comments (7)

gregberge avatar gregberge commented on August 12, 2024 2

Yeah if you are using CSS variables, you obviously can't do it. All colors have to be defined in the theme to be pre-processed before. You can't use it like that in CSS.

from xstyled.

gregberge avatar gregberge commented on August 12, 2024 1

@stephenkoo you have to turn off the transformation into CSS properties. https://xstyled.dev/docs/color-modes/#turn-off-custom-properties

from xstyled.

stephyswe avatar stephyswe commented on August 12, 2024

This!

from xstyled.

gregberge avatar gregberge commented on August 12, 2024

Already possible, in fact th.xxx() returns a function that takes prop. You can wrap this function and you get access to the value, the adapted example:

import styled from '@xstyled/styled-components'
import { th } from '@xstyled/system'
import { rgba } from 'polished'

const theme = {
  colors: {
    black: '#000'
  }
}

const Box = styled.div`
  color: ${p => rgba(th.colors('black')(p), 0.5)};
`

from xstyled.

stephenkoo avatar stephenkoo commented on August 12, 2024

Thanks for taking a look @gregberge.

I've followed your example, but that still provides me with a CSS variable instead of the color value.

Where I'm trying to access the hex/rgba value:

image

Dev console:

image

from xstyled.

stephenkoo avatar stephenkoo commented on August 12, 2024

from xstyled.

stephenkoo avatar stephenkoo commented on August 12, 2024

Hi @gregberge, mind re-opening the issue? I'm pretty sure Xstyled is converting colors into CSS variables named --xstyled-colors- which prevents the solution from working. If it's not I'm not sure what library is renaming the colors before I can manipulate them.

Would a code demo help?

from xstyled.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.