Ir al contenido

Skeleton

Una forma gris que ocupa el lugar de un contenido que viene en camino. Tiene el tamaño de lo que va a llegar, así la página no salta.

import { Skeleton, SkeletonWords, SkeletonOf } from '@sypnia/ui/react'

En esta página
  1. Formas
  2. Una lista que carga
  3. Palabras y piezas
  4. Piezas que cargan con su forma real
  5. Tarjetas en camino
  6. Cuándo usarlo
  7. Para todos
  8. Props

Formas

Un círculo, una línea y bloques, cada uno con su tamaño.

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

// The pieces: a line, a block, a circle. Each takes the size of what will replace it.
export default function Shapes() {
  return (
    <div className="sy-row" aria-busy="true">
      <Skeleton circle height={40} />
      <Skeleton width={180} />
      <Skeleton width={96} height={32} radius={10} />
      <Skeleton width={220} height={80} radius={14} />
    </div>
  );
}

Una lista que carga

Presiona «Load again»: el skeleton tiene la forma de las filas que llegan.

Team

LMLaura MéndezOwnerDRDiego RuizEditorACAna CastañoViewer
Código
import { useState } from 'react';
import { Button, Identity, Panel, Skeleton } from '@sypnia/ui/react';

const team = [['Laura Méndez', 'Owner'], ['Diego Ruiz', 'Editor'], ['Ana Castaño', 'Viewer']];
// Press «Load again»: the skeleton has the shape of the list that arrives, so nothing jumps.
export default function Loading() {
  const [loading, setLoading] = useState(false);
  const reload = () => { setLoading(true); setTimeout(() => setLoading(false), 2200); };
  return (
    <Panel title="Team" actions={<Button size="sm" disabled={loading} onClick={reload}>Load again</Button>}>
      <div className="sy-stack" aria-busy={loading} aria-live="polite">
        {team.map(([name, role]) => loading
          ? <div key={name} className="sy-row"><Skeleton circle height={32} /><div className="sy-stack sy-grow"><Skeleton width="38%" /><Skeleton width="22%" /></div></div>
          : <Identity key={name} name={name} meta={role} />)}
      </div>
    </Panel>
  );
}

Palabras y piezas

La fila cargada y la misma fila cargando: las barras tienen el largo de los valores, y la etiqueta y el botón sus propias cajas.

Laura Méndezlaura@northwind.io · since March
Owner
Código
import { Badge, Button, Row, SkeletonOf, SkeletonWords, Stack, Text } from '@sypnia/ui/react';

// Inside the real piece, the values that are not here yet: SkeletonWords draws a bar as long as a typical value, in the
// same line; SkeletonOf draws a real Button or Badge as a skeleton of its own box. The page around them is the real one.
export default function Words() {
  const row = (loading: boolean) => (
    <Row gap={3} justify="between">
      <Stack gap={1}>
        <b>{loading ? <SkeletonWords>Laura Méndez</SkeletonWords> : 'Laura Méndez'}</b>
        <Text as="span" size="sm" tone="muted">{loading ? <SkeletonWords>laura@northwind.io · since March</SkeletonWords> : 'laura@northwind.io · since March'}</Text>
      </Stack>
      <Row gap={2}>
        {loading ? <SkeletonOf><Badge tone="light">Owner</Badge></SkeletonOf> : <Badge tone="light">Owner</Badge>}
        {loading ? <SkeletonOf><Button size="sm">Resend</Button></SkeletonOf> : <Button size="sm">Resend</Button>}
      </Row>
    </Row>
  );
  return <Stack gap={5}>{row(false)}<div aria-busy="true">{row(true)}</div></Stack>;
}

Piezas que cargan con su forma real

Stat, Identity, KeyValue, UsageBar, PlanCard, ListItem, ActivityFeed y Pagination reciben loading con los últimos valores conocidos: los nombres se quedan, los valores son barras tan largas como los suyos y los botones esperan en sus cajas. Pulsa el botón para cambiar.

Requests
Errors

Account

Plan
Region
Seats

