ChatLoader
Loading indicators and skeletons for assistant responses
Usage
import {ChatLoader} from "@peakui-pro/react";Anatomy
ChatLoader is a namespace with no root: there is no <ChatLoader> element, only its parts.
import {ChatLoader} from "@peakui-pro/react";
export default () => (
<>
<ChatLoader.Dots />
<ChatLoader.Pulse />
<ChatLoader.Spinner />
<ChatLoader.Skeleton>
<ChatLoader.SkeletonAvatar />
<ChatLoader.SkeletonBlock>
<ChatLoader.SkeletonLine />
</ChatLoader.SkeletonBlock>
</ChatLoader.Skeleton>
</>
);Examples
Dots
Pulse
Spinner
Skeleton
ChatLoader.Skeleton without children draws an avatar and three lines.
Skeleton Composed
Children replace the default layout whole.
Labelled
Pass role="status" and a label to announce a loader; every part is aria-hidden by default.
On Surface
Customization
Tailwind CSS
<ChatLoader.Skeleton className="[--chat-loader-avatar-size:48px] [--chat-loader-line-height:16px]" />Global CSS
@layer components {
.chat-loader {
--chat-loader-avatar-size: 48px;
}
.chat-loader__dots {
--chat-loader-dot-size: 8px;
}
.chat-loader__pulse {
background-color: var(--color-success);
}
}Styling Reference
PeakUI follows the BEM methodology, so variants and states are plain class names you can target.
CSS Classes
The ChatLoader component uses these CSS classes (view source styles):
Base Classes
.chat-loader- The skeleton root, a message-shaped loading layout
Element Classes
.chat-loader__avatar- Avatar placeholder.chat-loader__content- Group of loading lines.chat-loader__line- Individual loading line.chat-loader__dots- Dots loader.chat-loader__dot- One dot of the dots loader.chat-loader__pulse- Pulse loader.chat-loader__spinner- Box around the core Spinner
Slots
[data-slot="chat-loader-dots"][data-slot="chat-loader-dot"][data-slot="chat-loader-pulse"][data-slot="chat-loader-spinner"][data-slot="chat-loader-skeleton"][data-slot="chat-loader-skeleton-avatar"][data-slot="chat-loader-skeleton-block"][data-slot="chat-loader-skeleton-line"]
CSS Variables
| Variable | Purpose |
|---|---|
--chat-loader-dot-size | Diameter of a dot; defaults to 6px, set on .chat-loader__dots |
--chat-loader-dot-gap | Gap between dots; defaults to 4px, set on .chat-loader__dots |
--chat-loader-pulse-size | Diameter of the pulse; defaults to 8px, set on .chat-loader__pulse |
--chat-loader-gap | Gap between the avatar and the lines; defaults to 12px |
--chat-loader-avatar-size | Width and height of the avatar; defaults to 32px |
--chat-loader-line-height | Height of a line; defaults to 12px |
--chat-loader-line-gap | Gap between lines; defaults to 8px |
Interactive States
Motion and color are the only states, and these conditions change them:
- Reduced motion:
@media (prefers-reduced-motion: reduce)stops the dots and the pulse at 70% opacity, and the skeleton's shimmer stops too - Forced colors:
@media (forced-colors: active)paints dots inCanvasTextand the pulse inHighlight, and outlines each skeleton shape inButtonBorder
API Reference
ChatLoader.Dots
| Prop | Type | Default | Description |
|---|---|---|---|
aria-hidden | Booleanish | "true" | Hides the loader from assistive technology; pass undefined with role="status" to announce it |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
...rest | ComponentProps<'div'> | - | Native <div> attributes |
ChatLoader.Pulse
| Prop | Type | Default | Description |
|---|---|---|---|
aria-hidden | Booleanish | "true" | Hides the loader from assistive technology |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
...rest | ComponentProps<'div'> | - | Native <div> attributes |
ChatLoader.Spinner
| Prop | Type | Default | Description |
|---|---|---|---|
aria-hidden | Booleanish | "true" | Hides the box and the role="status" of the core Spinner inside it, so unhiding it exposes one live region |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
...rest | ComponentProps<'div'> | - | Native <div> attributes |
ChatLoader.Skeleton
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | An avatar and a block of three lines | Replaces the default layout whole |
aria-hidden | Booleanish | "true" | Hides the skeleton from assistive technology |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
...rest | ComponentProps<'div'> | - | Native <div> attributes |
ChatLoader.SkeletonAvatar
| Prop | Type | Default | Description |
|---|---|---|---|
aria-hidden | Booleanish | "true" | Hides the shape from assistive technology |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div>; receives the props the core Skeleton computed, data-slot included |
...rest | ComponentProps<'div'> | - | Native <div> attributes |
ChatLoader.SkeletonBlock
| Prop | Type | Default | Description |
|---|---|---|---|
aria-hidden | Booleanish | "true" | Hides the shape from assistive technology |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
...rest | ComponentProps<'div'> | - | Native <div> attributes |
ChatLoader.SkeletonLine
| Prop | Type | Default | Description |
|---|---|---|---|
aria-hidden | Booleanish | "true" | Hides the shape from assistive technology |
className | string | - | Additional classes, such as a width utility |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div>; receives the props the core Skeleton computed, data-slot included |
...rest | ComponentProps<'div'> | - | Native <div> attributes |