-
In all examples I see, there's always a prop passed into the Progress Indicator to make it move via translateX. Is it possible to style it with the data-value attribute given? I'm not sure if my syntax is off or if I'm using this the wrong way. What I see... (this works) function ({value}:any) => {
return (
<ProgressPrimitive.Indicator
style={{ transform: `translateX(-${100 - (value || 0)}%)` }} // this works
/>
)
} What I'm looking to do... function ({value}:any) => {
return (
<ProgressPrimitive.Indicator
// style={{ transform: "translateX(-var(--data-value)%)" }} // doesn't work
// style={{ transform: `translateX(calc( 100 - var(--data-value) * -1 )% )` }} // doesn't work
// style={{ transform: `translateX(data-value)` }} // doesn't work
// style={{ transform: `translateX([data-value])` }} // doesn't work
/>
)
} What's the correct syntax to get the value of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
To use data attributes on CSS you can use What you can do is create a CSS variable on https://codesandbox.io/p/sandbox/empty-voice-mct6bj?file=%2FApp.jsx |
Beta Was this translation helpful? Give feedback.
To use data attributes on CSS you can use
attr()
function, but support for properties other thancontent
is experimental.What you can do is create a CSS variable on
Root
part and use it onIndicator
parthttps://codesandbox.io/p/sandbox/empty-voice-mct6bj?file=%2FApp.jsx