# Stickers: API reference

> Every function, option and type, as the package exports them.

Source: https://cesarvenzac.com/stickers/docs/api

## sticker

```typescript
function sticker(element: HTMLElement, src: Source, options?: StickerOptions): Sticker;

type Source = string | CanvasImageSource;

type Sticker = {
  readonly element: HTMLElement;
  readonly place: Place;
  readonly state: "loading" | "resting" | "peeling" | "held" | "off";
  set(options: StickerOptions & { src?: Source }): void;
  peelOff(): void;
  restore(): void;
  destroy(): void;
};

type Place = { x: number; y: number; angle: number };
```

### StickerOptions

```typescript
type StickerOptions = {
  finish?: Finish; // "gloss"
  pattern?: Pattern; // a holographic foil's, "smooth"
  label?: string;
  outline?: number; // a 16th of the box's shorter side
  smooth?: number; // twice the outline
  border?: string; // white
  back?: string;
  print?: string;
  peel?: boolean; // true
  drag?: boolean; // false
  bounds?: Element | null; // its parent
  dark?: boolean | "auto"; // "auto"
  glow?: string; // phosphor green
  curl?: number; // the curl's radius, pixels
  comesOff?: number; // 0.5
  shine?: boolean; // true
  place?: Place;
  seed?: number;
  reducedMotion?: boolean; // the visitor's setting
  onPeel?: () => void;
  onPick?: () => void;
  onDrop?: (place: Place) => void;
};

type Finish = "paper" | "gloss" | "holo" | "glitter" | "glow";
type Pattern = "smooth" | "lines" | "squares" | "dots" | "shards";
const FINISHES: readonly Finish[];
const PATTERNS: readonly Pattern[];
```

## React

`@cesarvenzac/stickers/react`, a client component. Every option is a prop; the rest go on the `<div>`.

```typescript
function Sticker(props: StickerOptions & HTMLAttributes<HTMLDivElement> & {
  src: Source;
  handle?: (sticker: Sticker | null) => void;
}): JSX.Element;
```

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