Skip to content

Commit

Permalink
feat: style for the checkbox component (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
gerzon05 authored Aug 16, 2024
1 parent c3f070b commit 8ef4683
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/forms/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { checkbox, cn } from '@/tailwind'
export interface Comp extends React.ElementRef<typeof CheckboxPrimitive.Root> {}
export type Props = React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> & VariantProps<typeof checkbox>

const Checkbox = React.forwardRef<Comp, Props>(({ className, color, rounded, ...props }, ref) => (
const Checkbox = React.forwardRef<Comp, Props>(({ className, variant, rounded, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(checkbox({ color, rounded }), className)}
className={cn(checkbox({ variant, rounded }), className)}
{...props}
>
<CheckboxPrimitive.Indicator>
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/components/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { cva } from 'class-variance-authority'
*/
export const checkbox = cva('peer size-4 shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', {
variants: {
color: {
variant: {
default: 'data-[state=checked]:bg-default data-[state=checked]:text-default-foreground border border-default',
primary: 'data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground border border-primary',
success: 'data-[state=checked]:bg-success data-[state=checked]:text-success-foreground border border-success',
Expand All @@ -23,9 +23,15 @@ export const checkbox = cva('peer size-4 shrink-0 focus-visible:outline-none foc
md: 'rounded-medium',
lg: 'rounded-large',
},
size: {
sm: 'size-4',
md: 'size-5',
lg: 'size-6',
},
},
defaultVariants: {
color: 'default',
variant: 'default',
rounded: 'sm',
size: 'sm',
},
})

0 comments on commit 8ef4683

Please sign in to comment.