# Stickers: Getting started

> Install Stickers and make a picture a sticker: in React, or on any element.

Source: https://cesarvenzac.com/stickers/docs/getting-started

```sh
npm install @cesarvenzac/stickers
```

Plain TypeScript, published as ES modules with their types, and no dependencies. React is an optional peer, for the React entry alone. It draws with WebGL 2, which every current browser has; where there's none, a sticker is drawn flat, its border and shadow included.

## A first sticker

`sticker` makes an element a sticker of a picture. The element is the sticker's box: give it a size, and the picture is fitted inside, a border grown round it.

```typescript
import { sticker } from "@cesarvenzac/stickers";

const heart = sticker(document.querySelector(".heart")!, "/heart.svg", {
  finish: "holo",
  label: "A heart",
});
```

It peels from an edge unless `peel` is false, and with `drag` it can be picked up and stuck down elsewhere: [Peeling and moving](https://cesarvenzac.com/stickers/docs/peeling-and-moving). Its finish is how it takes the light: [Finishes](https://cesarvenzac.com/stickers/docs/finishes).

## In React

`Sticker` is a `<div>` that's a sticker of `src`. Its other props go on the `<div>`:

```tsx
import { Sticker } from "@cesarvenzac/stickers/react";

<Sticker
  src="/heart.svg"
  finish="holo"
  drag
  label="A heart"
  className="size-40"
/>;
```

A server draws the picture itself, with a border made of drop shadows, and the sticker takes over as soon as it's drawn: nothing moves as the page hydrates. It's a client component, React 18 or later.

## Pictures

`src` is any of these:

- An image's address. Its pixels are read to cut round it, so one from another site needs CORS.
- SVG markup, `<svg …>`. Its `var(--…)` and `currentColor` are read on the sticker's element, so a sticker can be painted in your page's tokens and follow them.
- Anything a canvas draws: an image, a canvas, an `ImageBitmap`, a video's frame (in the browser alone, in React).

The picture's own alpha is its outline: what's half opaque or more is the art, and the border (`outline`, a sixteenth of the box's shorter side unless said) is grown round it. Gaps narrower than `smooth` are closed and holes are filled, as a kiss-cut follows one smooth contour; `outline: 0` cuts close to the art.

```tsx
<Sticker src={logo} outline={10} smooth={24} border="#fff7e8" />
```

## Stickers's docs

- [Overview](https://cesarvenzac.com/stickers.md): Stickers for the web: die-cut from any picture, peeled, picked up and stuck down, lit by the pointer.
- [Getting started](https://cesarvenzac.com/stickers/docs/getting-started.md): Install Stickers and make a picture a sticker: in React, or on any element.
- [Peeling and moving](https://cesarvenzac.com/stickers/docs/peeling-and-moving.md): How a sticker peels, comes off, is picked up and stuck down, and how to keep where it's been put.
- [Finishes and the light](https://cesarvenzac.com/stickers/docs/finishes.md): Paper, gloss, holographic foil in five patterns, glitter and glow in the dark: how each takes the light.
- [API reference](https://cesarvenzac.com/stickers/docs/api.md): Every function, option and type, as the package exports them.
- [Scratch cards](https://cesarvenzac.com/stickers/docs/scratch-cards.md): A coating in any finish over whatever an element holds, scratched off with a coin's ragged edge.
