Zubra UI
Code for
GitHub

backdrop-pattern

A decorative background behind its content: a grid, dots, a soft gradient mesh, film grain, or an aurora. Drawn in CSS from the theme's colours, so it follows light, dark and any theme. It's hidden from screen readers and never takes clicks or focus; with animated the mesh and aurora drift slowly, and stay still for visitors who asked for less motion. fade softens the edges toward the page. size is the grid or dot spacing.

Ship components, not frameworks

One file each, in any stack.

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

Source: backdrop-pattern.zb, and its registry item.

Install

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

The compiled install writes src/components/zubra/backdrop-pattern.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
<backdrop-pattern pattern="aurora">
  <div class="demo-hero">
    <h2>Ship components, not frameworks</h2>
    <p>One file each, in any stack.</p>
  </div>
</backdrop-pattern>

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

  const element = document.querySelector('backdrop-pattern');
  element.animated = true;
</script>
Example.jsx
import './components/zubra/backdrop-pattern.js';

const animated = true;

export function BackdropPatternExample() {
  return (
    <backdrop-pattern pattern="aurora" animated={animated}>
      <div className="demo-hero">
        <h2>Ship components, not frameworks</h2>
        <p>One file each, in any stack.</p>
      </div>
    </backdrop-pattern>
  );
}
Example.vue
<script setup>
import './components/zubra/backdrop-pattern.js';
const animated = true;
</script>

<template>
  <backdrop-pattern pattern="aurora" :animated.prop="animated">
    <div class="demo-hero">
      <h2>Ship components, not frameworks</h2>
      <p>One file each, in any stack.</p>
    </div>
  </backdrop-pattern>
</template>

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

<backdrop-pattern pattern="aurora" {animated}>
  <div class="demo-hero">
    <h2>Ship components, not frameworks</h2>
    <p>One file each, in any stack.</p>
  </div>
</backdrop-pattern>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/backdrop-pattern.js';

@Component({
  selector: 'app-backdrop-pattern-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <backdrop-pattern pattern="aurora" [animated]="animated">
      <div class="demo-hero">
        <h2>Ship components, not frameworks</h2>
        <p>One file each, in any stack.</p>
      </div>
    </backdrop-pattern>
  `,
})
export class BackdropPatternExample {
  animated = true;
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
pattern"grid" | "dots" | "mesh" | "grain" | "aurora""grid"
sizestring"24px"
fadebooleantrue
animatedbooleanfalse
Slots
SlotFor
(default)What sits on the background.

Size

1.3 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.5 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