Skip to content

StackOverflowIsBetterThanAnyAI/fetch-loading

Repository files navigation

Fetch Loading

npm Downloads Last Year

React loading animation which can be displayed while data is fetched from an API.

Installation

npm i fetch-loading

Usage

import { FetchLoading } from 'fetch-loading'

...

<FetchLoading />

### with no arguments being passed,
### the animation will fall back to its default color #52525c,
### and it will not contain any accessible attributes

...

Default Fetch Loading Animation Preview

You can also pass any Hex- / RGB- or RGBA-value as an argument for the theme property:

...

<FetchLoading theme="#121" />

<FetchLoading theme="#608c" />

<FetchLoading theme="#ffe98c" />

<FetchLoading theme="#ff1e2cf0" />

<FetchLoading theme="rgb(178, 165, 253)" />

<FetchLoading theme="rgba(131, 240, 131, 0.8)" />

...

Theme Fetch Loading Animation Preview

By passing a descriptive value for ariaLabel, the following properties are added:

...

<FetchLoading ariaLabel="Loading" />

### role="status"
### aria-live="polite"
### aria-label="Loading"

...

This results in screen reader users hearing “Status - Loading” being read aloud.

Of course, theme and ariaLabel can also be used simultaneously:

...

<FetchLoading ariaLabel="Loading" theme="#ffe98c"/>

...

About

React loading animation which can be displayed while data is fetched from an API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •