Skip to content
react-cards-opening

Effects library

Past the reveal's own show there is a library of 64 effects: particles, light, waves, and effects that act on the whole stage. Each is one name. Play one on its own, stack several at the same moment, or hand an opener a plan that says which tier gets what.

Vault Dragon

Legendary

Keeps one of every card ever dealt. This one is its own.

 

Particles

Light

Waves

Screen

Every effect, on a button. Pick a tier to change the colour they play in.

A package of its own

The effects live in @react-cards-opening/effects. The ui package brings it along and carries its stylesheet, so with the card components installed there is nothing to add, and everything on this page can be imported from either. For effects without cards, install it alone: nothing in it knows what a card is.

bash
pnpm add @react-cards-opening/effects gsap
tsx
import "@react-cards-opening/effects/styles.css";

Playing one

tsx
import { EffectLayer, type EffectLayerHandle } from "@react-cards-opening/effects";

const layer = useRef<EffectLayerHandle>(null);

<EffectLayer handle={layer} />;

layer.current?.play("shockwave");
layer.current?.play(["flash", "nova", "embers"], { at: cardElement, tone: "#f5c451" });

An effect is drawn for a card 300 pixels wide and scaled to whatever it celebrates, so the same sparks fits a badge and a full-screen reveal. It takes its colour from the tone you give it. EffectLayer has every option.

Particles (24)

Drawn on one canvas a layer, so a hundred of them cost about as much as one. Lights add up where they cross on a dark page and are painted on a light one.

EffectNameWhat it looks likeSeconds
SparkssparksA ring of lit squares thrown hard and slowing fast, the way the card's own burst does.1.3
ConfetticonfettiPaper thrown up from behind the card. It flutters, shows its darker side, and falls.3
EmbersembersSmall hot lights lifting off the card, drifting and flickering out on the way up.3.4
StarduststardustFour-pointed stars easing outward and twinkling as they slow.2.6
PixelspixelsHard square pixels on a grid, blown out and dropped. Nothing is smoothed.1.6
ShardsshardsSplinters of glass with one lit facet each, spinning as they fall.1.7
FountainfountainA jet of lights from the top of the card that climbs, spreads and rains back down.2.6
BubblesbubblesThin rings with a glint, wobbling up past the card and popping.3.2
SnowsnowSoft flakes falling across the whole stage, near ones larger and faster than far ones.5
PetalspetalsPetals let go from above the card, turning over and swinging side to side as they come down.4
CometscometsA handful of bright heads with tapering tails, fired outward.1.1
SpiralspiralThree arms of light winding out from behind the card like a small galaxy.2.2
FirefliesfirefliesSlow lights wandering around the card, each pulsing at its own pace.3.8
Rain of lightrainFast thin streaks falling past the card at a slant.2.2
OrbitorbitLights circling the card on a tilted ring, tightening as they fade.2.6
ImplosionimplosionStreaks drawn in from all around to the card's middle. A charge, best before something louder.0.95
SmokesmokeSoft puffs in the tier's colour swelling and thinning out behind the card.2.4
CoinscoinsCoins tossed up from the card, flashing as they turn and dropping under their own weight.2.2
FireworksfireworksThree shells going off around the card one after another, each a round burst that hangs and falls.2.6
GlitterglitterStars that light and go out where they stand, all around the card.2.4
Pixel ringring-of-pixelsA shockwave drawn in pixels: one clean ring of squares that widens and thins.1
DustdustA low cloud kicked out sideways from the card's foot, as if it had landed hard.1.5
LeavesleavesLeaves lifted off the card's edge by an updraft, turning over as they climb and drift apart.2.8
FlamesflamesThe card burns: fire climbs its sides, closes over the top of it and tears off, with sparks riding the heat.3

Light (16)

Elements the stylesheet draws and a timeline moves: wheels of rays, beams, flashes and glows.

EffectNameWhat it looks likeSeconds
RaysraysThe wheel of rays a loud card opens behind itself, turning slowly.2.6
BeamsbeamsA few broad, soft shafts of light sweeping past each other in two layers.3
HalohaloA soft ring of light around the card that breathes a few times and lets go.2.4
FlashflashThe whole stage goes white at the card and falls away through the tier's colour.0.85
Lens flareflareA wide streak through a hot core, with two ghosts sliding out along it, as through a lens.1.5
SpotlightspotlightA cone of light from the top of the stage that finds the card, sways and settles on it.2.6
AuroraauroraThree blurred bands in the tier's colour and the accent, drifting across each other.3.2
SunburstsunburstNeedle-thin spikes shot outward once, like light off a blade.0.9
BloombloomOne big soft swell of light from the middle that floods and fades.1.6
StarburststarburstA four-pointed star that snaps open, turns a little and closes: the glint on something precious.0.95
PillarpillarA column of light through the card from the top of the stage to the bottom, the beam over rare loot.2
LightninglightningJagged bolts out of the card that strike, vanish and strike again along new paths.0.62
Rim lightrimThe card's own outline, lit hot from behind, pulsing twice.1.6
FrostfrostA six-armed ice crystal that grows out from behind the card, turns a notch and melts away.2
SigilsigilA circle of power drawn behind the card: two rings, a six-pointed star and a second seal turning against it.2.6
CrackscracksThe air around the card splits: glowing fractures race outward, fork, and burn out slowly.1.9

Waves (11)

One shape getting bigger: rings, ripples and outlines thrown out from the card, or drawn in to it.

