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.
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 aTitlewith theskeletonprop is still a heading. Give a skeleton that holds placeholder textaria-hidden="true", whether it's aSkeletonor a component with theskeletonprop orhasSkeleton, or leave the block empty. Thelinesvariant holds no text. - Controls still take the keyboard: Bulma's skeleton stops the pointer and not the keyboard, so
a
Buttonwith theskeletonprop is still reached with Tab and pressed with Enter. Give a skeleton control, and anything focusable inside a skeleton,tabIndex={-1}as well asaria-hidden="true", so Tab passes it by and a screen reader skips it. Its look doesn't change, wheredisabledwould draw it faded. - Say that it's loading:
Skeletonhas no role, and ARIA doesn't allow a name on its<div>, so don't give it anaria-label. Setaria-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: reducethe pulse stops and each shape stays drawn in the skeleton color. That coversSkeleton, theskeletonprop andhasSkeleton. The rule ships in bestax's stylesheets:bestax.cssand its variants, orextras.cssnext 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 coversSkeleton, theskeletonprop andhasSkeleton, and ships in the same stylesheets as the reduced-motion rule.
Skeleton loaders provide a visual cue for loading but should not block navigation or accessibility.
Related Components
The following components support the skeleton property for Bulma skeleton loaders:
ButtonButtonsIconImageMediaNotificationTagTitleSubTitleInputTextAreauseBulmaClasses: The helper hook that enables theskeletonprop for any compatible component.
Additional Resources
Props
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes to apply |
variant | 'block' | 'lines' | 'block' | Skeleton variant: block (single block) or lines. |
lines | number | 3 | Number of lines (only for lines variant). |
children | React.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 Variable | Sass Variable | Default |
|---|---|---|
--bulma-skeleton-background | $skeleton-background | var(--bulma-border) |
--bulma-skeleton-radius | $skeleton-radius | var(--bulma-radius-small) |
--bulma-skeleton-block-min-height | $skeleton-block-min-height | 4.5em |
--bulma-skeleton-lines-gap | $skeleton-lines-gap | 0.75em |
--bulma-skeleton-line-height | $skeleton-line-height | 0.75em |