Chakra v3 host: useToken returns a snapshot
Symptom
Root cause
// node_modules/@chakra-ui/react/dist/esm/styled-system/system.js
const tokenFn = (path, fallback) => tokenMap.get(path)?.value || fallback;
tokenFn.var = (path, fallback) => tokenMap.get(path)?.variable || fallback;// ❌ Snapshots the resolved color at render time
const [bgPrimary] = useToken('colors', ['bg.primary'])
// bgPrimary === '#1B1D1F' when Chakra evaluated bg.primary in dark scope
// bgPrimary === 'white' when it evaluated in light scopeFix
Option A — use Chakra v3's sys.token.var(...) resolver
sys.token.var(...) resolverOption B — hardcode the CSS variable
How to verify
Reference reproduction
Last updated
Was this helpful?