Skip to content

provide a custom TS-safe custom variant #4046

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
acidjazz opened this issue May 1, 2025 · 1 comment
Open

provide a custom TS-safe custom variant #4046

acidjazz opened this issue May 1, 2025 · 1 comment
Labels
bug Something isn't working needs reproduction triage v3 #1289

Comments

@acidjazz
Copy link
Contributor

acidjazz commented May 1, 2025

Environment

  • Operating System: Darwin
  • Node Version: v22.12.0
  • Nuxt Version: 3.17.1
  • CLI Version: 3.25.0
  • Nitro Version: 2.11.11
  • Package Manager: pnpm@10.6.2
  • Builder: -
  • User Config: modules, devtools, app, css, site, content, runtimeConfig, build, future, experimental, compatibilityDate, typescript, cookieControl, eslint, i18n, icon, image, ogImage, sitemap, turnstile
  • Runtime Modules: @vueuse/nuxt@13.1.0, @nuxt/eslint@1.3.0, @nuxt/ui-pro@3.1.0, @nuxtjs/sitemap@7.2.10, @nuxtjs/robots@5.2.10, @nuxt/content@3.5.1, nuxt-og-image@5.1.3, @nuxt/image@1.10.0, @nuxtjs/turnstile@1.0.0, @dargmuesli/nuxt-cookie-control@9.0.2, @nuxtjs/robots@5.2.10, nuxt-auth-utils@0.5.20, @nuxtjs/i18n@9.5.3
  • Build Modules: -

Version

v3.1.0

Reproduction

not needed for this situation

Description

I'm hoping this just turns into a question, but I'm trying to figure out if custom variants are supported by TypeScript, I tried adding a variant to a button using this methodology:

     button: {
      variants: {
        variant: {
          gradient: 'shadow-sm shadow-emerald-300/5 border border-emerald-300/10 hover:shadow hover:border-emerald-300 hover:shadow-emerald-300 transition-all duration-200 text-white bg-gradient-to-br from-logo-a via-logo-a-dark to-logo-a focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-{color}-500 dark:focus-visible:outline-{color}-400',
        },
      },
      defaultVariants: {
        color: 'neutral',
        variant: 'subtle',
      },
      default: {
        color: 'white',
        loadingIcon: 'i-mdi-loading',
      },
    },

I also tried adding it via compoundVariants as well - and while this strategy works fine in both situations, I get TS errors whenever I try to apply it at the component.

Type '"gradient"' is not assignable to type '"solid" | "outline" | "soft" | "subtle" | "ghost" | "link" | undefined'.ts-plugin(2322)
Image

Am I doing something wrong? Or is TS support for variants just not completed yet?

Additional context

No response

Logs

@acidjazz acidjazz added bug Something isn't working triage labels May 1, 2025
Copy link
Member

Could you provide a reproduction? This should work out of the box!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction triage v3 #1289
Projects
None yet
Development

No branches or pull requests

2 participants