-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Theme: Include Figma scopes extension in design tokens #73897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Now that I think of it, it probably makes sense to go through our other tokens and add applicable scopes as well. For example, "GAP" for Edit: Added in b22d6e3. |
mirka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need someone to confirm, but this isn't working for me 😕 The screen recording is for dimension, but same with color. It's the latest version of Figma.
CleanShot.2025-12-12.at.19-44-40.mp4
packages/theme/tokens/dimension.json
Outdated
| } | ||
| }, | ||
| "$extensions": { | ||
| "com.figma.scopes": [ "GAP" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both gap and padding don't seem to be scoped 🤔
|
Colors seem to be scoped correctly for me 👍 Border width interactive doesn't seem to be scoped. Neither do any of the dimension tokens.
Edit: I just read the OP :) Variables can be unscoped in the UI, even when aliased. I suppose we'll have to do this manually in Figma for now. |
I would like to, and it feels like something that Figma should support, as in: If I specify scopes as an empty array, those primitives should be effectively hidden, right? Unfortunately that doesn't seem to be working as expected, mentioned in the original comment:
Although maybe the issues y'all have flagged will lead me to some sudden "ah-ha!" of what I'm doing wrong (unlikely, but there's hope yet 😅 ). |
|
Oh, I just noticed that border colors are scoped to 'Effects' rather than 'Stroke'. |
|
Typography tokens are also unscoped. I'm wondering if all the unscoped tokens are a 'me' problem 🙈 |
b22d6e3 to
8fbb711
Compare
|
I've not been able to reproduce the issue y'all are seeing with the scopes not being properly assigned 😬 The typography scopes were unscoped though. This was semi-intentional as the typography tokens are very unfinished, though based on the changes I explored separately in #73931, I don't think the structure will need to radically change, so I went ahead and added them here. |
|
I asked AI and was able to fix the dimension tokens in 696d5f2.
|
|
Seems we were using the wrong scope name for stroke. I fixed that (and removed effects as I don't think it's needed) in bf1e67f. |
|
Tokens are now all importing with correct scoping for me. |
|
Hm, neither of those changes make particular sense to me, but if it's working then it's working and I'm not gonna fight it 😄 Per your quoted AI conversation:
The individual tokens didn't define
Figma's official documentation mentions https://developers.figma.com/docs/plugins/api/VariableScope/ |
| * @param extensions - The extensions object to copy. | ||
| * @return A new extensions object without the 'mode' key. | ||
| */ | ||
| function copyExtensionsWithoutMode( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jameskoster What were these changes for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the changes I made to fix scoping, running npm run --workspace @wordpress/theme build was stripping the scope definitions from the .json files in /modes. This was entirely AI generated so please fix any slop 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I see now. Yes, without this, the overrides files won't include $extensions. But my understanding of how Figma imports the mode overrides is that they only override differences, i.e. the absence of scopes means it'll inherit the scopes from the value it overrides.
In my own testing, this seems to work as expected. The GAP scope is still applied to "compact" density overrides even without explicit com.figma.scopes extension because it's applied to the original value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in my initial test it was working opposite to how you describe. When the modes weren't scoped, importing was them was unsetting the scope of all tokens.
But I just reverted this change, rebuilt the tokens, and it's working fine 😅 At this point I don't know if it's the importer that's bugged or me... probably the latter.
The dimensions tokens did, no? There's a
That's so strange 😅 It goes without saying; hopefully someone else can test these changes before merging. |
Well, it does seem to still work for me in applying "Stroke" scope using the (seemingly-invalid)
|
|
At this point the only thing I'm concerned is if we can avoid the changes to the mode plugin. @jameskoster would you mind testing what I described to see if the scopes are still applied for the mode overrides even if the |
This reverts commit 2cae2ff.

What?
Updates theme package design tokens to include Figma scope extensions, such that importing the tokens will assign the valid scopes in Figma accordingly.
Follow-on to #73859 (specifically #73859 (comment))
Why?
Ensure that tokens are only available for use in relevant contexts (e.g. "stroke" tokens should be used in "stroke" fields in Figma).
How?
Adds a Figma-supported
$extensionsfield specifying scopes for tokens.Extensions are intended for these sorts of proprietary vendor data.
I could not find any documentation which describes this field, but it was discovered via reverse-engineering by exporting variables out of Figma that already had the scopes assigned.
I was curious to try to effectively "hide" primitive token values by assigning
"com.figma.scopes": [], but this did not work as expected. My hunch is that Figma won't allow them to be unscoped since they are aliased by other variables.Documentation of available scopes can be found on Figma Developers site: https://developers.figma.com/docs/plugins/api/VariableScope/
Testing Instructions
Screenshots or screencast