Replies: 2 comments 1 reply
-
Good question! Thinking out loud... Stitches basically pre-compiles all the styles and uses css variables to map the theme values to styles that are generated. so you'd probably need to / want to somehow override all those variables in your app // In stitches.config.js of your UI library
const { styled } = createStitches({
theme: {
colors: { primary: 'tomato' }
}
});
// In component:
const Button = styled('button', {
backgroundColor: '$primary' // var(--stitches-color-primary)
}); Then in your app: <style>
:root {
--stitches-color-primary: cadetblue;
}
</style> Just thinking out loud on this, would be keen to know other people's thoughts. For dark mode, internally in our UI we basically use the same concept... |
Beta Was this translation helpful? Give feedback.
-
I've got pretty much the same question. What's the right way of creating a UI component library that is styled with Stitches, which can be easily customised with a different theme or extended. The fact that each component is supposed to be styled with a // ./application/theme.ts
import { createStitches } from "@stitches/react";
export const { styled } = createStitches({ /* ... */ }); // ./ui-library/component.tsx
import { styled } from "../application/theme"; // <= this dependency is not supposed to be here
const Button = styled("button", {/* ... */}); |
Beta Was this translation helpful? Give feedback.
-
Lets say we have an UI library built with stitches. Now we're using this UI library in a project which needs to override the theme tokens for all the components. (i.e primary color or spacings)
in Material-UI you can
createTheme
and pass down thetheme
object viaThemeProvider
and it's going to let the components override the tokens. This approach requires runtime operations.How can I achieve the same thing using stitches. (sorry I'm a newbie to stitches)
Beta Was this translation helpful? Give feedback.
All reactions