EffectNameWhat it looks likeSeconds
ShockwaveshockwaveOne thick ring thrown out from the card, thinning as it goes.1.1
RipplesripplesThree thin rings one after another, as on water.1.7
PulsepulseA filled disc with a bright edge that swells out and thins to nothing.0.9
SonarsonarA sweeping arm inside a fine ring, with two pings going out from the middle.2.1
Hex wavehexA six-sided outline that opens, turns a notch and fades, with a second one behind it.1.2
Diamond wavediamondThe same, cut as a diamond: sharper, and it turns a quarter as it goes.1.2
Ground slamslamA ring that spreads flat along the floor under the card, as if it had been dropped there.0.9
ConvergeconvergeRings closing in on the card from outside. A wind-up, the opposite of a shockwave.1
HeatwaveheatwaveA ring with no colour of its own: it bends and brightens whatever it passes over.1
Card echoechoThe card's own outline, three times over, each one larger and fainter than the last.1.4
NovanovaA disc of white light that bursts, hollows from the middle and leaves as a ring.1

Screen (13)

These act on the whole stage: they move it, wash it, or lay something across all of it.

EffectNameWhat it looks likeSeconds
ShakeshakeA short, sharp side-to-side jolt of the stage.0.42
QuakequakeA longer rumble that throws the stage about in every direction and dies down.0.85
PunchpunchThe stage jumps a few percent toward the viewer and springs back.0.55
VignettevignetteThe edges of the stage close in with the tier's colour and open again.1.5
TinttintThe whole stage takes the tier's colour for a moment, as through tinted glass.0.85
ScanlinesscanlinesFine lines across the stage and one bright band that runs down through them.1.3
GlitchglitchTorn bars of colour jumping across the stage while it skews, for half a second.0.5
Chroma splitchromaTwo flashes, one in the tier's colour and one in the accent, thrown apart and pulled back into one.0.6
LetterboxletterboxTwo black bars slide in at the top and bottom, hold, and leave: the stage becomes a film for a moment.2.4
FlickerflickerThe lights cut out three times, each cut shorter than the last.0.42
Speed linesspeedlinesThin lines racing in from the edges toward the card, redrawn every few frames.0.8
Impact framenegativeTwo frames of the stage in negative, the way a drawn impact is punctuated.0.26
Focus pullfocusThe stage starts blurred and comes sharp, as a lens finding its subject.0.8

Stacking

Effects are made to be played together. A good hit is usually three things at the same moment: something for the whole stage, a wave, and particles. ["flash", "shockwave", "sparks"] is a rare card. ["negative", "nova", "pillar", "embers", "quake"] is the one people screenshot. For a wind-up, play implosion or converge first and the hit after it with delay.

An effect of your own

An effect is an object: a name, how long it plays, and a play that adds to a GSAP timeline. Two helpers do the drawing. emit lets particles go, and part puts an element on the stage, already centred and sized. Your effect goes anywhere a name does.

ts
import { emit, part, playEffects, type Effect } from "@react-cards-opening/effects";

const hearts: Effect = {
  name: "hearts",
  kind: "particles",
  label: "Hearts",
  about: "Pink petals that rise instead of falling, over a soft ring.",
  seconds: 2.4,
  play: (stage, timeline) => {
    emit(stage, timeline, {
      count: 30,
      shape: "petal",
      colours: ["#fb7185", "#fda4af"],
      from: "edge",
      angle: [-Math.PI * 0.9, -Math.PI * 0.1],
      speed: [120, 380],
      gravity: -120,
      life: [1.4, 2.2],
      size: [8, 14],
      flip: [0.6, 1.4],
    });
    const ring = part(stage, "shockwave");
    timeline.fromTo(ring, { opacity: 1, scale: 0.2 }, { opacity: 0, scale: 3, duration: 0.9 }, 0);
  },
};

playEffects(layer, [hearts, "flash"]);
HelperWhat it does
emit(stage, timeline, spec)Lets particles go at a moment of the effect.
part(stage, name)Puts an element on the stage with the class rco-fx-<name>, centred on the effect. Pass true as a third argument for one that fills the stage.
piece(parent, name)An element inside a part: a ring's second line, a flare's ghost.
drawing(stage, name, { tag, count })An SVG outline that stays one line thick however far it is stretched. This is how the hex wave and the lightning are drawn.
corners(sides)The points of a shape with that many sides, for a drawing.
onEdge(angle, ratio)Where a line from the middle crosses the card's outline, for placing things on its edge.
tint(colour, amount), shade(colour, amount)A hex colour part of the way to white, or to black.
ts
import { corners, drawing, type Effect } from "@react-cards-opening/effects";

// A triangle thrown out from the card, drawn with the hex wave's own styles.
const triangle: Effect = {
  name: "triangle",
  kind: "wave",
  label: "Triangle",
  about: "Three sides, thrown out from the card.",
  seconds: 1,
  play: (stage, timeline) => {
    const [line] = drawing(stage, "hex", { tag: "polygon" });
    line.setAttribute("points", corners(3));
    timeline.fromTo(line.parentElement, { opacity: 1, scale: 0.3 }, { opacity: 0, scale: 3, duration: 1 }, 0);
  },
};

Particles come in eleven shapes: square, dot, mote, star, streak, shard, flake, ring, petal, puff and coin. Speeds are in pixels a second, angles in radians with zero pointing right, and from: "edge" starts each one on the card's outline, where it is seen from the first frame.

Restyling one

Every part that is not a particle is an element with a class: .rco-fx-shockwave, .rco-fx-rays, .rco-fx-pillar. Each rule weighs one class, like the rest of the stylesheet, so a rule of your own wins without a fight.

css
/* A dashed shockwave. */
.rco-fx-shockwave {
  border-style: dashed;
}

Last updated . Read this page as Markdown.