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
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
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
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
<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
<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>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>
);
}<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('-') } } }) --><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>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
| Property | Type | Default |
|---|---|---|
max | number | 8 |
glare | boolean | true |
| Slot | For |
|---|---|
(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.