# Confetti — SvelteKit UI

Package: sveltekit-ui 1.1.94

Page: https://www.sveltekit-ui.com/components/confetti

Category: Feedback

Creates a confetti animation with configurable item count, size, and random spread. There is a confetti component already in the Layout componet if full screen confetti is desired

Public component import: `Confetti`

Public manager import: `create_confetti_manager`

## Usage

```svelte
<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Confetti, create_confetti_manager, Button, create_button_manager } from "sveltekit-ui"

  const manager = create_confetti_manager({ amount: 40, time_range: 1000 })

  const celebrate_button = create_button_manager({
    text: "Celebrate",
    on_click: () => manager.show_confetti(),
  })
</script>

<Button manager={celebrate_button} />
<div style="position: relative; height: 12rem; overflow: hidden;">
  <Confetti {manager} />
</div>
```

## Configuration

### `type`

- type: string
- default: null
- description: defines layout type (e.g. 'full' to fill screen) or null for local usage

### `amount`

- type: number
- default: 50
- description: how many confetti pieces to generate

### `size`

- type: number
- default: 1.2
- description: base size multiplier for each confetti piece in rem

### `x_range`

- type: array
- default:
  - -10
  - 10
- description: range for random x translation (in rem), e.g. [-10, 10]

### `x_spread`

- type: number
- default: 0.9
- description: scales how far confetti travels horizontally during the fall

### `y_range`

- type: array
- default:
  - -3
  - -10
- description: range for random initial y position (in rem)

### `time_range`

- type: number
- default: 50
- description: range (in ms) added to each piece's start delay

### `duration`

- type: number
- default: 2000
- description: animation duration for each piece, in milliseconds

### `item_bg`

- type: any
- default: null
- description: background for confetti items, can be array of strings or 'rainbow'

### `fall_distance`

- type: string
- default: 10rem
- description: vertical distance that confetti travels before disappearing

### `border_radius`

- type: number
- default: 0.1
- description: border radius (rem) applied to each piece

## Methods

### `show_confetti()`

- description: resets the confetti state, preps items, then triggers the confetti animation
- parameters:
- returns: void

## Returned state

### `type`

- type: string
- description: layout type (e.g. 'full' for full-screen confetti) if set

### `confetti_prepped`

- type: array
- description: array of pre-calculated confetti items with random transformations

### `is_show`

- type: boolean
- description: indicates if confetti is currently visible

### `border_radius`

- type: number
- description: border radius in rem for each piece

### `fall_distance`

- type: string
- description: vertical distance that confetti falls before disappearing

### `size`

- type: number
- description: base size multiplier (rem) for each confetti piece

### `transition_duration`

- type: number
- description: duration (ms) for each confetti piece’s animation

### `x_spread`

- type: number
- description: horizontal spread factor used in the confetti path animation
