11import { type VariantProps , cva } from "cva"
2- import type { ComponentPropsWithRef , ElementType , PropsWithChildren , ReactNode } from "react"
2+ import type { ElementType , HTMLAttributes , PropsWithChildren , ReactNode , Ref } from "react"
33import { cn } from "../../utils"
44
5- // Add variants, colors, or sizes in the arrays below
6- // to add them to the component
75export const BUTTON_VARIANTS = [ "solid" , "outline" , "text" , "unstyled" ] as const
86export const BUTTON_COLORS = [ "light" , "dark" , "brand" , "blue" , "red" ] as const
97export const BUTTON_SIZES = [ "sm" , "md" , "lg" ] as const
@@ -12,21 +10,23 @@ export type ButtonVariant = (typeof BUTTON_VARIANTS)[number]
1210export type ButtonColor = ( typeof BUTTON_COLORS ) [ number ]
1311export type ButtonSize = ( typeof BUTTON_SIZES ) [ number ]
1412
15- export type ButtonProps < E extends ElementType = "button" > = VariantProps < typeof button > &
16- PropsWithChildren & {
17- /**
18- * The HTML element to render the button as
19- *
20- * Defaults to an HTML <button> element, but can be used with the Link
21- * component from 'next/link' to create a link that looks like a button
22- */
23- element ?: E
13+ export type ButtonProps = VariantProps < typeof button > &
14+ PropsWithChildren &
15+ Omit < HTMLAttributes < HTMLElement > , "color" > & {
16+ element ?: ElementType
2417 className ?: string
2518 icon ?: ReactNode
2619 iconRight ?: ReactNode
27- } & ComponentPropsWithRef < E >
20+ ref ?: Ref < HTMLElement >
21+ href ?: string
22+ type ?: "button" | "submit" | "reset"
23+ disabled ?: boolean
24+ target ?: string
25+ rel ?: string
26+ prefetch ?: boolean
27+ }
2828
29- export function Button < E extends ElementType = "button" > ( {
29+ export function Button ( {
3030 element,
3131 children,
3232 variant,
@@ -37,7 +37,7 @@ export function Button<E extends ElementType = "button">({
3737 className,
3838 ref,
3939 ...props
40- } : ButtonProps < E > ) {
40+ } : ButtonProps ) {
4141 const Component = element ?? "button"
4242 const classes = cn ( button ( { variant, size, color } ) , "inline-flex items-center justify-center gap-1" , className )
4343 return (
@@ -89,7 +89,6 @@ export const button = cva(
8989 color : "light" ,
9090 variant : "solid" ,
9191 className : [
92- // Not using `enabled:` to make it easier to override
9392 "bg-gray-200 hover:bg-gray-100 disabled:hover:bg-gray-200" ,
9493 "dark:bg-stone-700 dark:hover:bg-stone-600 dark:disabled:hover:bg-stone-700" ,
9594 ] . join ( " " ) ,
0 commit comments