Skip to content

Commit 66a11f9

Browse files
committed
refactor: remove slot support for button component
1 parent 2c9545a commit 66a11f9

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

apps/docs/src/components/ui/button.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { cn } from '@repo/ui/utils/cn'
22
import { cva, type VariantProps } from 'cva'
3-
import { Slot } from 'radix-ui'
43

54
const buttonVariants = cva({
65
base: [
@@ -38,16 +37,14 @@ const buttonVariants = cva({
3837
}
3938
})
4039

41-
type ButtonProps = React.ComponentProps<'button'> &
42-
VariantProps<typeof buttonVariants> & {
43-
asChild?: boolean
44-
}
40+
type ButtonProps = React.ComponentProps<'button'> & VariantProps<typeof buttonVariants>
4541

4642
const Button = (props: ButtonProps) => {
47-
const { className, variant, size, asChild = false, ...rest } = props
48-
const Comp = asChild ? Slot.Root : 'button'
43+
const { className, variant, size, type = 'button', ...rest } = props
4944

50-
return <Comp data-slot='button' className={cn(buttonVariants({ variant, size, className }))} {...rest} />
45+
return (
46+
<button data-slot='button' className={cn(buttonVariants({ variant, size, className }))} type={type} {...rest} />
47+
)
5148
}
5249

5350
export { Button, buttonVariants }

packages/ui/src/components/button.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { cva, type VariantProps } from 'cva'
2-
import { Slot } from 'radix-ui'
32

43
import { cn } from '../utils/cn'
54

@@ -39,16 +38,14 @@ const buttonVariants = cva({
3938
}
4039
})
4140

42-
type ButtonProps = React.ComponentProps<'button'> &
43-
VariantProps<typeof buttonVariants> & {
44-
asChild?: boolean
45-
}
41+
type ButtonProps = React.ComponentProps<'button'> & VariantProps<typeof buttonVariants>
4642

4743
const Button = (props: ButtonProps) => {
48-
const { className, variant, size, asChild = false, ...rest } = props
49-
const Comp = asChild ? Slot.Root : 'button'
44+
const { className, variant, size, type = 'button', ...rest } = props
5045

51-
return <Comp data-slot='button' className={cn(buttonVariants({ variant, size, className }))} {...rest} />
46+
return (
47+
<button data-slot='button' className={cn(buttonVariants({ variant, size, className }))} type={type} {...rest} />
48+
)
5249
}
5350

5451
export { Button, buttonVariants }

0 commit comments

Comments
 (0)