Ir al contenido

SkeletonText

Líneas grises que ocupan el lugar de un párrafo mientras carga.

import { SkeletonText } from '@sypnia/ui/react'

En esta página
  1. Tres y cinco líneas
  2. Un párrafo que carga
  3. Cuándo usarlo
  4. Para todos
  5. Props

Tres y cinco líneas

La última línea es más corta, como el final de un párrafo.

Código
import { SkeletonText } from '@sypnia/ui/react';

// The last line is shorter, like the end of a paragraph.
export default function Lines() {
  return (
    <div className="sy-cols sy-cols--stack" aria-busy="true">
      <SkeletonText />
      <SkeletonText lines={5} />
    </div>
  );
}

Un párrafo que carga

Presiona «Load again».

About this project

Orders, customers and products of the online store. The mobile app and the back office both read from here. Backups run every night and are kept for 7 days.

Código
import { useState } from 'react';
import { Button, Panel, SkeletonText } from '@sypnia/ui/react';

// Press «Load again».
export default function Loading() {
  const [loading, setLoading] = useState(false);
  const reload = () => { setLoading(true); setTimeout(() => setLoading(false), 2000); };
  return (
    <Panel title="About this project" actions={<Button size="sm" disabled={loading} onClick={reload}>Load again</Button>}>
      <div aria-busy={loading} aria-live="polite">
        {loading ? <SkeletonText lines={3} /> : (
          <p className="sy-text--sm sy-text--soft">
            Orders, customers and products of the online store. The mobile app and the back office both read from here.
            Backups run every night and are kept for 7 days.
          </p>
        )}
      </div>
    </Panel>
  );
}

Cuándo usarlo

Úsalo cuando

  • Está cargando un bloque de texto: una descripción, un mensaje, un artículo.
  • Elige lines cerca del largo real, así la página no salta cuando llega el texto.

No lo uses cuando

  • El contenido tiene forma propia (filas, tarjetas, avatares): arma con Skeleton.
  • Es un solo valor corto: un Skeleton solo con un ancho.

Para todos

  • Está oculto para los lectores de pantalla. Marca la región con aria-busy="true" y aria-live="polite", como en el segundo ejemplo.
  • El brillo se detiene con movimiento reducido.

Props

SkeletonTextTipoPor defecto
lines number 3
  1. Tres y cinco líneas
  2. Un párrafo que carga
  3. Cuándo usarlo
  4. Para todos
  5. Props

    Busca páginas, secciones y términos