Skip to main content

Skeleton

Overview​

The Skeleton component provides a Bulma-styled skeleton loader for React applications, useful for indicating that content is loading.

It can be used as a placeholder for headings, paragraphs, blocks, or custom content.

info

Use Skeleton to improve perceived performance and give users a visual cue that content is being fetched.


Import​

import { Skeleton } from '@allxsmith/bestax-bulma';

Usage​

Default Skeleton​

The default usage of the Skeleton component renders a block placeholder, ideal for simulating loading content such as cards, images, or sections.

<Skeleton />

Skeleton Text​

Use the children prop to display placeholder text or content inside the skeleton block. This is useful for simulating paragraphs or multi-line content while data is loading. A screen reader still reads the text, so hide it with aria-hidden.

<Skeleton aria-hidden="true">
  "Quando in rerum natura homines aequales creantur, ab ipso Creatore quibusdam
  iuribus inalienabilibus donantur, inter quae sunt Vita, Libertas et quaerenda
  felicitas. Quoties aliquod regimen haec iura destruere conatur, populus habet
  potestatem tale regimen abrogare et novum constituere, quod iuribus suis
  tutandis aptissimum videatur. Prudentia quidem dictat vetera regimina levibus
  de causis non mutanda esse; sed cum diuturnus abusus ad despotismum vergit,
  ius est, immo officium, talia regimina exuere et novas custodes securitatis
  futurae constituere."
</Skeleton>

Lines Skeleton​

The lines variant of the Skeleton component renders multiple line placeholders, perfect for simulating text content loading. Use the lines prop to specify the number of lines.

<Skeleton variant="lines" lines={5} />


Skeleton Examples from useBulmaClasses.stories.tsx​

These show how the skeleton Bulma helper can be applied to various components using the skeleton prop and useBulmaClasses. A screen reader still reads what a skeleton hides, and the keyboard still reaches a skeleton control, so each one is hidden from assistive tech, and each control is out of the tab order too, as the accessibility notes say.

Skeleton Button​

Demonstrates a button with a skeleton loader, useful for indicating an action is in progress.

<Button skeleton tabIndex={-1} aria-hidden="true" color="dark">
  Skeleton Button
</Button>

Skeleton Buttons Group​

A group of buttons with skeleton loaders, ideal for simulating multiple actions loading simultaneously.

<Buttons>
  <Button skeleton tabIndex={-1} aria-hidden="true" color="dark">
    Skeleton
  </Button>
  <Button skeleton tabIndex={-1} aria-hidden="true" color="dark">
    Skeleton
  </Button>
  <Button skeleton tabIndex={-1} aria-hidden="true" color="dark">
    Skeleton
  </Button>
</Buttons>

Skeleton Icon​

An icon with a skeleton loader, perfect for indicating an icon's action is loading.

<Icon name="star" skeleton size="medium" />

Skeleton Image​

An image with a skeleton loader, great for simulating image loading.

<Image skeleton src="/img/react-logo.png" alt="Skeleton image" size="128x128" />

Skeleton Media​

Media object with a skeleton loader, useful for indicating media content is loading.

<Media skeleton aria-hidden="true">
  <Media.Left>
    <Image
      skeleton
      as="p"
      size="64x64"
      src="/img/carousel/carousel-banner-1-1by1.jpg"
      alt=""
    />
  </Media.Left>
  <Media.Content>
    <Content>
      <Paragraph>
        <Strong>Skeleton Name</Strong> <small>@skelly</small> <small>1m</small>
        <br />
        This is a skeleton media example.
      </Paragraph>
    </Content>
  </Media.Content>
</Media>

Skeleton Notification​

A notification with a skeleton loader, ideal for indicating a message or alert is loading.

<Notification skeleton aria-hidden="true">
  Skeleton notification message.
</Notification>

Skeleton Tag​

A tag with a skeleton loader, great for simulating tag or category loading.

<Tag skeleton aria-hidden="true" size="medium">
  Skeleton Tag
</Tag>

Skeleton Title​

A title with a skeleton loader, useful for indicating a section or heading is loading.

