Skip to content

feat(generator): export tokens individually (WIP) #3300

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juanrgm
Copy link
Contributor

@juanrgm juanrgm commented Jun 30, 2025

📝 Description

Export tokens individually for tree shaking (+30kb savings).

⛳️ Current behavior (updates)

All tokens are exported in one single object.

🚀 New behavior

Tokens are still exported in a single object, but a new variable (tokens) is available to store all the individually exported tokens.

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

No.

📝 Additional Information

There are some issues to address due to the character limit on JS variable names. This has been resolved as follows.

If the variable name is valid, the token can be accessed directly:

import { tokens } from "../styled-system/tokens"
tokens.colors_500

If the variable name is invalid, it will be accessed via a map (e.g., tokens.$['sizes.special_Name!']).

To maintain a similarity with tokens, an exception has been made so that negative numbers cannot be exported in variables: spacing.-1 will be converted to spacing_n1.

There are still some tokens with names that are not allowed due to the use of the (-) character (

):

  • easings.in-out
  • sizes.breakpoint-sm
  • sizes.breakpoint-md
  • sizes.breakpoint-lg
  • sizes.breakpoint-xl
  • sizes.breakpoint-2xl

You can always transform - into _ to allow it to be exported, but this causes conflicts (e.g., easings.in_out and easings.in-out would use the same name).

Another solution for later is to limit the characters allowed in the tokens.

Copy link

vercel bot commented Jun 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
panda-docs ❌ Failed (Inspect) Jun 30, 2025 9:24am
panda-playground ✅ Ready (Inspect) Visit Preview Jun 30, 2025 9:24am
panda-studio ✅ Ready (Inspect) Visit Preview Jun 30, 2025 9:24am

Copy link

changeset-bot bot commented Jun 30, 2025

🦋 Changeset detected

Latest commit: 0519505

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@pandacss/generator Minor
@pandacss/node Minor
@pandacss/parser Minor
@pandacss/reporter Minor
@pandacss/astro-plugin-studio Minor
@pandacss/dev Minor
@pandacss/postcss Minor
@pandacss/studio Minor
@pandacss/config Minor
@pandacss/core Minor
@pandacss/extractor Minor
@pandacss/is-valid-prop Minor
@pandacss/logger Minor
@pandacss/preset-atlaskit Minor
@pandacss/preset-base Minor
@pandacss/preset-open-props Minor
@pandacss/preset-panda Minor
@pandacss/shared Minor
@pandacss/token-dictionary Minor
@pandacss/types Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another 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