Replies: 4 comments
-
StyleX is a build-time solution, so the values specified in |
Beta Was this translation helpful? Give feedback.
-
@necolas Thank you for your response but I don't think your answer is entirely true, because |
Beta Was this translation helpful? Give feedback.
-
@ebitogu If you're seeing some colors, but not others that is likely an issue with the build set up. Would need more information about your set up to help. The bundler and plugin being used. The way the variables are being used within |
Beta Was this translation helpful? Give feedback.
-
This is kind of hacky but we have some client side only JS components that don't support styling via CSS, so the way I've got around this is something like this: const regex = /var\((--[a-zA-Z0-9-]+)\)/;
export const getColor = (cssVar: string) => {
const match = cssVar.match(regex);
if (!match || !match[1]) {
return '#000000';
}
return getComputedStyle(document.documentElement).getPropertyValue(match[1]);
};
getColor(colors.background); Keep in mind this won't work for components rendered on the server. |
Beta Was this translation helpful? Give feedback.
-
I'm utilizing Ant Design 5 as the design system for my application while also incorporating custom styles using stylex. To centralize my color definitions, I've established the following variables in my globalTokens.stylex file:
Ant Design 5 requires me to configure primary colors within its own configuration flow. To avoid redundancy and repetition, I'm attempting to reference the values from
globalTokens.colors
in the Ant Design 5 configuration, as illustrated below:However, despite this approach, the colorPrimary consistently resolves to black on all Ant Design 5 buttons. It appears that the call to
colors.primaryColor
within Ant Design 5 is unresolvable. How can I successfully retrieve the value of primaryColor from the defined vars in globalTokens to ensure Ant Design 5 recognizes and utilizes it properly?Beta Was this translation helpful? Give feedback.
All reactions