Zubra UI
Code for
GitHub

loading-spinner

Something is loading. Announced to screen readers once, as label ("Loading" by default), and shown as a ring that turns (a pulse instead, for visitors who asked for less motion). size is sm, md or lg; inline puts the label beside it.

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

Sizes

Source: loading-spinner.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/loading-spinner.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/loading-spinner.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/loading-spinner.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/loading-spinner.json
One file, no dependencies (1.7 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/loading-spinner.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/loading-spinner.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/loading-spinner.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/loading-spinner.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/loading-spinner.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/loading-spinner.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/loading-spinner.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/loading-spinner.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/loading-spinner.js"></script>

The compiled install writes src/components/zubra/loading-spinner.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
<loading-spinner label="Loading your projects" size="md"></loading-spinner>

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

  const element = document.querySelector('loading-spinner');
  element.inline = true;
</script>
Example.jsx
import './components/zubra/loading-spinner.js';

const inline = true;

export function LoadingSpinnerExample() {
  return (
    <loading-spinner label="Loading your projects" size="md" inline={inline}></loading-spinner>
  );
}
Example.vue
<script setup>
import './components/zubra/loading-spinner.js';
const inline = true;
</script>

<template>
  <loading-spinner
    label="Loading your projects"
    size="md"
    :inline.prop="inline"
  ></loading-spinner>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/loading-spinner.js';
  const inline = true;
</script>

<loading-spinner label="Loading your projects" size="md" {inline}></loading-spinner>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/loading-spinner.js';

@Component({
  selector: 'app-loading-spinner-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <loading-spinner label="Loading your projects" size="md" [inline]="inline"></loading-spinner>
  `,
})
export class LoadingSpinnerExample {
  inline = true;
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
labelstring"Loading"
size"sm" | "md" | "lg""md"
inlinebooleanfalse

Size

0.8 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.0 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