Skip to content
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

Custom "states" based on data variables #5087

Open
aleclarson opened this issue Apr 3, 2025 · 1 comment
Open

Custom "states" based on data variables #5087

aleclarson opened this issue Apr 3, 2025 · 1 comment

Comments

@aleclarson
Copy link
Contributor

Tokens have a variety of built-in states based on CSS pseudo selectors.

Image

What if there was a "Token State" type for data variables?

Image

These data variables would add a new option to each token's list of possible states.

Image

(The asterisk * is added to separate custom states from built-in ones, but could be any other visual indication you want.)

When a Token State variable exists, its data-* attribute also exists.

Image

When editing styles within this token state, the following CSS would be generated:

/* If this layer has data-enabled set to true... */
.c1234567[data-enabled="true"] {
  /* ... */
}

One question would be how we could use a parent layer's Token State variable to style a descendant. For example, the following CSS might be desirable in certain cases:

/* If any parent has data-enabled set to true... */
[data-enabled="true"] .c1234567 {
  /* ... */
}

Motivation

This feature would allow my designer to set arbitrary, domain-specific, data-driven styles.

@kof
Copy link
Member

kof commented Apr 3, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants