PeakUIPro

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

VariablePurpose
--chat-loader-dot-sizeDiameter of a dot; defaults to 6px, set on .chat-loader__dots
--chat-loader-dot-gapGap between dots; defaults to 4px, set on .chat-loader__dots
--chat-loader-pulse-sizeDiameter of the pulse; defaults to 8px, set on .chat-loader__pulse
--chat-loader-gapGap between the avatar and the lines; defaults to 12px
--chat-loader-avatar-sizeWidth and height of the avatar; defaults to 32px
--chat-loader-line-heightHeight of a line; defaults to 12px
--chat-loader-line-gapGap 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 in CanvasText and the pulse in Highlight, and outlines each skeleton shape in ButtonBorder

API Reference

ChatLoader.Dots

PropTypeDefaultDescription
aria-hiddenBooleanish"true"Hides the loader from assistive technology; pass undefined with role="status" to announce it
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

ChatLoader.Pulse

PropTypeDefaultDescription
aria-hiddenBooleanish"true"Hides the loader from assistive technology
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

ChatLoader.Spinner

PropTypeDefaultDescription
aria-hiddenBooleanish"true"Hides the box and the role="status" of the core Spinner inside it, so unhiding it exposes one live region
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

ChatLoader.Skeleton

PropTypeDefaultDescription
childrenReactNodeAn avatar and a block of three linesReplaces the default layout whole
aria-hiddenBooleanish"true"Hides the skeleton from assistive technology
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

ChatLoader.SkeletonAvatar

PropTypeDefaultDescription
aria-hiddenBooleanish"true"Hides the shape from assistive technology
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div>; receives the props the core Skeleton computed, data-slot included
...restComponentProps<'div'>-Native <div> attributes

ChatLoader.SkeletonBlock

PropTypeDefaultDescription
aria-hiddenBooleanish"true"Hides the shape from assistive technology
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

ChatLoader.SkeletonLine

PropTypeDefaultDescription
aria-hiddenBooleanish"true"Hides the shape from assistive technology
classNamestring-Additional classes, such as a width utility
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div>; receives the props the core Skeleton computed, data-slot included
...restComponentProps<'div'>-Native <div> attributes

On this page