Código
import { useState } from 'react';
import {
  ActivityFeed, Button, Columns, Identity, KeyValue, List, ListItem, Pagination, Panel, PlanCard, Stack, Stat, StatGroup, UsageBar,
} from '@sypnia/ui/react';

// Pieces that load in their real shape: give them `loading` and the last values you know (or typical ones). Names and
// labels stay; each value is a bar as long as its own, each button a skeleton of its box. Press the button to switch.
export default function Pieces() {
  const [loading, setLoading] = useState(true);
  return (
    <Stack gap={4}>
      <div><Button icon="refresh" onClick={() => setLoading((l) => !l)}>{loading ? 'Show the values' : 'Load again'}</Button></div>
      <div aria-busy={loading}>
        <Stack gap={4}>
          <StatGroup><Stat loading={loading} label="Requests" value="880K" delta="+12% this week" trend="good" /><Stat loading={loading} label="Errors" value="0.82%" /></StatGroup>
          <Columns cols={2} stack>
            <Panel title="Account">
              <Stack gap={4}>
                <Identity loading={loading} name="Ana Ruiz" meta="ana@northwind.io" />
                <KeyValue loading={loading} items={[['Plan', 'Team'], ['Region', 'São Paulo']]} />
                <UsageBar loading={loading} label="Seats" used={5} limit={8} />
              </Stack>
            </Panel>
            <PlanCard loading={loading} name="Pro" price={29} currency="USD" period="month" blurb="For a product in production." action={<Button>Change plan</Button>} />
          </Columns>
          <List label="Customers">
            <ListItem loading={loading} title="Luis Ortega" description="Lumen Labs" meta="2 orders" />
            <ListItem loading={loading} title="Marta Gil" description="Globex" meta="11 orders" />
          </List>
          <ActivityFeed label="Activity" loading={loading} items={[{ id: 1, actor: { name: 'Ana Ruiz' }, action: 'deployed', target: 'version 1.42', time: Date.UTC(2026, 10, 17, 13) }]} />
          <Pagination loading={loading} page={1} pageSize={20} total={86} onPage={() => undefined} />
        </Stack>
      </div>
    </Stack>
  );
}

Tarjetas en camino

La cuadrícula ya está en su lugar.

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

// A page of cards that is on its way.
export default function Cards() {
  return (
    <div className="sy-grid" aria-busy="true">
      {[0, 1, 2].map((i) => (
        <div key={i} className="sy-card">
          <Skeleton width="55%" height={18} />
          <Skeleton width="80%" />
          <Skeleton width={72} height={22} />
        </div>
      ))}
    </div>
  );
}

Cuándo usarlo

Úsalo cuando

  • Está cargando un contenido y conoces su forma: una fila, una tarjeta, un avatar.
  • Arma el skeleton con el mismo diseño que lo real, para que encaje exacto: la página real, sus encabezados, paneles y columnas reales, y solo los valores como skeletons.
  • Un valor dentro de una pieza real: SkeletonWords con un valor típico, así la barra tiene el largo y la línea del valor. Un Button o un Badge cuyas palabras se conocen: SkeletonOf.
  • Es la única forma en que Sypnia muestra que algo carga: no hay ruedas de carga ni «Cargando…».

No lo uses cuando

  • Es texto de varias líneas: SkeletonText.
  • Un botón está trabajando: el botón tiene su propio estado ocupado.
  • Es una cantidad conocida de trabajo (una importación, una subida): Progress muestra cuánto falta.
  • La respuesta tarda menos de un momento: no mostrar nada es más tranquilo que un destello gris.

Para todos

  • Los skeletons están ocultos para los lectores de pantalla. Marca la región que los rodea con aria-busy="true"; agrega aria-live="polite" para que el contenido se anuncie cuando llegue.
  • El brillo se detiene para quien le pide a su dispositivo menos movimiento.
  • Nada dentro de una región que carga recibe el foco.

Props

SkeletonTipoPor defecto
circle boolean
className string
height string | number
radius string | number
width string | number
  1. Formas
  2. Una lista que carga
  3. Palabras y piezas
  4. Piezas que cargan con su forma real
  5. Tarjetas en camino
  6. Cuándo usarlo
  7. Para todos
  8. Props

    Busca páginas, secciones y términos