How to apply conditional sprinkles across multiple variants, states and themes? #1012
Replies: 2 comments 14 replies
-
@askoufis do you know if the above is possible using |
Beta Was this translation helpful? Give feedback.
-
I've finally figured it out, I think. I'm not sure if there's a better way or not, but I've managed to swap out Light/Dark themes with this one. https://vanilla-extract.style/documentation/packages/dynamic/ Basically, I've got this const export const themeVars = createThemeContract({
colors: {
hover: null,
textPrimary: null,
textSecondary: null,
textTertiary: null,
bg: null,
bgSecondary: null,
bgButton: null,
borderMain: null,
}
}); and then two consts, something like this - const colors = {
hover: '#555657',
textPrimary: '#fff',
textSecondary: '#787878',
textTertiary: '#AAAAAA',
bg: '#222323',
bgSecondary: '#222323',
bgButton: '#555657',
borderMain: '#787878',
};
export const darkTheme = {
colors
}; Then in root I'm changing it like this - export const [themeMode, setThemeMode] = createSignal('dark');
export default function Root() {
let html;
const value = createI18nContext(languageDict, 'en');
onMount(() => {
createEffect(() => setElementVars(html, themeVars, themeMode() === 'dark' ? darkTheme : lightTheme));
});
return (
<Html lang="en" ref={html}>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I just recently discovered
vanilla-extract
and I really like what I have seen thus far! I'm in the process of creating a component library and am working on the theme for library. For context, the theme I'm trying to implement has two axes to it:With the above, I'm looking to do something like the following for a custom
button
component with multiple variants:I'm pretty sure I have to make use of
sprinkles
in some way, shape or form since it supports the conditional styling. I just don't know how to achieve the complex conditional styling for bothcolorMode
anddensity
in all button states likedefault
,hover
anddisabled
. Does anyone know how I can achieve this? Is this even possible currently?Beta Was this translation helpful? Give feedback.
All reactions