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
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
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
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
<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
<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>import './components/zubra/skeleton-block.js';
const lines = 3;
export function SkeletonBlockExample() {
return (
<skeleton-block shape="text" width="20rem" lines={lines}></skeleton-block>
);
}<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('-') } } }) --><script>
import './components/zubra/skeleton-block.js';
const lines = 3;
</script>
<skeleton-block shape="text" width="20rem" {lines}></skeleton-block>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
| Property | Type | Default |
|---|---|---|
shape | "text" | "circle" | "rect" | "text" |
lines | number | 3 |
width | string | "" |
height | string | "" |
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.