Replies: 4 comments 1 reply
-
|
Hi, thanks for kind words. We've actually considered this but we're still not sure if we want to make this change. On the web every CSS variable is just a string, we're not parsing it inside useCSSVariable. Limited input type gives a better intellisense and typesafety, but it can be limiting factor for creating your own hooks / components. For now I believe that runtime warning on dev mode is enough for now. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
While we see the value in stricter typing, we've decided to keep this flexible for now. Since the As uniwind grows, we are still learning the most popular usage patterns. We want to prioritize flexibility to accommodate different workflows, even if it means trading off a bit of type safety in the short term. We are definitely open to revisiting this in the future as usage patterns stabilize, but for the time being, we will keep the types as they are. |
Beta Was this translation helpful? Give feedback.
-
|
other issue with the way it is right now i calculate the paddingTop and i need to do custom because p-safe doesn't take into account the expo-router header height. const headerHeight = useHeaderHeight()
const offsetTop = useCSSVariable("--spacing-4") as number
const paddingTop = headerHeight + offsetTop
const [refreshing, setRefreshing] = useState(false)
console.log(headerHeight, offsetTop)issue is, that fucks on web because it return a string on web but a number on native. i feel like it's a really bad thing for the api to not be consistent over platform in the output type. i don't even see a way currently to get the variable as a number on web to do this outside of doing a parsing myself :/ |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hey team 👋
Uniwind markets “resolve CSS variables directly in JavaScript,” which is awesome for DX. I’d love to propose a small typing upgrade that makes this experience fully typesafe:
What I’m proposing
useCSSVariableshould only accept actual CSS variable names present in our tokens (e.g.'--color-primary'). Passing a non‑existent var should be a type error.string | number.Why this helps
'--colo-primary'→ error).Proposed API surface
Usage
Keeping it maintainable (codegen)
:root { --var: value; }tokens (or tailwind config) and emitsCSSVariableMap.px/rem/em→ Length,%→ Percent,ms/s→ Duration, plain number → number). This can be refined over time.Example codegen outline
Implementation notes
If this approach aligns with Uniwind’s goals, I’m happy to contribute a PR with:
CSSVariableMaptyping,useCSSVariablesignature updates (with tests).Thanks for considering!
Beta Was this translation helpful? Give feedback.
All reactions