We keep our design system in its own WeWeb project and link it as a library to our other projects. The library holds the components and the color tokens. Brand colors (primary, secondary, tertiary) are different in every project, and we want the library components to pick up the project’s own colors without detaching them from the library.
What we see today: our library components reference color tokens by uid with a hardcoded fallback, like `var(–, #hex)`. A project that uses the library gets the library’s colors. We can create color tokens in the project, but the library components don’t use them.
A workaround that works
Give the component optional color props (for example “project primary”) and fall back to the library token when the prop is empty. The component stays linked to the library. The downside: every component that uses a brand color (buttons, labels, checkboxes) needs such a prop, and the project has to pass the value in each time. Typography and fonts have the same problem.
Our idea
Match tokens by name (or something). If a project has a token with exactly the same name (and folder) as a token in the library, the library component would use the project’s token instead of the library’s. Then the library can define everything once, and a project only overrides the colors it wants to change.
Questions:
- Does something like this exist, or is there an equivalent?
- How do you theme library components per project or brand?
- What problems did you run into, for example detached copies that drift out of sync with the library?
Thanks! Happy to share more details.