35
Componentregistry:componentModern collection

Sticker

A die-cut sticker you can peel off and stick somewhere else, in a matte, gloss or holographic finish. Drag from any edge and the flap folds back over itself with its liner backing, crease shading and a shadow underneath. Let go early and it falls flat; peel past a threshold and it comes off in your hand, tilting as you carry it, and slaps down where you drop it. The gloss follows the mouse, the border is traced from the artwork's real shape, the nearest corner curls up on hover, and the keyboard can lift and move it.

Preview

⌘K
Drag to peel it off and stick it somewhere else, or press Enter to lift it and use the arrow keys.
SHIPPED
Drag to peel it off and stick it somewhere else, or press Enter to lift it and use the arrow keys.
Drag to peel it off and stick it somewhere else, or press Enter to lift it and use the arrow keys.
you
Drag to peel it off and stick it somewhere else, or press Enter to lift it and use the arrow keys.
200 OK
Drag to peel it off and stick it somewhere else, or press Enter to lift it and use the arrow keys.
shipit.
Drag to peel it off and stick it somewhere else, or press Enter to lift it and use the arrow keys.
LICENCEMIT
Drag to peel it off and stick it somewhere else, or press Enter to lift it and use the arrow keys.
Finish
Border6 px
Back
Comes off at40%

Restuck0

Installation

$ npx shadcn@latest add @creative-ui/sticker

On an older shadcn CLI, use the URL: npx shadcn@latest add https://ui.krutikraut.com/r/sticker.json

Usage

Example.tsx
import { Sticker } from "@/components/sticker"

export function Laptop() {
  return (
    <div className="relative h-80 rounded-xl bg-neutral-200">
      <Sticker rotate={-8} label="Team logo" className="absolute top-8 left-10 w-28">
        <img src="/stickers/logo.svg" alt="" />
      </Sticker>
      <Sticker rotate={6} finish="holo" label="Launch badge, in foil" className="absolute top-24 right-12 w-24">
        <LaunchBadge />
      </Sticker>
    </div>
  )
}

// Any element works. Its painted shape, here a pill, becomes the die cut.
<Sticker border={4} backColor="#d9c4a0">
  <div className="rounded-full bg-teal-700 px-5 py-2 font-serif text-white italic">peel me</div>
</Sticker>

// Three surfaces: a clear laminate (the default), foil, or plain paper with no shine.
<Sticker finish="gloss"><Art /></Sticker>
<Sticker finish="holo"><Art /></Sticker>
<Sticker finish="matte" liner={false}><Art /></Sticker>

// Remember where people leave it.
<Sticker defaultOffset={saved} onStick={(offset) => save(offset)}>
  <Art />
</Sticker>

// Peel only: it lifts and falls back flat, and never leaves its spot.
<Sticker movable={false}>
  <Art />
</Sticker>

Props

PropTypeDefaultDescription
children*React.ReactNode—The artwork: an image, an inline SVG or any element. It sets the sticker's size, and its painted shape becomes the die cut.
bordernumber6Width of the die-cut border in px, traced around the artwork's shape. 0 for none.
borderColorstring"#ffffff"Colour of the die-cut border.
backColorstring"#eceae4"Colour of the sticker's back, seen on the peeled flap.
finish"matte" | "gloss" | "holo""gloss"The surface. gloss is a clear laminate: a highlight follows the mouse and slides as the sticker is carried, and the cut edge catches a rim of light. holo is foil, with coloured light that shifts as it moves. matte has no shine.
linerbooleantruePrint a faint ruled grid on the back, like the liner a sticker peels from.
rotatenumber0Tilt in degrees. Peeling and dragging account for it.
thresholdnumber0.4Share of the sticker, from 0 to 1, that has to be peeled before it comes off in your hand.
movablebooleantrueLet the sticker come off and be stuck down somewhere else. When false it only peels and falls back flat, and isn't focusable.
boundedbooleantrueKeep a moved sticker's centre inside its parent. Past the edge it drags with resistance, then springs back in.
hoverPeelbooleantrueCurl the nearest corner up as the mouse comes close. Mouse only, and off with reduced motion.
defaultOffset{ x: number; y: number }—Where the sticker starts, relative to its place in the layout, in px. Read once on mount.
onPeel() => void—Called when the sticker comes off, by peeling or from the keyboard.
onStick(offset: { x: number; y: number }) => void—Called when the sticker is stuck down, with its offset from its place in the layout. Feed it back as defaultOffset.
labelstring"Sticker"Accessible name of the sticker, which is a button.
hapticsbooleantrueBuzz the device as the sticker comes off and goes down, where the Vibration API exists (most Android browsers).

Also accepts every div prop, which is spread onto the root element.

Notes

  • The peel starts at the artwork's real edge, not its bounding box. The component reads the shape from images, inline SVGs, backgrounds and text inside it. If a cross-origin image blocks that, it falls back to the image's box, so serve sticker art from your own origin or with CORS.
  • The children render six times: the sticker, its gloss, its back, the crease shading and two shadows (five on a matte sticker). The copies are inert and hidden from screen readers, but anything with effects runs in every copy, so keep stickers to artwork.
  • The gloss is an SVG lighting filter, redrawn while the light moves. It follows a mouse only; on touch screens and with reduced motion it rests at the top left. For a page with dozens of stickers, finish="matte" is the lightest.
  • Peeling past the threshold lifts the sticker into your hand. Drag it anywhere and let go to stick it down. The sticker touched last sits on top.
  • Enter or Space lifts a focused sticker, the arrow keys move it (Shift for bigger steps), Enter sticks it down and Escape puts it back.
  • The sticker sets touch-action: none, so a finger on it peels instead of scrolling the page.
  • The border, back and shadows are SVG filters, so they reach past the sticker's box. Leave a little room around it, or a parent with overflow: hidden clips them.
  • Position the sticker with className (for example absolute top-8 left-10 w-28) and tilt it with rotate. A transform on the sticker itself is overwritten while it moves.

Dependencies

shadcn/utils