Spin
Used for the loading state of pages. When part of the page is waiting for asynchronous data or is in the rendering process, appropriate loading amimation will effectively alleviate user anxiety.
Install
npm install @arco-design/web-react@2.66.18
Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.
Examples
- Basic: A simple loading state.
- Dot Indicator: The dot type indicator can be displayed by specifying the
dotproperty. - As Container: You can add loading status to any element. The container defaults to the
inline-blocklayout. When you need to fill the parent container, you can setstyle={{ display:'block' }}. - Tip: Use
tipproperty to customize the tip when loading. - Delay: Use
delayto delay the switch of loading status, which effectively avoids screen flicker during rapid state switching. - Custom Icon: By specifying
icon, you can specify a custom icon as a loading component. - Size: Set
sizeto get different sizes of loading icons.
Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.
API
Spin
| Property | Description | Type | DefaultValue | Version |
|---|---|---|---|---|
| block | Whether it is a block-level element | boolean | - | 2.29.0 |
| dot | Whether to use dot type animation | boolean | - | - |
| loading | Whether is loading status (Only works when Spin has children)) | boolean | - | - |
| delay | Specifies a delay(ms) for loading state | number | - | - |
| size | The size of loading icon | number | - | - |
| element | Customize element which won't be rotated automatically, such as image/gif. | ReactNode | - | - |
| icon | Customize icon which will be rotated automatically. | ReactNode | - | - |
| tip | Customize description content when Spin has children | string | ReactNode | - | - |
| className | Additional css class | string | string[] | - | - |
| style | Additional style | CSSProperties | - | - |