Zubra UI
Code for
GitHub

skeleton-block

A grey placeholder in the shape of content that's on its way, so the page doesn't jump when it arrives. shape is text (lines lines, the last one shorter), circle or rect; width and height take any CSS length. Hidden from screen readers: say "loading" once elsewhere (a loading-spinner, or aria-busy on the region being filled).

This one has no events: it shows what it's given.

Source: skeleton-block.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/skeleton-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/skeleton-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/skeleton-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/skeleton-block.json
One file, no dependencies (2.8 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/skeleton-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/skeleton-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/skeleton-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/skeleton-block.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/skeleton-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/skeleton-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/skeleton-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/skeleton-block.json
No build: a script tag, straight from this site
HTML
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/skeleton-block.js"></script>

The compiled install writes src/components/zubra/skeleton-block.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.

Usage

index.html
<skeleton-block shape="text" width="20rem"></skeleton-block>

<script type="module">
  import './components/zubra/skeleton-block.js';

  const element = document.querySelector('skeleton-block');
  element.lines = 3;
</script>
Example.jsx
import './components/zubra/skeleton-block.js';

const lines = 3;

export function SkeletonBlockExample() {
  return (
    <skeleton-block shape="text" width="20rem" lines={lines}></skeleton-block>
  );
}
Example.vue
<script setup>
import './components/zubra/skeleton-block.js';
const lines = 3;
</script>

<template>
  <skeleton-block shape="text" width="20rem" :lines.prop="lines"></skeleton-block>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/skeleton-block.js';
  const lines = 3;
</script>

<skeleton-block shape="text" width="20rem" {lines}></skeleton-block>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/skeleton-block.js';

@Component({
  selector: 'app-skeleton-block-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <skeleton-block shape="text" width="20rem" [lines]="lines"></skeleton-block>
  `,
})
export class SkeletonBlockExample {
  lines = 3;
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
shape"text" | "circle" | "rect""text"
linesnumber3
widthstring""
heightstring""

Size

1.0 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.1 KB.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour