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.
import { Button } from "@/components/ui/button"
import { fxRecipes } from "@/lib/yan-fx"
<Button fx={fxRecipes.hearts}>Like</Button>| Prop | Type | Default |
|---|---|---|
sparklesSparkles and dots with a ring. | BurstOptions | - |
heartsPink hearts that float up. | BurstOptions | - |
starsA fast pop of lemon and lavender stars. | BurstOptions | - |
petalsSakura petals that drift down. | BurstOptions | - |
bubblesSoap bubbles rising. | BurstOptions | - |
confettiA 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.
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.
| Prop | Type | Default |
|---|---|---|
AccordionThe burst from the arrow when a row opens. | fx | - |
ButtonThe click burst. | fx | - |
CardThe click burst of an interactive card. | fx | - |
CheckboxThe sparkles when it is checked. In kawaii mode they join the bloom only when you pass fx. | fx | - |
DialogContentThe burst when the dialog opens. | fx | - |
DropdownMenuContentThe burst from the item you pick. | fx | - |
InputThe per-keystroke burst. | fx | - |
PopoverContentThe burst when the popover opens. | fx | - |
ProgressThe party at 100%. | fx | - |
RadioGroupThe burst from the chosen radio. | fx | - |
SelectThe burst when the heart lands on the trigger. | fx | - |
SkeletonThe burst when its content arrives. | fx | - |
SliderThe burst when a drag ends. | fx | - |
SwitchThe splash when the thumb lands. | fx | - |
TabsListThe sparkles where the candy lands. | fx | - |
TextareaThe per-keystroke burst. | fx | - |
TooltipContentThe 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:
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 })| Prop | Type | Default |
|---|---|---|
shapessparkle, heart, star, petal, bubble, dot or puff, used in turn. | FxShape[] | ["sparkle"] |
countNumber of particles. | number | 10 |
wordOnomatopoeia sticker drawn at the origin. | string | null | null |
wordStylepop springs up from nothing, slam lands from above. | "pop" | "slam" | "pop" |
colorsCSS colors or custom property names. | string[] | --yan-fx-1 … 5 |
powerVelocity multiplier. | number | 1 |
sizeBase particle size in px. | number | 9 |
angle / spreadAim the burst (radians). | number | up / full circle |
gravityDownward pull in px/s². Petals, bubbles and puffs keep their own. | number | 420 |
ringA soft shockwave ring at the origin. | boolean | false |
linesManga emphasis lines around the origin. | boolean | false |
Other effects
burst() is one word in the vocabulary. The rest are small, authored effects
that components combine into a beat:
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 anotherEvery effect is a no-op under prefers-reduced-motion: reduce.