Bootstrap React Spinner
Indicate the loading state of a component or page with Bootstrap React Spinners, built entirely with HTML, CSS, and no JavaScript.
About#
Bootstrap React "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#
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.
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!
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.
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.
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>
API#
CSpinner#
1import { CSpinner } from '@coreui/bootstrap-react'2// or3import CSpinner from '@coreui/bootstrap-react/src/components/spinner/CSpinner'
Property | Description | Type | Default |
---|---|---|---|
className | A string of all className you want applied to the component. | string | - |
color | Sets the color context of the component to one of Bootstrap React’s themed colors. | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string | - |
component | Component used for the root node. Either a string to use a HTML element or a component. | string | ComponentClass<any, any> | FunctionComponent<any> | - |
size | Size the component small. | 'sm' | - |
variant | Set the button variant to an outlined button or a ghost button. | 'border' | 'grow' | border |
visuallyHiddenLabel | Set visually hidden label for accessibility purposes. | string | Loading... |