Zubra UI
Code for
GitHub

tilt-card

A card that tilts toward the pointer in 3D (up to max degrees) and springs back flat, with an optional glare. Flat on touch screens and under reduced motion.

Recipes that scale

Change the batch size and every amount follows.

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

Source: tilt-card.zb, and its registry item.

Install

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

The compiled install writes src/components/zubra/tilt-card.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
<tilt-card>
  <h3>Recipes that scale</h3>
  <p>Change the batch size and every amount follows.</p>
</tilt-card>

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

  const element = document.querySelector('tilt-card');
  element.max = 8;
  element.glare = true;
</script>
Example.jsx
import './components/zubra/tilt-card.js';

const max = 8;
const glare = true;

export function TiltCardExample() {
  return (
    <tilt-card max={max} glare={glare}>
      <h3>Recipes that scale</h3>
      <p>Change the batch size and every amount follows.</p>
    </tilt-card>
  );
}
Example.vue
<script setup>
import './components/zubra/tilt-card.js';
const max = 8;
const glare = true;
</script>

<template>
  <tilt-card :max.prop="max" :glare.prop="glare">
    <h3>Recipes that scale</h3>
    <p>Change the batch size and every amount follows.</p>
  </tilt-card>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/tilt-card.js';
  const max = 8;
  const glare = true;
</script>

<tilt-card {max} {glare}>
  <h3>Recipes that scale</h3>
  <p>Change the batch size and every amount follows.</p>
</tilt-card>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/tilt-card.js';

@Component({
  selector: 'app-tilt-card-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <tilt-card [max]="max" [glare]="glare">
      <h3>Recipes that scale</h3>
      <p>Change the batch size and every amount follows.</p>
    </tilt-card>
  `,
})
export class TiltCardExample {
  max = 8;

  glare = true;
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
maxnumber8
glarebooleantrue
Slots
SlotFor
(default)The card's content.

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.8 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