<Title skeleton aria-hidden="true" size="2">
  Skeleton Title
</Title>

Skeleton SubTitle​

A subtitle with a skeleton loader, perfect for simulating secondary heading loading.

<SubTitle skeleton aria-hidden="true" size="4">
  Skeleton SubTitle
</SubTitle>

Skeleton Input​

An input field with a skeleton loader, ideal for indicating form input is loading.

<Input skeleton tabIndex={-1} aria-hidden="true" placeholder="Skeleton Input" />

Skeleton TextArea​

A textarea with a skeleton loader, useful for simulating multi-line text input loading.

<TextArea
  skeleton
  tabIndex={-1}
  aria-hidden="true"
  placeholder="Skeleton TextArea"
  rows={3}
/>


Accessibility​

  • Its text is still read: Bulma hides a skeleton's text with a transparent color, and a screen reader reads it anyway, so <Skeleton>Lorem ipsum</Skeleton> reads "Lorem ipsum" and a Title with the skeleton prop is still a heading. Give a skeleton that holds placeholder text aria-hidden="true", whether it's a Skeleton or a component with the skeleton prop or hasSkeleton, or leave the block empty. The lines variant holds no text.
  • Controls still take the keyboard: Bulma's skeleton stops the pointer and not the keyboard, so a Button with the skeleton prop is still reached with Tab and pressed with Enter. Give a skeleton control, and anything focusable inside a skeleton, tabIndex={-1} as well as aria-hidden="true", so Tab passes it by and a screen reader skips it. Its look doesn't change, where disabled would draw it faded.
  • Say that it's loading: Skeleton has no role, and ARIA doesn't allow a name on its <div>, so don't give it an aria-label. Set aria-busy="true" on the region it stands in for, and remove it when the content arrives, swapping the skeleton for the content as soon as it's there. To announce that loading started or finished, change the text of a live region that's already on the page.
  • Reduced motion: under prefers-reduced-motion: reduce the pulse stops and each shape stays drawn in the skeleton color. That covers Skeleton, the skeleton prop and hasSkeleton. The rule ships in bestax's stylesheets: bestax.css and its variants, or extras.css next to your own Bulma, in either order.
  • Forced colors: Bulma paints each shape as a background color, which a contrast theme replaces with the page's color, and hides the text inside with a transparent color, which the theme paints in its text color. In forced colors, bestax draws every shape in GrayText, the theme's color for something unavailable, such as a disabled control, and turns the theme's colors off on the skeleton so the text Bulma hides stays hidden. That reaches what's inside it too, so anything there that Bulma draws in colors of its own, such as a control's edge and focus ring or a link, keeps Bulma's colors rather than the theme's. That covers Skeleton, the skeleton prop and hasSkeleton, and ships in the same stylesheets as the reduced-motion rule.
tip

Skeleton loaders provide a visual cue for loading but should not block navigation or accessibility.


The following components support the skeleton property for Bulma skeleton loaders:


Additional Resources​


Props​

PropTypeDefaultDescription
classNamestring—Additional CSS classes to apply
variant'block' | 'lines''block'Skeleton variant: block (single block) or lines.
linesnumber3Number of lines (only for lines variant).
childrenReact.ReactNode—Content inside the block (only for block variant). Bulma hides it, but a screen reader still reads it, so give a block that holds placeholder text aria-hidden="true".
...All standard <div> attributes—

CSS & Sass Variables​

Bulma declares these variables globally rather than on Skeleton's own element, so the defaults come from the theme. Override them anywhere above the component — on the element itself (via className/style) for a one-off, or on :root to retheme every instance. See Theme.

CSS VariableSass VariableDefault
--bulma-skeleton-background$skeleton-backgroundvar(--bulma-border)
--bulma-skeleton-radius$skeleton-radiusvar(--bulma-radius-small)
--bulma-skeleton-block-min-height$skeleton-block-min-height4.5em
--bulma-skeleton-lines-gap$skeleton-lines-gap0.75em
--bulma-skeleton-line-height$skeleton-line-height0.75em