1
- import { Button , ButtonProps } from '@mui/material' ;
1
+ 'use client' ;
2
+
3
+ import * as React from 'react' ;
4
+ import { Button as MaterialButton } from '@mui/material' ;
2
5
import { styled } from '@mui/material/styles' ;
6
+ import { Slot } from '@radix-ui/react-slot' ;
3
7
4
- export const StyledButton = styled ( Button ) < ButtonProps > ( ( ) => ( {
5
- color : '#fff' ,
6
- '&:hover' : {
7
- backgroundColor : 'rgb(255 255 255 / .15)' ,
8
+ import { tv , type VariantProps } from 'tailwind-variants' ;
9
+ import clsx from 'clsx' ;
10
+
11
+ const buttonVariants = tv ( {
12
+ base : 'inline-flex items-center justify-center align-middle whitespace-nowrap font-semibold transition' ,
13
+ variants : {
14
+ variant : {
15
+ primary : 'bg-primary text-white hover:bg-opacity-80' ,
16
+ } ,
17
+ size : {
18
+ md : 'h-10 text-sm px-4 rounded-lg' ,
19
+ } ,
8
20
} ,
9
- } ) ) ;
21
+ defaultVariants : {
22
+ variant : 'primary' ,
23
+ size : 'md' ,
24
+ } ,
25
+ } ) ;
26
+
27
+ export interface ButtonProps
28
+ extends React . ButtonHTMLAttributes < HTMLButtonElement > ,
29
+ VariantProps < typeof buttonVariants > {
30
+ asChild ?: boolean ;
31
+ }
32
+
33
+ const Button = React . forwardRef < HTMLButtonElement , ButtonProps > (
34
+ ( { className, variant, size, asChild = false , ...props } , ref ) => {
35
+ const Comp = asChild ? Slot : 'button' ;
36
+ return (
37
+ < Comp
38
+ className = { clsx ( buttonVariants ( { variant, size } ) , className ) }
39
+ ref = { ref }
40
+ { ...props }
41
+ />
42
+ ) ;
43
+ }
44
+ ) ;
10
45
11
- export const StyledLinkButton = styled ( Button ) < ButtonProps > ( ( ) => ( {
46
+ export default Button ;
47
+
48
+ export const StyledLinkButton = styled ( MaterialButton ) < ButtonProps > ( ( ) => ( {
12
49
color : '#fff' ,
13
50
textTransform : 'none' ,
14
51
fontFamily : 'var(--font-inter)' ,
@@ -18,5 +55,3 @@ export const StyledLinkButton = styled(Button)<ButtonProps>(() => ({
18
55
backgroundColor : 'rgb(255 255 255 / .15)' ,
19
56
} ,
20
57
} ) ) ;
21
-
22
- export default StyledButton ;
0 commit comments