Docs menu

Effects

Every particle comes from lib/yan-fx.ts. Components fire it for you, and the fx prop lets you change what flies out. キラッ

Recipes

fxRecipes are named bursts. Pass one to fx on any component that has it.

tsx
import { Button } from "@/components/ui/button"
import { fxRecipes } from "@/lib/yan-fx"

<Button fx={fxRecipes.hearts}>Like</Button>
PropTypeDefault
sparkles

Sparkles and dots with a ring.

BurstOptions-
hearts

Pink hearts that float up.

BurstOptions-
stars

A fast pop of lemon and lavender stars.

BurstOptions-
petals

Sakura petals that drift down.

BurstOptions-
bubbles

Soap bubbles rising.

BurstOptions-
confetti

A tall fountain in all five colors.

BurstOptions-

A recipe is a plain object, so spread it to adjust one: fx={{ ...fxRecipes.petals, count: 30 }}.

Try it everywhere

Pick a recipe, then poke each component. Default is what it does with no fx.

Buttonclick
Cardclick
Checkboxtick
Switchturn on
Radio Groupchoose
Sliderdrag, then let go
Inputtype
Textareatype
Progressfill it up
Tabsswitch
Selectpick one
Accordionopen

Dropdown Menupick an item
Popoveropen
Dialogopen
Tooltiphover or focus
Toastsend one
Skeletonload it

The fx prop

fx is merged over the component's own burst, so you only write what you change. Some bursts only fire in kawaii mode: Dialog, Popover, Select, Tabs and Tooltip.

PropTypeDefault
Accordion

The burst from the arrow when a row opens.

fx-
Button

The click burst.

fx-
Card

The click burst of an interactive card.

fx-
Checkbox

The sparkles when it is checked. In kawaii mode they join the bloom only when you pass fx.

fx-
DialogContent

The burst when the dialog opens.

fx-
DropdownMenuContent

The burst from the item you pick.

fx-
Input

The per-keystroke burst.

fx-
PopoverContent

The burst when the popover opens.

fx-
Progress

The party at 100%.

fx-
RadioGroup

The burst from the chosen radio.

fx-
Select

The burst when the heart lands on the trigger.

fx-
Skeleton

The burst when its content arrives.

fx-
Slider

The burst when a drag ends.

fx-
Switch

The splash when the thumb lands.

fx-
TabsList

The sparkles where the candy lands.

fx-
Textarea

The per-keystroke burst.

fx-
TooltipContent

The glint when the bubble pops in.

fx-
toast()

The burst from the candy mark.

fx-

burst()

Call it yourself for a moment no component covers:

tsx
import { burst } from "@/lib/yan-fx"

// at a point in the viewport…
burst({ x: 200, y: 120 }, { shapes: ["heart"], count: 12, word: "ドキッ" })

// …or at the center of an element
burst(document.querySelector("#save")!, { shapes: ["petal"], count: 20 })
PropTypeDefault
shapes

sparkle, heart, star, petal, bubble, dot or puff, used in turn.

FxShape[]["sparkle"]
count

Number of particles.

number10
word

Onomatopoeia sticker drawn at the origin.

string | nullnull
wordStyle

pop springs up from nothing, slam lands from above.

"pop" | "slam""pop"
colors

CSS colors or custom property names.

string[]--yan-fx-1 … 5
power

Velocity multiplier.

number1
size

Base particle size in px.

number9
angle / spread

Aim the burst (radians).

numberup / full circle
gravity

Downward pull in px/s². Petals, bubbles and puffs keep their own.

number420
ring

A soft shockwave ring at the origin.

booleanfalse
lines

Manga emphasis lines around the origin.

booleanfalse

Other effects

burst() is one word in the vocabulary. The rest are small, authored effects that components combine into a beat:

tsx
import { bloom, emote, fly, impact, puff, speedLines } from "@/lib/yan-fx"

impact(button)                 // soft glow + emphasis lines + clouds off both ends
puff(el, { count: 3 })         // "pofu" clouds, animated on twos
speedLines(el)                 // manga emphasis lines around an element
bloom(checkbox)                // a sakura unfolds around it, then lets its petals go
emote(el, "!")                // an emotion mark popping off a corner
fly(option, trigger)           // a heart that arcs from one element to another

Every effect is a no-op under prefers-reduced-motion: reduce.