Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentConfetti
Managercreate_confetti_manager

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>

API reference

Configure the manager, call its methods, and read its reactive state.

11 entries in configuration

PropertyTypeDefaultDescription
typestring nulldefines layout type (e.g. 'full' to fill screen) or null for local usage
amountnumber 50how many confetti pieces to generate
sizenumber 1.2base size multiplier for each confetti piece in rem
x_rangearray [-10,10]range for random x translation (in rem), e.g. [-10, 10]
x_spreadnumber 0.9scales how far confetti travels horizontally during the fall
y_rangearray [-3,-10]range for random initial y position (in rem)
time_rangenumber 50range (in ms) added to each piece's start delay
durationnumber 2000animation duration for each piece, in milliseconds
item_bgany nullbackground for confetti items, can be array of strings or 'rainbow'
fall_distancestring 10remvertical distance that confetti travels before disappearing
border_radiusnumber 0.1border radius (rem) applied to each piece