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

feat(shadcn): allow removal of variables from external registries #5194

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

Conversation

bcorbold
Copy link
Contributor

@bcorbold bcorbold commented Oct 2, 2024

Allows external registries to remove CSS / tailwind variables that are not being used by their systems

Use case

We are building out our component registry for internal use but have chosen to use our own named tokens for theming

Currently, if we wanted to remove the defaults, that requires a manual step for our consumers to delete those CSS variables/tailwind colours manually after running shadcn init.

We've worked around this temporarily by having our own cli that calls shadcn init and removes those variables

Proposal

Update schemas/utils to allow null when defining cssVariables or in the tailwind properties to remove them when running shadcn add .... This should allow us to remove our own cli to fully leverage the shadcn tooling 🎉

// http://localhost:3000/registry/theme-foo.json
{
  "theme": "theme-foo",
  "type": "registry:theme",
  "cssVars": {
    "light": {
      "card": null,
      "card-foreground": null,
      "info": "210.8 100% 56.9%"
    },
    "dark": {
      "card": null,
      "card-foreground": null
    }
  },
  "tailwind": {
    "config": {
      "theme": {
        "extend": {
          "colors": {
            "card": null,
            "info": "hsl(var(--info))"
          }
        }
      }
    }
  }
}

After running pnpx shadcn@latest add http://localhost:3000/registry/theme-foo.json this should:

  1. Remove --card, and --card-foreground from the globals.css file
  2. Add --info to the globals.css file
  3. Remove theme.extend.colors.card from tailwind.config.ts
  4. Add theme.extend.colors.info to tailwind.config.ts

Allows external registries to remove default variables that are not being used
Copy link

vercel bot commented Oct 2, 2024

@bcorbold is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

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