File size: 544 Bytes
87337b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { Button, ButtonProps } from "@/components/ui/button"
import { AnimatedSpinnerIcon } from "@/components/Icon"

export interface LoadingButtonProps extends Omit<ButtonProps, "asChild"> {
  loading?: boolean
  svgProps?: React.SVGProps<SVGSVGElement>
}

export function LoadingButton(props: LoadingButtonProps) {
  const { loading, disabled, children, svgProps, ...rest } = props
  return (
    <Button {...rest} disabled={loading || disabled}>
      {loading && <AnimatedSpinnerIcon {...svgProps} />}
      {children}
    </Button>
  )
}