Skip to Content
Cristal

Navigation and progress

Loading

Skeletons, progress bars, steps, indicators and blur-up images to show that something is coming.

<cr-skeleton><cr-progress><cr-progress-steps><cr-loader><cr-image>

Skeleton

CrSkeleton draws the shape of the expected content and gently pulses (1.6s). shape is line (a line of text, default), block (image, card) or circle (avatar); width and height take any CSS value.

import { CrBox, CrSkeleton } from '@cristal-ui/react';

export default function LoadingSkeleton() {
  return (
    <CrBox display="flex" gap="lg" padding="lg" background="surface" radius="l" border aria-busy="true" style={{ width: '100%', maxWidth: 420 }}>
      <CrSkeleton shape="block" width="120px" height="88px" />
      <CrBox display="flex" direction="column" gap="sm" style={{ flex: 1 }}>
        <CrSkeleton width="90%" />
        <CrSkeleton width="70%" />
        <CrSkeleton width="45%" />
      </CrBox>
    </CrBox>
  );
}

Progress bar

Without value, CrProgress is indeterminate: a segment glides along the track, growing mid-way (1.5s). With value (0 to 100), the bar fills up; showValue also shows a big percentage that counts up to each new value.

Start
'use client';

import { useState } from 'react';
import { CrBox, CrButton, CrProgress } from '@cristal-ui/react';

export default function LoadingProgress() {
  const [value, setValue] = useState(0);

  return (
    <CrBox display="flex" direction="column" gap="xl" style={{ width: '100%', maxWidth: 360 }}>
      <CrProgress label="Importing files" />
      <CrProgress label="Upload" value={value} showValue />
      <CrButton size="s" variant="secondary" onClick={() => setValue(value === 100 ? 0 : 100)}>
        {value === 100 ? 'Reset' : 'Start'}
      </CrButton>
    </CrBox>
  );
}

Processing steps

CrProgressSteps shows what is happening during a long wait: past steps are checked, the current step has a spinner, the next ones only appear in turn. current is the current step; it equals the number of steps once everything is done.

Restart
'use client';

import { useEffect, useState } from 'react';
import { CrBox, CrButton, CrProgressSteps } from '@cristal-ui/react';

const steps = ['Searching', 'Reading', 'Writing'];

export default function LoadingSteps() {
  const [current, setCurrent] = useState(0);

  useEffect(() => {
    if (current >= steps.length) return;
    const timer = setTimeout(() => setCurrent(current + 1), 1000);
    return () => clearTimeout(timer);
  }, [current]);

  return (
    <CrBox display="flex" direction="column" gap="lg" align="start">
      <CrProgressSteps label="Preparing the answer" steps={steps} current={current} />
      <CrButton size="s" variant="secondary" disabled={current < steps.length} onClick={() => setCurrent(0)}>
        Restart
      </CrButton>
    </CrBox>
  );
}

Indicator

CrLoader signals a wait of unknown length: a spinning circle (default) or, with variant="bounce", a ball that bounces, squashes on landing, and whose shadow shrinks as it rises; with variant="search", a gliding magnifier for searches. Its size follows font-size.

import { CrBox, CrLoader } from '@cristal-ui/react';

export default function LoadingLoader() {
  return (
    <CrBox display="flex" gap="2xl" align="end">
      <CrLoader />
      <CrLoader variant="bounce" label="Loading messages…" style={{ fontSize: 24 }} />
      <CrLoader variant="search" label="Searching…" style={{ fontSize: 24 }} />
    </CrBox>
  );
}

Blur-up image

CrImage shows the image blurred (18px) and slightly zoomed in, then sharpens it over 2s once loaded. Give the component a size (width, height or aspect-ratio): the image fills it and stays cropped.

Reload the image
'use client';

import { useState } from 'react';
import { CrBox, CrButton, CrImage } from '@cristal-ui/react';

