aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/common/button/LoadingButton.tsx
blob: fd1c19b3e2e5a50a033a1016441f6f8bc85432e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import React from "react";

const LoadingButton: React.FC<{ loading?: boolean } & ButtonProps> = ({
  loading,
  variant,
  disabled,
  ...otherProps
}) => {
  return (
    <Button
      variant={variant != null ? `outline-${variant}` : "outline-primary"}
      disabled={disabled || loading}
      {...otherProps}
    >
      {otherProps.children}
      {loading ? (
        <Spinner
          className="ms-1"
          variant={variant}
          animation="grow"
          size="sm"
        />
      ) : null}
    </Button>
  );
};

export default LoadingButton;