Skip to content
react-cards-opening

Styling by hand

The look that ships is a default, not a wall. Every part of every component takes a class of your own through classNames, and every rule in the library's stylesheet weighs exactly one class, so yours wins without !important. With Tailwind it takes one line of setup, and then utilities work on any part.

5 cards are hiding in here.

Run the scan. Each card opens where the beam finds it.

  • Still hidden
  • Still hidden
  • Still hidden
  • Still hidden
  • Still hidden

The same hunt, restyled with a dozen classes: square corners, a typewriter face, hard shadows.

With Tailwind 4

Import the library's stylesheet into the components layer. That puts it above Tailwind's reset, so the reset cannot flatten it, and below your utilities, so a utility always wins.

app.css
@import "tailwindcss";
@import "@react-cards-opening/ui/styles.css" layer(components);
tsx
<CardHunt
  classNames={{
    root: "rounded-none bg-zinc-950 p-10",
    headline: "font-serif text-5xl",
    scanButton: "rounded-md bg-pink-500 px-8 text-white",
    cell: "rounded-none",
    badge: "rounded-md",
    face: "rounded-xl p-4",
  }}
  {...rest}
/>

With plain CSS

The rco- class on each part is a stable name, and every rule on it weighs one class. Two ways to win follow from that. A rule of yours with a parent in front of it always wins. A single class of yours wins when your stylesheet loads after the library's.

css
/* Always wins: two classes against one. */
.my-hunt .rco-hunt-headline {
  font-family: Georgia, serif;
}

/* Wins when it comes later: one class against one. Hand it over with classNames. */
.headline {
  font-size: 40px;
}
tsx
import styles from "./hunt.module.css";

<CardHunt className="my-hunt" classNames={{ headline: styles.headline }} {...rest} />

Variables for the usual things

Corners, gaps and the dimmed page are variables, so the common changes need no class at all. Set them on any ancestor. The reveal is mounted on the document's body, outside your component, so set what it reads on :root, on body, or on the stage part.

VariableDefaultWhat it does
--rco-fontthe page's fontThe typeface of everything the library draws.
--rco-radius28pxThe corner of a card. The foil border follows it.
--rco-card-shadowa deep dropThe shadow under a card.
--rco-panel-radius28pxThe corner of the hunt's panel.
--rco-button-radiusa pillThe corner of the hunt's buttons.
--rco-badge-radius14pxThe corner of a badge.
--rco-cell-radius22%The corner of a grid cell.
--rco-cell-gap3pxThe room between grid cells.
--rco-backdropa near-black washWhat dims the page behind a card.
--rco-backdrop-blur3pxHow much the page behind is blurred.
--rco-z80Where the reveal's overlay stacks.

The parts of a hunt

CardHunt takes every key on this page: its own, and the grid's and the reveal's, which it passes down.

KeyThe library's classThe part
root.rco-huntThe panel. The same as className.
head.rco-hunt-headThe row that holds the words and the buttons.
headline.rco-hunt-headlineThe headline.
subline.rco-hunt-sublineThe line under it.
actions.rco-hunt-actionsThe buttons' row.
scanButton.rco-button-mainThe main button: Scan, then Keep scanning.
skipButton.rco-button-skipFind all, shown during a scan.
replayButton.rco-button-againScan again, shown once everything is found.
scan.rco-scanThe grid's root.
flash.rco-hunt-flashThe flash over the whole panel on a loud find.
finds.rco-findsThe list of badges.
badge.rco-badgeEach badge, found or not. A found one is a button.
badgeArt.rco-badge-artThe little glyph's box in a badge.
badgeName.rco-badge-nameThe card's name in a badge.
badgeWhere.rco-badge-whereWhere a found card was found.

The parts of the grid

ScanGrid takes these. Its own root takes className.

KeyThe library's classThe part
grid.rco-gridThe grid itself.
cell.rco-cellEvery cell.
marker.rco-cell-pressThe button inside a found cell.
beam.rco-beamThe beam that sweeps the grid.
beamGlow.rco-beam-glowThe soft light either side of the beam.
beamLine.rco-beam-lineThe bright line at its middle.
band.rco-bandThe band of light along the row being locked.
reticle.rco-reticleThe square that closes in on a cell.
ring.rco-ringThe ring that rolls out of a cracking cell.
spark.rco-crack-bitEach spark a cracking cell throws.
scanFlash.rco-scan-flashThe grid's own flash, used when it stands alone.

The parts of the reveal

CardOpening takes these, and the card's parts below.

KeyThe library's classThe part
stage.rco-stageThe fixed layer over the page that holds the reveal. A good place to set variables.
backdrop.rco-backdropThe dimmed page behind the card.
flyer.rco-flyerThe box that flies. It holds the card and what moves with it.
press.rco-flyer-pressThe button laid over the card: what a press and the focus land on.
rays.rco-raysThe wheel of rays behind a loud card.
burst.rco-burst-bitEach particle of the burst.
legendRays.rco-legend-raysThe second, finer wheel a legendary adds.
legendFlash.rco-legend-flashThe flash over the whole screen as a legendary turns.
wave.rco-legend-waveEach of a legendary's two shockwave rings.
sparkle.rco-sparkleEach of the diamonds that glint around a legendary.
effects.rco-fx-layerThe layer an effects plan is played on, behind the card.

The parts of a card

Card takes these. So does CardOpening, for the card it turns over.

KeyThe library's classThe part
face.rco-faceThe front of the card: its frame, its padding, its ground.
back.rco-backThe back of the card.
foilBorder.rco-legend-borderThe turning border of a legendary.
shine.rco-foilThe band of light that crosses a legendary's face.
art.rco-card-artThe room the glyph sits in, on the ready-made face.
name.rco-card-nameThe card's name.
rarity.rco-card-rarityThe tier as a word, under the name.
text.rco-card-textThe line of text.
note.rco-card-noteThe small last line.

States

State is written on the parts as data attributes, so a selector or a Tailwind data- variant can follow it.

OnAttributeWhen
.rco-huntdata-heroThe hunt is the page.
.rco-griddata-veiledThe grid is blank until the beam has passed.
.rco-celldata-level="0" to "4"How lit the cell is.
.rco-celldata-litThe beam has crossed it.
.rco-celldata-hitIt is the cell being cracked. --rco-hit is the card's colour.
.rco-celldata-foundA card was found here. --rco-found is its colour.
.rco-carddata-downThe card lies face down.
.rco-carddata-effectquiet, loud or legendary.
tsx
<CardHunt classNames={{ cell: "data-found:rounded-full data-[level='0']:opacity-40" }} {...rest} />

What to leave to the library

  • Colour, type, corners, shadows, padding: yours to change on any part.
  • `transform`, `opacity` and `visibility` on what moves: the flyer, the particles, the beam, the reticle, the rays. The animation writes these as inline styles and will overwrite a class.
  • The card's own colour comes from the theme's rarity, through --rco-tone. Change it there and the border, the burst and the rays follow together.
  • The words are labels, not styles.

Last updated . Read this page as Markdown.