Skip to content

Commit 9c87b06

Browse files
committed
feat: add support for custom spinners
1 parent a06c05f commit 9c87b06

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

frontend/src/components/Spinner/Spinner.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useMemo } from 'react'
22
import { useTranslation } from 'react-i18next'
33
import { BiLoader } from 'react-icons/bi'
44
import {
5+
Box,
56
Flex,
67
FlexProps,
78
Icon,
@@ -30,6 +31,11 @@ interface SpinnerProps extends FlexProps {
3031
*/
3132
label?: string
3233

34+
/**
35+
* Custom spinner element. If not provided, a default spinner icon will be used.
36+
*/
37+
element?: JSX.Element
38+
3339
/**
3440
* Font size of the spinner.
3541
*/
@@ -50,6 +56,7 @@ export const Spinner = ({
5056
color = 'inherit',
5157
label: userSpecifiedLabel,
5258
fontSize = '1rem',
59+
element,
5360
...flexProps
5461
}: SpinnerProps): JSX.Element => {
5562
const { t } = useTranslation()
@@ -66,12 +73,16 @@ export const Spinner = ({
6673
return (
6774
<Flex color={color} align="center" {...flexProps}>
6875
{label && <VisuallyHidden>{label}</VisuallyHidden>}
69-
<Icon
70-
animation={animation}
71-
as={BiLoader}
72-
fontSize={fontSize}
73-
aria-label="Spinner icon"
74-
/>
76+
{element ? (
77+
<Box animation={animation}>{element}</Box>
78+
) : (
79+
<Icon
80+
animation={animation}
81+
as={BiLoader}
82+
fontSize={fontSize}
83+
aria-label="Spinner icon"
84+
/>
85+
)}
7586
</Flex>
7687
)
7788
}

0 commit comments

Comments
 (0)