Restricting colour tokens per property #3425
loicplaire
started this conversation in
Ideas
Replies: 2 comments 5 replies
|
This is an interesting idea that might be worth implementing. |
2 replies
|
Interesting idea! We're considering supporting dot-paths in the utility First, structure your tokens by intent: export default defineConfig({
theme: {
tokens: {
colors: {
surface: {
default: { value: '#ffffff' },
accent: { value: '#3d1cba' },
},
border: {
default: { value: '#dfe0e6' },
accent: { value: '#3d1cba' },
},
text: {
default: { value: '#1e163c' },
danger: { value: '#c00' },
},
},
},
},
})Then scope utilities to specific token groups: export default defineConfig({
utilities: {
backgroundColor: {
values: 'colors.surface',
},
borderColor: {
values: 'colors.border',
},
color: {
values: 'colors.text',
},
},
})With This encourages organizing tokens by intent rather than by visual property, which tends to scale better for design systems. Would this approach work for your use case? @loicplaire @zslabs |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, thanks for Panda CSS, it has been great to work with so far!
I have colour tokens that are roughly structured like this:
{ "grey-50": { "value": "#ffffff", "type": "color" }, "grey-500": { "value": "#dfe0e6", "type": "color" }, "purple-900": { "value": "#3d1cba", "type": "color" }, "surface-color": { "value": "{grey-50}", "type": "color", }, "surface-color-accent": { "value": "{purple-900}", "type": "color", }, "border-color": { "value": "{grey-500}", "type": "color", }, "border-color-accent": { "value": "{purple-900}", "type": "color", }, "text-color": { "value": "#1e163c", "type": "color", }, "text-color-danger": { "value": "{red-900}", "type": "color", } }Ideally I would like:
surface-*tokensborder-*tokenstext-*tokensFor example:
Is this kind of per property restriction currently possible in Panda, based on the token name or group? Or are all colour tokens always treated as part of a single colours space?
Thanks a lot for your help!
All reactions