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

Duplicate style properties on checkbox component #2424

Closed
Sveagruva opened this issue Jan 14, 2024 · 4 comments
Closed

Duplicate style properties on checkbox component #2424

Sveagruva opened this issue Jan 14, 2024 · 4 comments
Labels

Comments

@Sveagruva
Copy link

generated checkbox component with a cli contains duplicated styles border-gray-200 border-gray-900 and dark:border-gray-800 dark:border-gray-50:

`
import * as React from "react"
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { CheckIcon } from "@radix-ui/react-icons"

import { cn } from "@/lib/utils"

const Checkbox = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef

(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-slate-200 border-slate-900 shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-slate-950 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-slate-900 data-[state=checked]:text-slate-50 dark:border-slate-800 dark:border-slate-50 dark:focus-visible:ring-slate-300 dark:data-[state=checked]:bg-slate-50 dark:data-[state=checked]:text-slate-900",
className
)}
{...props}

<CheckboxPrimitive.Indicator
  className={cn("flex items-center justify-center text-current")}
>
  <CheckIcon className="h-4 w-4" />
</CheckboxPrimitive.Indicator>

</CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName

export { Checkbox }

`

my components.json (changing cssVariables to true fixes it):

{ "$schema": "https://ui.shadcn.com/schema.json", "style": "default", "rsc": false, "tsx": true, "tailwind": { "config": "tailwind.config.ts", "css": "src/styles/globals.css", "baseColor": "gray", "cssVariables": false, "prefix": "" }, "aliases": { "components": "@/components", "utils": "@/lib/utils" } }

@pnodet
Copy link

pnodet commented Jan 24, 2024

Running into the same issue.

From what I can see: through transformCssVars the border is replaced by border border-border at the beginning of applyColorMapping but then it results to duplicated color classnames. The issue was previously reported in #692 it should have been resolved by this PR #1089

The PR uses a Set instead of an Array to avoid duplicates but with the current bug we get border-gray-200 border-gray-900 which are not filtered by the Set trick.

@Cielquan
Copy link

The same issue goes for the radio-group component. Just wrote a comment in the other issue because I was too blind to see this issue here: #692 (comment)

@shadcn shadcn added the Stale label Feb 9, 2024
@shadcn
Copy link
Collaborator

shadcn commented Feb 16, 2024

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

@shadcn shadcn closed this as completed Feb 16, 2024
@pnodet
Copy link

pnodet commented Feb 17, 2024

@shadcn I don't think this should be closed

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

No branches or pull requests

4 participants