Esqueleto
Ocupa el lugar del contenido mientras se carga, con marcadores de posición discretos que tienen la forma de lo que va a llegar (líneas de texto, un bloque, un círculo), y reserva la caja que ocupará el contenido, para que nada se mueva cuando llegue.
- Categoría
- Comunicación
- Tokens
comp.skeleton- Nivel
- Base
- Web
tanrei-skeletonschedule - SwiftUI
TanreiSkeletonradio_button_unchecked - Jetpack Compose
TanreiSkeletonradio_button_unchecked - Flutter
TanreiSkeletonradio_button_unchecked - React Native
Skeletonradio_button_unchecked
Generado a partir de docs/status/status.json, specs/skeleton.spec.json
Los datos de una persona y una tarjeta, mientras se cargan
Una vista suele llegar antes que su contenido. Un esqueleto reserva la forma de lo que va a llegar en el lugar donde estará: líneas de texto, un bloque para una imagen o un control, un círculo para la foto de una persona. Cuando el contenido llega, ocupa las cajas que se le habían reservado, y nada de lo que la persona estaba mirando, o a punto de pulsar, se mueve.
Es una región y sus marcadores de posición. La región se dice una sola vez a la tecnología de apoyo («Cargando proyectos», ocupada), y los marcadores de posición no dicen nada por sí mismos. Espera un momento antes de mostrarse, de modo que una espera breve muestra un hueco del tamaño correcto en lugar de formas que parpadean.
En la web es <tanrei-skeleton> alrededor de tus propios elementos con class="tanrei-skeleton-placeholder". Las demás plataformas todavía no lo han implementado.
Cuatro componentes responden a «aquí todavía no hay nada». Cuál usar depende de lo que se sabe de la espera y de lo que va a llegar.
| La situación | Usa | Por qué |
|---|---|---|
| Un contenido de forma conocida va a llenar una región de una vista, y la espera es lo bastante larga para verse. | Un esqueleto | Reserva el diseño, así que nada se mueve cuando el contenido llega, y muestra dónde estará cada cosa. |
| Una espera breve de duración desconocida cuyo resultado no tiene una forma que reservar, o es pequeño: en un botón, una fila, un campo, una línea de estado. Una acción en curso, como guardar o enviar. | Un indicador de carga | Basta con una marca. Las formas para una sola fila o un solo icono son ruido. |
| Una tarea cuyo progreso se puede medir, o que tarda muchos segundos. | Un indicador de progreso | Un esqueleto no dice nada sobre cuánto se ha avanzado, y al cabo de unos segundos la persona necesita saberlo. |
| No va a llegar nada: la lista está vacía, la búsqueda no encontró nada. | Un estado vacío | Un esqueleto promete contenido. |
| La carga falló. | Un callout con el estado de error, en ese mismo lugar. | Un esqueleto que nunca termina es una mentira. |
| El contenido ya está ahí, y solo llega tarde su script, su imagen o su fuente. | Ninguno de los cuatro. El componente reserva su propia caja. | Un esqueleto no conoce el tamaño de otro componente. Ese componente sí. |
Pon el esqueleto donde estará el contenido cuando empiece la espera, y sustitúyelo por el contenido cuando termine. Dale un label que diga qué se está cargando. Un marcador de posición es un elemento vacío tuyo con la clase: un <span> en cualquier lugar, o un <div> donde es hijo de un bloque, como otro <div>. Dentro de un encabezado o de un párrafo es un <span>.
<link rel="stylesheet" href="@tanrei/web/skeleton.css" />
<!-- Los marcadores de posición que son hijos directos del esqueleto se apilan, con una separación. -->
<tanrei-skeleton label="Cargando el proyecto">
<span class="tanrei-skeleton-placeholder" data-shape="block" style="block-size: 160px"></span>
<span class="tanrei-skeleton-placeholder" style="inline-size: 12.5rem"></span>
<span class="tanrei-skeleton-placeholder" data-lines="3"></span>
</tanrei-skeleton>
<!-- Todo lo demás es tu propio diseño, con los marcadores de posición dentro, donde estará el contenido. -->
<tanrei-skeleton label="Cargando los datos del autor">
<div class="byline">
<span class="tanrei-skeleton-placeholder" data-shape="circle" style="block-size: 40px"></span>
<div>
<h3><span class="tanrei-skeleton-placeholder" style="inline-size: 10rem"></span></h3>
<p><span class="tanrei-skeleton-placeholder" data-lines="2"></span></p>
</div>
</div>
</tanrei-skeleton>
<!-- Parte de la primera presentación de una página, escrita por el servidor: se muestra de inmediato y es correcta antes de cualquier script. -->
<tanrei-skeleton show-delay="0" role="progressbar" aria-busy="true" aria-label="Cargando el panel">
…
</tanrei-skeleton>
<noscript>El panel necesita JavaScript.</noscript>
<script type="module">
import '@tanrei/web/components/skeleton';
</script>import { Skeleton } from '@tanrei/react';
import '@tanrei/web/skeleton.css';
{project ? (
<ProjectCard project={project} />
) : (
<Skeleton label="Cargando el proyecto">
<span className="tanrei-skeleton-placeholder" data-shape="block" style={{ blockSize: 160 }} />
<span className="tanrei-skeleton-placeholder" style={{ inlineSize: '12.5rem' }} />
<span className="tanrei-skeleton-placeholder" data-lines={3} />
</Skeleton>
)}En la web, la hoja de estilos es todo el componente antes de que se ejecute ningún script: las formas, la espera antes de mostrarse, el pulso, la quietud donde el movimiento está reducido y los contornos de los colores forzados. El elemento añade lo que una hoja de estilos no puede: el rol y el nombre para la tecnología de apoyo, mantener fuera del orden del foco lo que el esqueleto contiene, y detenerse mientras no se puede ver.
Las tres formas: texto, un bloque, un círculo
Un marcador de posición de texto toma el estilo de texto del lugar donde está: en un encabezado, en un párrafo
Anatomía
| Parte | Descripción |
|---|---|
1 container | The region that stands in the content's place: a block as wide as the place it stands in and as tall as what it holds, with no fill, no edge, no padding and no elevation. It is what assistive technology is told about, once, and it carries no state: a skeleton takes no input. |
2 placeholder | A quiet filled shape in the place of one piece of the content: one or more lines of text, a block (a picture, a card, a control) or a circle (a person's picture, a round mark). It has the size the content will have and says nothing by itself. |
Propiedades
| Propiedad | Tipo | Valor predeterminado | Descripción |
|---|---|---|---|
label | string | "" | What is loading, in the product's language ("Loading projects"): the name assistive technology is given for the whole skeleton, once. Never drawn. Left empty, it reads the product's words; Tanrei ships none of its own. Not read while decorative is true. |
decorative | boolean | false | Whether something else already says this wait: a loading indicator beside it, a status text, a region the product itself exposes as busy and names. True keeps the whole skeleton from assistive technology, so that one wait is said once; it changes nothing that is drawn. |
showDelay | number | null | How long, in milliseconds, this skeleton waits from the moment it is inserted before it is drawn and exposed to assistive technology; 0 shows it as it is inserted. Null takes comp.skeleton.motion.show-delay, the system's answer for every skeleton. Set it to 0 where the skeleton is part of the first presentation of a page or a view, which has nothing else to show; leave it where content is fetched in a view that is already there. |
Elementos
Los tipos de elemento que el componente repite. Un fixture enumera sus elementos en orden; cada plataforma nombra cada tipo según su propio estilo.
placeholder
One shape in the place of one piece of the content: lines of text, a block or a circle.
| Propiedad | Tipo | Valor predeterminado | Descripción |
|---|---|---|---|
shape | text | block | circle | "text" | What the placeholder stands for. Text is one or more lines of the text style in effect where it stands. Block is a box: a picture, a card, a control, a row. Circle is a round box: a person's picture, a round mark. |
lines | number | 1 | For text: how many lines the text will take, a whole number of 1 or more. The placeholder is exactly that many line boxes high. Not read for a block or a circle. |
inlineSize | number | null | The placeholder's size along the line, in points. Null leaves it to the layout: the whole inline size of its place for text and for a block, the side of the square for a circle. A size the product's own layout gives the placeholder (a share of a row, a track of a grid) is used as it is and needs no prop. |
blockSize | number | null | The placeholder's size across the line, in points: the height of a block, and the side of a circle. Null is one line of the text style in effect, or the size the product's own layout gives. Not read for text, whose height is its lines. |
| Especificación | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| Elemento | span | TanreiSkeletonPlaceholder | TanreiSkeletonPlaceholder | TanreiSkeletonPlaceholder | SkeletonPlaceholder |
shape · Propiedad | data-shape | shape | shape | shape | shape |
lines · Propiedad | data-lines | lines | lines | lines | lines |
inlineSize · Propiedad | inline-size | width | width | width | width |
blockSize · Propiedad | block-size | height | height | height | height |
| Notas | The product's own element with class="tanrei-skeleton-placeholder" — a <span>, or a <div> where it is a block's child — empty, so that it has nothing to expose. data-shape is text (the default, and what a missing or unknown value draws), block or circle; data-lines the number of lines. inlineSize and blockSize are the CSS properties inline-size and block-size on the element (in its style, or by a rule of the product's): a number of the spec is that many CSS pixels, and any other length, a percentage or an aspect-ratio the product writes there is a size its layout gives (SKL-4). The text style is the inherited font, so the placeholder goes where the text will be — inside the heading, the paragraph or the cell — and is 1lh high a line. | TanreiSkeletonPlaceholder(.text, lines: 3), TanreiSkeletonPlaceholder(.circle, height: 40); a .frame or an .aspectRatio the product applies is a size its layout gives. The text style is the font of the environment (.font(...) on an ancestor), measured with the reader's text size. | TanreiSkeletonPlaceholder(shape, lines, width, height, modifier) inside the skeleton's scope; a size from modifier is a size the layout gives. The text style is LocalTextStyle, measured with the font scale. | TanreiSkeletonPlaceholder.text(lines: 3), .block(height: 160), .circle(size: 40); inside an Expanded, a SizedBox or an AspectRatio it takes that size. The text style is DefaultTextStyle, with MediaQuery.textScalerOf. | <SkeletonPlaceholder shape="text" lines={3} />; style gives a size the layout gives (flex, a percentage, aspectRatio). React Native has no inherited text style, so the product passes one of Tanrei's text styles as textStyle, and the body style is used where it gives none (SKL-3). |
Estados
Comportamiento
Requisitos en formato EARS. Cada implementación de plataforma se prueba contra estos identificadores. El texto de los requisitos se muestra tal como está en la especificación, en inglés.
| ID | Requisito |
|---|---|
SKL-1 | THE skeleton SHALL lay itself out as a block that takes the whole inline size of the place it stands in and is as tall as what it holds: it SHALL lay out the placeholders that stand directly in it in one column, in the order given, each at its own size and at the start edge, comp.skeleton.container.gap apart, and SHALL leave placeholders that stand inside a layout of the product's own (a row, a grid, a card's own structure) to that layout, changing neither their place nor their size. THE skeleton SHALL draw no fill, no edge and no elevation, SHALL bring no padding and no outer space of its own, SHALL set no height of its own and SHALL NOT scroll or clip. |
SKL-2 | THE skeleton SHALL draw each placeholder as one box, or for text one box a line, filled with comp.skeleton.placeholder.color, with the corners of its shape (comp.skeleton.placeholder.shape.text for each line of text, comp.skeleton.placeholder.shape.block for a block, comp.skeleton.placeholder.shape.circle for a circle), never larger than half the box's smaller side, and with no edge, no elevation, no shadow and nothing inside it. THE skeleton SHALL draw nothing else: no glyph, no mark, no text, and never its label. |
SKL-3 | WHILE a placeholder's shape is text THE skeleton SHALL size it by the text style in effect where it stands — the style text placed there would be drawn in, and sys.typescale.body where the platform has no such style and the product gave none: the placeholder SHALL be exactly as tall as lines line boxes of that style, and in each line box THE skeleton SHALL draw one bar as tall as the style's font size, centred in the line box. Each bar SHALL be as long as the placeholder's inline size (inlineSize, else the whole inline size of its place), except that WHILE lines is 2 or more the last bar SHALL be comp.skeleton.placeholder.last-line-inline-size of that size, from the start edge. The placeholder SHALL NOT read blockSize. |
SKL-4 | WHILE a placeholder's shape is block THE skeleton SHALL draw one box whose inline size is inlineSize, else the size the product's layout gives it, else the whole inline size of its place, and whose block size is blockSize, else the size the product's layout gives it (a stretched cell, a ratio the product set), else one line box of the text style in effect where it stands (SKL-3). The block SHALL NOT read lines. |
SKL-5 | WHILE a placeholder's shape is circle THE skeleton SHALL draw one square box whose side is blockSize, else inlineSize, else the size the product's layout gives it, else one line box of the text style in effect where it stands (SKL-3), and SHALL draw it round. WHERE the place is narrower than the side THE skeleton SHALL make the square as large as the place allows and keep it square: a circle is never drawn as an oval. The circle SHALL NOT read lines. |
SKL-6 | THE skeleton SHALL keep the box of every placeholder, and so its own, unchanged from the moment it is inserted to the moment it is removed — while it waits to be shown (SKL-7), while it is shown and while it stirs (SKL-12) — and SHALL NOT guess what is coming: it draws the placeholders the product gave, in the sizes the product gave, and nothing of the content. That the content takes the box its placeholders held is the product's to arrange, by placing each placeholder where its content will be and as that content will be placed. |
SKL-7 | WHEN the skeleton is inserted into a view THE skeleton SHALL wait for its show delay (SKL-9) before it is shown, and WHILE it waits SHALL draw nothing, SHALL run no animation, SHALL be absent from the accessibility tree (no role, no name, no busy state), and SHALL still take the box it takes when shown (SKL-1 to SKL-5), so that nothing around it moves when it appears; a show delay of 0 SHALL show it as it is inserted. |
SKL-8 | WHEN its show delay ends THE skeleton SHALL be shown: it SHALL draw its placeholders at once, at their resting opacity and without an entrance of their own, expose itself as SKL-15 says without announcing itself (SKL-16), and start the animation of SKL-12 at the beginning of a pulse. |
SKL-9 | THE skeleton SHALL take its show delay from showDelay, a number of milliseconds used as given (the motion dial does not scale it). WHILE showDelay is null THE skeleton SHALL use comp.skeleton.motion.show-delay in its place; IF showDelay is negative or not a finite number THE skeleton SHALL use the token likewise and in debug builds report the value it ignored. |
SKL-10 | THE skeleton SHALL treat its show delay as a waiting time, not motion: WHERE motion is reduced it SHALL keep it, on every platform, including one whose reduced-motion setting removes every animation; and it SHALL keep counting it while the skeleton cannot be seen (scrolled out of view, in a hidden view), because the delay measures the wait, not what is seen. |
SKL-11 | WHEN the skeleton is removed before its show delay ends THE skeleton SHALL have drawn, exposed and announced nothing, and WHEN it is removed while shown it SHALL disappear at once, without a motion of its own: how the content enters is the content's. WHEN it is inserted again THE skeleton SHALL wait its whole show delay again; hiding it without removing it (a hidden ancestor, scrolling) SHALL neither restart nor pause the delay (SKL-10). WHEN showDelay changes while the delay is running THE skeleton SHALL finish the running delay as it started and use the new value from its next insertion. |
SKL-12 | WHILE the skeleton is shown THE skeleton SHALL stir as comp.skeleton.motion.animation names, without end. pulse SHALL ease the opacity of every placeholder's fill from its resting value to comp.skeleton.placeholder.dim-opacity of it over comp.skeleton.motion.dim-duration with comp.skeleton.motion.dim-easing and back over the same time on the same curve, every placeholder of the skeleton in step with the others. wave SHALL put each point of each placeholder through the same fall and return, each point later than the skeleton's start edge by a share of one whole pulse equal to its distance from that edge over the skeleton's inline size, so that one dimmer band travels from the start edge to the end edge through all the placeholders as through one surface. none SHALL leave the placeholders still at their resting opacity. In every manner THE skeleton SHALL change the fill's opacity only: no box moves, grows or changes shape, and nothing brighter than the resting fill is drawn. |
SKL-13 | WHERE reduced motion is requested THE skeleton SHALL NOT stir, whatever comp.skeleton.motion.animation names: it SHALL draw its placeholders still, at their resting opacity. The shapes, the label and the busy state still say that the place is waiting, and the show delay is kept (SKL-10). |
SKL-14 | WHILE the skeleton is not visible (scrolled out of view, in a hidden view, or in an app in the background) THE skeleton SHALL NOT run its animation, and SHALL resume it when it becomes visible. |
SKL-15 | WHILE the skeleton is shown and decorative is false THE skeleton SHALL expose itself to assistive technology as one element: the progressbar role with label as its name, no current value, and the platform's busy or indeterminate state. THE skeleton SHALL expose nothing of what it holds: no placeholder, no count of placeholders or of lines, and nothing of a layout the product placed in it. |
SKL-16 | THE skeleton SHALL NOT be focusable and SHALL NOT be a stop in the focus order, SHALL NOT announce itself when it is shown, when it changes or when it is removed, and SHALL NOT move keyboard or screen-reader focus. Saying that the content has arrived, where the product wants it said, is the product's, as it is beside a loading indicator. |
SKL-17 | WHILE decorative is true THE skeleton SHALL keep itself and everything it holds from assistive technology — no role, no name, no busy state — and SHALL draw, wait and stir as it otherwise would. A skeleton that stands inside another skeleton SHALL behave as decorative whatever its prop says: one wait is said once. |
SKL-18 | THE skeleton SHALL take its name from label, and WHILE label is empty from the product's words (the key loadingLabel); it has no words of its own in any language. WHILE both are empty and decorative is false THE skeleton SHALL still be drawn and still be exposed as SKL-15 says, without a name, and in debug builds report once that a skeleton has no label, naming the prop. |
SKL-19 | THE skeleton SHALL NOT take pointer, touch or keyboard input and SHALL NOT change anything it draws under a pointer, a press or focus: it has no hovered, focused, pressed, selected or disabled state and draws no state layer and no focus indicator. Whatever the product places in it besides placeholders SHALL be drawn as given, SHALL take no input and no focus, and SHALL NOT be exposed to assistive technology: a skeleton holds the shape of content, never content. |
SKL-20 | WHERE the platform draws with a person's own forced colors (the web's forced-colors mode, and a platform's equivalent where it has one) THE skeleton SHALL draw each placeholder, and each line of a text placeholder, as the outline of its shape, sys.border.hairline wide and inside its box, in the platform's text color, with no fill, and SHALL NOT stir: a fill is not drawn in that mode, and a placeholder that vanished would leave a blank place that says nothing. |
SKL-21 | WHILE the text size is enlarged THE skeleton SHALL grow its text placeholders with the text style they stand in, and every placeholder whose size is a line box with them, so that the skeleton still holds the box the enlarged content will take; it SHALL keep a size given as inlineSize or blockSize as given, SHALL never draw a placeholder wider than its place, SHALL keep its gap, and SHALL need no horizontal scrolling at a width of 320 points with text at 200 %. |
SKL-22 | WHERE the layout direction is right-to-left THE skeleton SHALL place its placeholders at the right edge, begin the shortened last bar of a text placeholder (SKL-3) and every placeholder narrower than its place at the right, and run a wave from the right edge to the left; a block and a circle are otherwise drawn as they are in a left-to-right layout. |
SKL-23 | THE skeleton SHALL take its layout direction from where it is used — the direction of the nearest ancestor that sets one, and the platform's own where none does — and SHALL have no direction setting of its own; WHEN that direction changes while the skeleton is shown THE skeleton SHALL draw itself for the new direction at once, without a motion of its own, keeping its place in its animation. |
SKL-24 | WHEN label, decorative or a placeholder's shape, lines, inlineSize or blockSize changes, or a placeholder is added or removed, while the skeleton waits or is shown THE skeleton SHALL draw and expose the new value at once, without a motion, without an announcement, and without restarting its show delay or its animation. THE skeleton SHALL neither show nor hide itself and SHALL NOT know when the content arrives: the product puts the skeleton in the content's place when the wait starts and takes it away when the wait ends, whatever the wait ends in. |
SKL-25 | WHEN a placeholder's shape names a value this spec does not have THE skeleton SHALL draw it as text; IF its lines is less than 1 or not a finite number THE skeleton SHALL use 1, and SHALL use the whole number below a lines that is not whole; IF its inlineSize or blockSize is negative or not a finite number THE skeleton SHALL treat it as null; WHEN comp.skeleton.motion.animation names a manner the skeleton does not know THE skeleton SHALL pulse. In each case it SHALL report the value it ignored in debug builds. |
SKL-26 | IF the skeleton holds no placeholder THE skeleton SHALL draw nothing, take no space and expose nothing, and in debug builds report that a skeleton holds no placeholder: a busy region with no shape in it is a blank place, and a wait whose shape is not known is a loading indicator's. |
Correspondencia de nombres por plataforma
Paridad no significa API idénticas. Cada plataforma expresa el mismo contrato con su propio estilo.
| Especificación | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| Componente | tanrei-skeleton | TanreiSkeleton | TanreiSkeleton | TanreiSkeleton | Skeleton |
label · Propiedad | label | label | label | label | label |
decorative · Propiedad | decorative | isDecorative | decorative | decorative | decorative |
showDelay · Propiedad | showDelay | showDelay | showDelay | showDelay | showDelay |
| Notas | Form: the light-DOM form a component around the product's own elements takes. <tanrei-skeleton label="Loading projects"> is a custom element with **no shadow root** around the product's own layout and its placeholders, and one stylesheet, @tanrei/web/skeleton.css, draws everything — the column and its gap, the placeholders, the show delay, the animation, reduced motion and forced colors — with selectors that start at tanrei-skeleton and at the placeholder's class, wrapped in :where(). **This is the point of the form: a skeleton is what a page shows before its script has run**, so it must be whole before the element is defined and where script never runs; a shadow root would draw nothing until the module arrived, which is the wait the skeleton is for. The show delay without script is an animation with a delay (animation: <appear> 0s linear var(--tanrei-comp-skeleton-motion-show-delay) both from visibility: hidden), so the box is held and nothing is drawn or exposed until it ends (SKL-7); the show-delay attribute sets a custom property the stylesheet reads, and attribute selectors cover show-delay="0" before definition. pulse is an opacity animation of the placeholders with animation-direction: alternate; wave is one mask or background gradient sized to the host and positioned per placeholder (background-attachment does not serve here; the element measures the placeholders' offsets and writes them as custom properties once defined, and before definition a wave is drawn as a pulse — say so in the docs); prefers-reduced-motion: reduce removes the animation and keeps the delay (SKL-10, SKL-13); forced-colors: active replaces the fill with an outline in CanvasText (SKL-20). The choice of manner reaches the stylesheet as the custom property that carries its name, read by a style query or, where those are missing, by the element. A text placeholder of several lines is one element calc(var(--lines) * 1lh) high whose bars are drawn as backgrounds; whether the bars can have eased corners and a shortened last bar from CSS alone in three engines, or need the element to write one child a line once defined, is the build's to find out — the box must be the same either way. What the element adds once defined, and only then: role="progressbar", aria-busy="true" and aria-label on the host when the delay ends, unless decorative or nested (then aria-hidden="true"); inert on the host, so that nothing inside takes focus or is read (SKL-19); pausing the animation while the host is not visible (SKL-14); the debug reports. A page that must be right before its script runs, or without it, writes role, aria-busy and aria-label on the element itself, and the element leaves what it finds; the placeholders are empty elements and expose nothing either way. The React wrapper renders the element around its children. Where script never runs the skeleton never ends unless the server replaces it: a product whose content arrives only by script gives the content, or a sentence, in <noscript>. | Proposed spelling, for the platform's agent to settle. TanreiSkeleton("Loading projects", isDecorative:, showDelay:) { … }, a view builder that holds placeholders directly (stacked, SKL-1) or inside the product's own stacks and grids. Not the platform's own redaction of a view, whose look is the platform's and which needs the real view to exist: the same idea drawn from Tanrei's tokens. Exposed as one accessibility element with the label, the progress trait's indeterminate form (updatesFrequently is not set) and its children ignored; accessibilityHidden while decorative or waiting. accessibilityReduceMotion stops the animation; the show delay is a task, not an animation. Not built on this platform yet: the stage color a fixture's surface names, which the text-lines-on-container-highest fixture draws on. | TanreiSkeleton(label, decorative, showDelay) { … }, a column scope. clearAndSetSemantics { contentDescription = label; progressBarRangeInfo = ProgressBarRangeInfo.Indeterminate } once shown, and clearAndSetSemantics { } with invisibleToUser() while decorative or waiting. The animation reads the system's animator duration scale: where it is 0 the placeholders are still, and the show delay is a coroutine delay that the scale does not shorten (SKL-10). Not built on this platform yet: the stage color a fixture's surface names, which the text-lines-on-container-highest fixture draws on. | TanreiSkeleton(label: …, decorative:, showDelay:, children: […]), or child: for a layout of the product's own. Semantics(label: label, excludeSemantics: true) with the progress indicator's indeterminate semantics once shown; ExcludeSemantics and IgnorePointer around everything it holds. MediaQuery.disableAnimationsOf stops the animation; the show delay is a Timer. Not built on this platform yet: the stage color a fixture's surface names, which the text-lines-on-container-highest fixture draws on. | <Skeleton label="Loading projects">…</Skeleton>. accessible, accessibilityRole="progressbar", accessibilityLabel and accessibilityState={{ busy: true }} once shown; importantForAccessibility="no-hide-descendants" and accessibilityElementsHidden while decorative or waiting; pointerEvents="none". AccessibilityInfo.isReduceMotionEnabled stops the animation. Follows the app's direction where an ancestor's is not known. Not built on this platform yet: the stage color a fixture's surface names, which the text-lines-on-container-highest fixture draws on. |
Tokens
| Token | Alias de | Valor resuelto (claro) |
|---|---|---|
--tanrei-comp-skeleton-container-gap | sys.space.space100 | 8px |
--tanrei-comp-skeleton-motion-animation | — | 0 |
--tanrei-comp-skeleton-motion-dim-duration | sys.motion.duration.extra-long4 | 1000ms |
--tanrei-comp-skeleton-motion-dim-easing | sys.motion.easing.standard | cubic-bezier(0.2, 0, 0, 1) |
--tanrei-comp-skeleton-motion-show-delay | sys.motion.role.show-delay | 300ms |
--tanrei-comp-skeleton-placeholder-color | sys.color.surface-variant | |
--tanrei-comp-skeleton-placeholder-dim-opacity | — | 0.5 |
--tanrei-comp-skeleton-placeholder-last-line-inline-size | — | 0.6 |
--tanrei-comp-skeleton-placeholder-shape-block | sys.shape.corner.medium | 8px |
--tanrei-comp-skeleton-placeholder-shape-circle | sys.shape.corner.full | 9999px |
--tanrei-comp-skeleton-placeholder-shape-text | sys.shape.corner.extra-small | 3px |
Fixtures
Representaciones canónicas. Todas las plataformas capturan cada fixture con el mismo identificador para poder comparar los resultados.
text
label: Loading the title showDelay: 0 items: 1 text-lines
label: Loading the article showDelay: 0 items: 1 text-lines-on-container-highest
label: Loading the article showDelay: 0 items: 1 text-short
label: Loading the name showDelay: 0 items: 1 block
label: Loading the picture showDelay: 0 items: 1 block-sized
label: Loading the action showDelay: 0 items: 1 block-line
label: Loading the row showDelay: 0 items: 1 circle
label: Loading the person showDelay: 0 items: 1 circle-line
label: Loading the mark showDelay: 0 items: 1 person
label: Loading the author showDelay: 0 items: 3 card
label: Loading the project showDelay: 0 items: 4 decorative
decorative: true showDelay: 0 items: 1 waiting
label: Loading the article items: 1 long-text
label: Loading the whole of the release notes f… showDelay: 0 items: 2 text-lines-rtl
label: جارٍ تحميل المقال showDelay: 0 direction: rtl items: 1 person-rtl
label: جارٍ تحميل الكاتب showDelay: 0 direction: rtl items: 3 Generado a partir de specs/skeleton.spec.json, tokens/comp/skeleton.tokens.json, design/tokens/
Lo que importa de un esqueleto es que nada se mueve. Su caja, y la de cada marcador de posición, es la misma desde el momento en que se inserta hasta el momento en que se quita: mientras espera para mostrarse, cuando aparece y mientras se anima.
El esqueleto no adivina nada. Dibuja los marcadores de posición que le diste, con los tamaños que les diste. Que el contenido ocupe la caja que reservaron sus marcadores de posición depende de ti: pon cada marcador donde estará su contenido, colocado como estará colocado ese contenido.
- Un marcador de posición de texto va dentro del encabezado, el párrafo o la celda donde estará el texto. Toma ese estilo de texto y es exactamente tan alto como ese número de líneas, también cuando quien lee amplía el texto.
- Di cuántas líneas ocupará el texto con
data-lines. Acertarás tanto como regular sea tu contenido. Un esqueleto al que le falta una línea mueve la página una línea, que sigue siendo menos de lo que la mueve un hueco en blanco. - Da a un bloque el tamaño de la imagen o del control: un número, una proporción o el tamaño que le da tu diseño. Un círculo recibe un solo número, su lado.
Pulsa Cargar: el esqueleto reserva el lugar durante dos segundos y medio, y el contenido ocupa su caja
Tokens en tres niveles
Tokens en tres niveles
Esta línea está debajo del artículo y no se mueve.
data-shape |
Ocupa el lugar de | Su tamaño |
|---|---|---|
text (predeterminado) |
Una o más líneas de texto. | data-lines cajas de línea del estilo de texto en el que está. Cada línea es una barra tan alta como el tamaño de la fuente. La última de varias líneas es más corta, porque un párrafo rara vez termina en el borde. inline-size define la longitud de las barras. |
block |
Una imagen, una tarjeta, un control, una fila. | inline-size y block-size, o el tamaño que le da tu diseño: una celda estirada, un aspect-ratio. Sin tamaño, es tan ancho como su lugar y tiene una línea de alto. |
circle |
La foto de una persona, una marca redonda. | Un lado: block-size o inline-size. Sin tamaño, tiene una línea de alto. |
Los marcadores de posición que son hijos directos del esqueleto se apilan uno debajo de otro, con una separación de 8. Cualquier otra cosa (un círculo junto a dos líneas, una cuadrícula de tarjetas) es tu propio diseño dentro del esqueleto. No hay esqueletos de tarjeta ni de lista ya hechos: tus pantallas son tuyas, y solo tú las conoces.
En una fila tuya, un marcador de posición de texto o un bloque necesita que esa fila le dé una anchura, como la necesitará el contenido: flex: 1, una pista de una cuadrícula o un inline-size.
Pon todos los marcadores de posición de una región en un solo esqueleto, con un solo label. Un esqueleto dentro de otro esqueleto no dice nada.
Donde otra cosa ya dice la misma espera (un indicador de carga en una línea de estado, un texto de estado, una región que tú marcas como ocupada y a la que das nombre), define decorative. El esqueleto se dibuja igual y queda oculto para la tecnología de apoyo, de modo que la espera no se lee dos veces.
Una línea de estado ya dice la espera, así que los marcadores de posición que tiene debajo son decorativos
Desde el momento en que se inserta, un esqueleto espera 300 ms antes de dibujarse y exponerse, con su caja ya reservada. Una espera que termina antes muestra un hueco que tenía el tamaño correcto desde el principio.
- Inserta el esqueleto cuando empiece la espera y quítalo cuando llegue el contenido. El retardo cuenta desde la inserción. Ocultar el esqueleto no lo reinicia.
- Define
show-delay="0"donde el esqueleto forma parte de la primera presentación de una página o de una vista, que no tiene nada más que mostrar. - El retardo es una espera, no movimiento: se conserva donde el movimiento está reducido.
Sustituye el esqueleto por el contenido, por un estado vacío donde no llegó nada, o por un callout con el estado de error donde la carga falló. Nunca caduca por sí solo: cuándo darse por vencido lo sabes tú.
El esqueleto no anuncia que el contenido ha llegado. Donde la llegada deba oírse (los resultados que responden a una búsqueda, una lista que se pidió), dilo con tu propia región activa o con el texto de estado del componente que lo pidió. Una vista que simplemente se abre con su contenido no necesita ningún anuncio.
De forma predeterminada, los marcadores de posición muestran un pulso: el relleno se atenúa hasta la mitad y vuelve, en todos a la vez, con un pulso cada dos segundos. Solo cambia la opacidad. Nada se mueve, y nada se dibuja más brillante que el relleno en reposo.
Un sistema de diseño puede elegir otra manera para todos sus esqueletos con el token comp.skeleton.motion.animation: pulse, wave (la misma atenuación, que recorre todo el esqueleto de su borde de inicio a su borde de fin como una sola banda) o none. No hay ningún ajuste para una sola instancia.
Donde el movimiento está reducido, los marcadores de posición se quedan quietos. Las formas, la etiqueta y el estado ocupado ya dicen que el lugar está esperando. Mientras el esqueleto no se puede ver, su animación no se ejecuta.
Un esqueleto es lo que una página muestra antes de que se haya ejecutado su script, así que @tanrei/web/skeleton.css lo dibuja entero sin el elemento. Unas pocas cosas necesitan el elemento, y son distintas hasta que este se define o donde nunca se ejecuta ningún script:
- El rol y el nombre. Una página que debe ser correcta antes de que se ejecute su script escribe
role="progressbar",aria-busy="true"yaria-labelen el propio elemento, y el elemento deja lo que encuentra. - Un
show-delaydistinto de0. La hoja de estilos espera el retardo del sistema de diseño. - Más de 24 líneas en un solo marcador de posición de texto.
- La manera
wave, que se dibuja como un pulso. - Un esqueleto dentro de una vista que no se muestra empieza su espera cuando la vista se muestra.
Donde nunca se ejecuta ningún script, un esqueleto no termina nunca salvo que el servidor lo sustituya. Un contenido que solo llega mediante un script necesita un <noscript> junto a su esqueleto.
- Da a los marcadores de posición la forma y el tamaño de lo que va a llegar.
- Pon los marcadores de posición de texto dentro del elemento donde estará el texto.
- Usa un solo esqueleto, con una sola etiqueta, para una sola espera.
- Sustitúyelo cuando la espera termine, termine en lo que termine.
- No pongas dentro de un esqueleto nada que una persona deba leer o usar. Lo que contiene no recibe ninguna entrada y queda oculto para la tecnología de apoyo. Un encabezado que ya se conoce o un botón que ya funciona van fuera de él.
- No lo uses para una espera breve en un control o en una fila, ni para una acción en curso. Eso es un indicador de carga.
- No cubras con él un contenido que ya está ahí.
- No dibujes cajas grises a mano.
- Rol
progressbar- Etiquetado
- label is the accessible name of the whole skeleton: what is loading. Once shown, the skeleton is one element — a progressbar with no value, in the platform's busy (indeterminate) state — and its placeholders are hidden; during its show delay, and while decorative is true, it is not exposed at all. It is exposed exactly as a loading indicator is, because it says the same thing: something is loading here.
- Objetivo mínimo
- El área de pulsación cumple el tamaño mínimo de objetivo aunque el tamaño visual sea menor. minimum 32px · pointer 44px · spacing 8px · touch 48px
Teclado
| Teclas | Acción |
|---|
Notas
- Not interactive: the skeleton takes no input and is never focusable (SKL-16, SKL-19), so there is no target of its own to size and minimumTarget holds trivially.
- One wait, said once. Every placeholder of a region belongs to one skeleton with one label; a skeleton inside another is silent (SKL-17). Where the same wait is already said — a loading indicator in a status row, a status text, a region the product itself marks busy and names — set decorative, or the wait is read twice.
- The skeleton does not announce that it appeared, and does not announce that the content arrived (SKL-16): it is removed with its busy state. Where arrival should be heard (results in answer to a search, a list that was asked for), the product says so through its own live region or the status text of the component that asked; a view that simply opens with its content needs no announcement.
- A wait shorter than the show delay shows and exposes nothing (SKL-7): no shapes that flash for a sighted person, and no progressbar that appears and vanishes for a screen-reader user.
- Nothing a person should read or use goes inside a skeleton: what it holds is kept from input and from assistive technology (SKL-19). A heading that is already known, a button that already works, stand outside it.
- The fill is decoration, held to no contrast ratio: comp.skeleton.placeholder.color is a low-emphasis fill, and in the default system it has the tone of the highest container step, so a placeholder on a surface of that tone is hard to see. The wait is never said by the fill alone: the label says it to assistive technology, and forced colors draw every placeholder as an outline (SKL-20).
- Motion: a pulse dims the fill by half and returns in 2 seconds in the default system, far below the three-per-second flash threshold; nothing moves and nothing brightens. Reduced motion stops it entirely (SKL-13): a large region that pulses is more than a small mark that does, and the shapes already say that the place is waiting.
- A skeleton that never ends tells a lie. The product replaces it with the content, with an empty state where nothing came, or with a callout of the error status where loading failed, and sets its own limit on the wait; a task that takes many seconds, or whose progress can be measured, is a progress indicator's.
- Text size, text spacing and reflow: SKL-21. A text placeholder follows the text style it stands in, so it grows with the reader's text size; a size given in points does not.
Generado a partir de specs/skeleton.spec.json, tokens/sys/measure.tokens.json
- Una vez mostrado, el esqueleto es un solo elemento para la tecnología de apoyo: una barra de progreso sin valor, ocupada, que recibe su nombre de
label. Se expone igual que un indicador de carga, porque dice lo mismo. - Sus marcadores de posición, cuántos son y sus líneas no se exponen, y tampoco un diseño que coloques dentro de él.
- Mientras espera para mostrarse no se expone en absoluto. Una espera más corta que el retardo no muestra ninguna barra de progreso que aparezca y desaparezca.
- Con
decorative, o dentro de otro esqueleto, queda oculto para la tecnología de apoyo. - No puede recibir el foco ni es una parada en el orden del foco, y tampoco nada de lo que contiene. No se anuncia a sí mismo y nunca mueve el foco.
- Donde el movimiento está reducido se queda quieto. El retardo se conserva.
- Con colores forzados, cada marcador de posición, y cada línea de texto, se dibuja como el contorno de su forma en el color del texto. En ese modo no se dibuja ningún relleno, y un marcador de posición que desapareciera dejaría un hueco en blanco.
- Con el texto ampliado, un marcador de posición de texto crece con su estilo de texto, así que el esqueleto sigue reservando la caja que ocupa el contenido ampliado. Un tamaño dado como número se mantiene. Nada es más ancho que su lugar; con una anchura de 320 y el texto al 200%, nada se desplaza en horizontal.
- En un diseño de derecha a izquierda, los marcadores de posición quedan a la derecha, la última línea, más corta, empieza por la derecha, y una ola va de derecha a izquierda.
- Las compilaciones de depuración notifican una forma desconocida, un número de líneas o un tamaño que no se pueden usar, un esqueleto sin marcadores de posición y un esqueleto sin etiqueta.
- Da un
labelen el idioma de la página que diga qué se está cargando («Cargando proyectos»), o da el texto una sola vez para todos los esqueletos consetWords({ loadingLabel: … }). El componente no aporta ningún texto. - Define
decorativedonde otra cosa ya dice la espera. - Di que el contenido ha llegado donde eso sea una novedad.
- Nunca dejes un esqueleto para siempre. Sustitúyelo por el contenido, por un estado vacío o por un error.
- El relleno es decoración y no está sujeto a ninguna relación de contraste. Sobre una superficie con el tono de contenedor más alto cuesta verlo. No dependas solo de él para decir que un lugar está esperando. Donde esté sobre una, apunta
comp.skeleton.placeholder.colora un rol más fuerte en una capa.