Support CoreUI Development

CoreUI is an MIT-licensed open source project and is completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.

You can support our Open Source software development in the following ways:

  • Buy the CoreUI PRO, and get access to PRO components, and dedicated support.
  • Became a sponsor, and get your logo on BACKERS.md/README.md files or each site of this documentation
  • Give us a star ⭐️ on Github.

React Spinner Component

Indicate the loading state of a component or page with CoreUI spinners, built entirely with HTML, CSS, and no JavaScript.

Other frameworks

CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and Vue components. To learn more please visit the following pages.

About#

CoreUI "spinners" can be used to show the loading state in your projects. They're built only with HTML and CSS, meaning you don't need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, alignment, and sizing can be easily customized with our amazing utility classes.

For accessibility purposes, each loader here includes role="status" and a nested <span className="visually-hidden">Loading...</span>.

Border spinner#

Use the border spinners for a lightweight loading indicator.

Basic usage#

Loading...
1<CSpinner/>

Colors#

The border spinner uses currentColor for its border-color. You can use any of our text color utilities on the standard spinner.

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
1<CSpinner color="primary"/>
2 <CSpinner color="secondary"/>
3 <CSpinner color="success"/>
4 <CSpinner color="danger"/>
5 <CSpinner color="warning"/>
6 <CSpinner color="info"/>
7 <CSpinner color="light"/>
8 <CSpinner color="dark"/>

Growing spinner#

If you don't fancy a border spinner, switch to the grow spinner. While it doesn't technically spin, it does repeatedly grow!

Loading...
1<CSpinner variant="grow"/>

Once again, this spinner is built with currentColor, so you can easily change its appearance. Here it is in blue, along with the supported variants.

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
1<CSpinner color="primary" variant="grow"/>
2 <CSpinner color="secondary" variant="grow"/>
3 <CSpinner color="success" variant="grow"/>
4 <CSpinner color="danger" variant="grow"/>
5 <CSpinner color="warning" variant="grow"/>
6 <CSpinner color="info" variant="grow"/>
7 <CSpinner color="light" variant="grow"/>
8 <CSpinner color="dark" variant="grow"/>

Size#

Add size="sm"property` to make a smaller spinner that can quickly be used within other components.

Loading...
Loading...
1<CSpinner size="sm"/>
2 <CSpinner size="sm" variant="grow"/>

Buttons#

Use spinners within buttons to indicate an action is currently processing or taking place. You may also swap the text out of the spinner element and utilize button text as needed.

1<CButton disabled>
2 <CSpinner component="span" size="sm" aria-hidden="true"/>
3 </CButton>
4 <CButton disabled>
5 <CSpinner component="span" size="sm" aria-hidden="true"/>
6 Loading...
7 </CButton>
1<CButton disabled>
2 <CSpinner component="span" size="sm" variant="grow" aria-hidden="true"/>
3 </CButton>
4 <CButton disabled>
5 <CSpinner component="span" size="sm" variant="grow" aria-hidden="true"/>
6 Loading...
7 </CButton>

Customizing#

CSS variables#

React spinners use local CSS variables on .spinner-border and .spinner-grow for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

Border spinner variables:

1--cui-spinner-width: #{$spinner-width};
2--cui-spinner-height: #{$spinner-height};
3--cui-spinner-vertical-align: #{$spinner-vertical-align};
4--cui-spinner-border-width: #{$spinner-border-width};
5--cui-spinner-animation-speed: #{$spinner-animation-speed};
6--cui-spinner-animation-name: spinner-border;

Growing spinner variables:

1--cui-spinner-width: #{$spinner-width};
2--cui-spinner-height: #{$spinner-height};
3--cui-spinner-vertical-align: #{$spinner-vertical-align};
4--cui-spinner-animation-speed: #{$spinner-animation-speed};
5--cui-spinner-animation-name: spinner-grow;

For both spinners, small spinner modifier classes are used to update the values of these CSS variables as needed. For example, the .spinner-border-sm class does the following:

1--cui-spinner-width: #{$spinner-width-sm};
2--cui-spinner-height: #{$spinner-height-sm};
3--cui-spinner-border-width: #{$spinner-border-width-sm};

How to use CSS variables#

1const vars = {
2 '--my-css-var': 10,
3 '--my-another-css-var': "red"
4}
5return <CSpinner style={vars}>...</CSpinner>

SASS variables#

1$spinner-width: 2rem;
2$spinner-height: $spinner-width;
3$spinner-vertical-align: -.125em;
4$spinner-border-width: .25em;
5$spinner-animation-speed: .75s;
6
7$spinner-width-sm: 1rem;
8$spinner-height-sm: $spinner-width-sm;
9$spinner-border-width-sm: .2em;

API#

CSpinner#

1import { CSpinner } from '@coreui/react'
2// or
3import CSpinner from '@coreui/react/src/components/spinner/CSpinner'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-
componentComponent used for the root node. Either a string to use a HTML element or a component.string | ComponentClass<any, any> | FunctionComponent<any>-
sizeSize the component small.'sm'-
variantSet the button variant to an outlined button or a ghost button.'border' | 'grow'border
visuallyHiddenLabelSet visually hidden label for accessibility purposes.stringLoading...