Skip to content

Commit 057b42a

Browse files
support accessibility by adding an optional ariaLabel property
1 parent f537978 commit 057b42a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/FetchLoading.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { FC } from 'react'
22
import './index.css'
33

44
type FetchLoadingProps = {
5+
ariaLabel?: string
56
theme?: string
67
}
78
type DotProps = {
@@ -38,10 +39,15 @@ const Dot: FC<DotProps & FetchLoadingProps> = ({ delay, theme }) => {
3839
)
3940
}
4041

41-
export const FetchLoading: FC<FetchLoadingProps> = ({ theme }) => {
42+
export const FetchLoading: FC<FetchLoadingProps> = ({ ariaLabel, theme }) => {
4243
return (
4344
<>
44-
<div style={{ display: 'flex', gap: '8px', padding: '6px 2px' }}>
45+
<div
46+
role={ariaLabel ? 'status' : undefined}
47+
aria-label={ariaLabel}
48+
aria-live={ariaLabel ? 'polite' : undefined}
49+
style={{ display: 'flex', gap: '8px', padding: '6px 2px' }}
50+
>
4551
<Dot delay={0} theme={theme} />
4652
<Dot delay={-1.33} theme={theme} />
4753
<Dot delay={-0.67} theme={theme} />

0 commit comments

Comments
 (0)