const landscape = `data:image/svg+xml,${encodeURIComponent(
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 180"><defs><linearGradient id="sky" x2="0" y2="1"><stop offset="0" stop-color="#4c1d95"/><stop offset="1" stop-color="#db2777"/></linearGradient></defs><rect width="320" height="180" fill="url(#sky)"/><circle cx="200" cy="118" r="28" fill="#fcd34d"/><path d="M0 180 70 100l50 40 60-60 70 70 70-40v70z" fill="#6d28d9"/><path d="M0 180 50 140l60 20 60-40 70 50 80-30v40z" fill="#3b0764"/></svg>',
)}`;

export default function LoadingImage() {
  const [key, setKey] = useState(0);

  return (
    <CrBox display="flex" direction="column" gap="lg" align="start" style={{ width: '100%', maxWidth: 360 }}>
      <CrImage key={key} src={landscape} alt="Purple mountains at sunset" style={{ width: '100%', aspectRatio: '16 / 9', borderRadius: 12 }} />
      <CrButton size="s" variant="secondary" onClick={() => setKey(key + 1)}>
        Reload the image
      </CrButton>
    </CrBox>
  );
}

If the user asked their system to reduce motion, the skeleton stops pulsing, the indeterminate bar and the ball gently fade instead of moving, the circle spins slowly, and numbers and the image appear without transition.

Accessibility

  • CrSkeleton is hidden from screen readers: signal loading on the container (aria-busy="true") or with a CrLoader.
  • CrProgress is a progress bar (role="progressbar") named by label ("Progress" by default); with value, its value is read. The big percentage is hidden so it is not read twice.
  • CrLoader is a status region that reads label ("Loading…" by default).
  • CrProgressSteps is an ordered list: the current step has aria-current="step", each step is read with its state ("current", "completed") and new steps are announced.
  • alt is required on CrImage; leave it empty (alt="") for a decorative image.
  • These animations loop: only show them while loading, and remove them as soon as it is done.

CrSkeleton API

Properties

PropertyTypeDefaultDescription
heightstring—Hauteur, toute valeur CSS.
shape"block" | "circle" | "line"'line'Forme : line (ligne de texte), block (image, carte) ou circle (avatar).
widthstring—Largeur, toute valeur CSS (« 60% », « 120px »).

CSS parts

To style it from outside: cr-skeleton::part(name) { … }

PartDescription

CrProgress API

Properties

PropertyTypeDefaultDescription
labelstring—Nom lu par les lecteurs d'écran (« Progression » par défaut).
showValuebooleanfalseAffiche le pourcentage en grand au-dessus de la barre ; il compte jusqu'à chaque nouvelle valeur.
valuenumber—Avancement de 0 à 100. Sans valeur, la barre est indéterminée.

CSS parts

To style it from outside: cr-progress::part(name) { … }

PartDescription
barLa partie remplie.
trackLe rail.
valueLe pourcentage affiché avec show-value.

CrProgressSteps API

Properties

PropertyTypeDefaultDescription
currentnumber0Étape en cours (0 pour la première) ; vaut le nombre d'étapes quand tout est terminé.
labelstring—Nom de la liste (« Progression » par défaut).
stepsstring[][]Noms des étapes, dans l'ordre.

CSS parts

To style it from outside: cr-progress-steps::part(name) { … }

PartDescription

CrLoader API

Properties

PropertyTypeDefaultDescription
labelstring—Texte lu par les lecteurs d'écran (« Chargement… » par défaut).
variant"bounce" | "search" | "spinner"'spinner'Style : spinner (cercle qui tourne), bounce (balle qui rebondit et s'écrase en touchant le sol) ou search (loupe qui glisse, pour une recherche).

CSS parts

To style it from outside: cr-loader::part(name) { … }

PartDescription
indicatorLe cercle ou la balle.

CrImage API

Properties

PropertyTypeDefaultDescription
alt (obligatoire)string—Texte alternatif ; chaîne vide pour une image décorative.
src (obligatoire)string—Adresse de l'image.

CSS parts

To style it from outside: cr-image::part(name) { … }

PartDescription
imageL'élément img.

On this page