Skip to content

feat: allow nested conditions to be used in tokens#10181

Open
tryone144 wants to merge 1 commit into
chakra-ui:mainfrom
tryone144:nested-rules-for-tokens
Open

feat: allow nested conditions to be used in tokens#10181
tryone144 wants to merge 1 commit into
chakra-ui:mainfrom
tryone144:nested-rules-for-tokens

Conversation

@tryone144
Copy link
Copy Markdown
Contributor

📝 Description

Allow using 'nested' conditions when defining (semantic) tokens. One such example is the existing _hover condition that resolves to

[ "@media (hover: hover)",
  "&:is(:hover, [data-hover]):not(:disabled, [data-disabled])" ]

for nesting the actual selector inside the @media-query.

⛳️ Current behavior (updates)

Using a condition that is not a simple string fails with TypeError: selector.startsWith is not a function here. This is true for the default _hover condition here.

🚀 New behavior

This PR updates the check for conditions that consist of only media-queries to support conditions that are of type string[] (like the default _hover). This then allows users to add and use their own conditions.

Our project would like to overwrite the default _dark selector to only apply on @media not print which requires this feature.

💣 Is this a breaking change (Yes/No):

No

@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chakra-ui-storybook Ready Ready Preview Mar 8, 2026 9:31pm
chakra-v3-docs Ready Ready Preview Mar 8, 2026 9:31pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 22, 2025

⚠️ No Changeset found

Latest commit: 78e6325

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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

Successfully merging this pull request may close these issues.

1 participant