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.
@import "tailwindcss";
@import "@react-cards-opening/ui/styles.css" layer(components);<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.
/* 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;
}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.
| Variable | Default | What it does |
|---|---|---|
--rco-font | the page's font | The typeface of everything the library draws. |
--rco-radius | 28px | The corner of a card. The foil border follows it. |
--rco-card-shadow | a deep drop | The shadow under a card. |
--rco-panel-radius | 28px | The corner of the hunt's panel. |
--rco-button-radius | a pill | The corner of the hunt's buttons. |
--rco-badge-radius | 14px | The corner of a badge. |
--rco-cell-radius | 22% | The corner of a grid cell. |
--rco-cell-gap | 3px | The room between grid cells. |
--rco-backdrop | a near-black wash | What dims the page behind a card. |
--rco-backdrop-blur | 3px | How much the page behind is blurred. |
--rco-z | 80 | Where 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.
| Key | The library's class | The part |
|---|---|---|
root | .rco-hunt | The panel. The same as className. |
head | .rco-hunt-head | The row that holds the words and the buttons. |
headline | .rco-hunt-headline | The headline. |
subline | .rco-hunt-subline | The line under it. |
actions | .rco-hunt-actions | The buttons' row. |
scanButton | .rco-button-main | The main button: Scan, then Keep scanning. |
skipButton | .rco-button-skip | Find all, shown during a scan. |
replayButton | .rco-button-again | Scan again, shown once everything is found. |
scan | .rco-scan | The grid's root. |
flash | .rco-hunt-flash | The flash over the whole panel on a loud find. |
finds | .rco-finds | The list of badges. |
badge | .rco-badge | Each badge, found or not. A found one is a button. |
badgeArt | .rco-badge-art | The little glyph's box in a badge. |
badgeName | .rco-badge-name | The card's name in a badge. |
badgeWhere | .rco-badge-where | Where a found card was found. |
The parts of the grid
ScanGrid takes these. Its own root takes className.
| Key | The library's class | The part |
|---|---|---|
grid | .rco-grid | The grid itself. |
cell | .rco-cell | Every cell. |
marker | .rco-cell-press | The button inside a found cell. |
beam | .rco-beam | The beam that sweeps the grid. |
beamGlow | .rco-beam-glow | The soft light either side of the beam. |
beamLine | .rco-beam-line | The bright line at its middle. |
band | .rco-band | The band of light along the row being locked. |
reticle | .rco-reticle | The square that closes in on a cell. |
ring | .rco-ring | The ring that rolls out of a cracking cell. |
spark | .rco-crack-bit | Each spark a cracking cell throws. |
scanFlash | .rco-scan-flash | The grid's own flash, used when it stands alone. |
The parts of the reveal
CardOpening takes these, and the card's parts below.
| Key | The library's class | The part |
|---|---|---|
stage | .rco-stage | The fixed layer over the page that holds the reveal. A good place to set variables. |
backdrop | .rco-backdrop | The dimmed page behind the card. |
flyer | .rco-flyer | The box that flies. It holds the card and what moves with it. |
press | .rco-flyer-press | The button laid over the card: what a press and the focus land on. |
rays | .rco-rays | The wheel of rays behind a loud card. |
burst | .rco-burst-bit | Each particle of the burst. |
legendRays | .rco-legend-rays | The second, finer wheel a legendary adds. |
legendFlash | .rco-legend-flash | The flash over the whole screen as a legendary turns. |
wave | .rco-legend-wave | Each of a legendary's two shockwave rings. |
sparkle | .rco-sparkle | Each of the diamonds that glint around a legendary. |
effects | .rco-fx-layer | The 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.
| Key | The library's class | The part |
|---|---|---|
face | .rco-face | The front of the card: its frame, its padding, its ground. |
back | .rco-back | The back of the card. |
foilBorder | .rco-legend-border | The turning border of a legendary. |
shine | .rco-foil | The band of light that crosses a legendary's face. |
art | .rco-card-art | The room the glyph sits in, on the ready-made face. |
name | .rco-card-name | The card's name. |
rarity | .rco-card-rarity | The tier as a word, under the name. |
text | .rco-card-text | The line of text. |
note | .rco-card-note | The small last line. |
States
State is written on the parts as data attributes, so a selector or a Tailwind data- variant can follow it.
| On | Attribute | When |
|---|---|---|
.rco-hunt | data-hero | The hunt is the page. |
.rco-grid | data-veiled | The grid is blank until the beam has passed. |
.rco-cell | data-level="0" to "4" | How lit the cell is. |
.rco-cell | data-lit | The beam has crossed it. |
.rco-cell | data-hit | It is the cell being cracked. --rco-hit is the card's colour. |
.rco-cell | data-found | A card was found here. --rco-found is its colour. |
.rco-card | data-down | The card lies face down. |
.rco-card | data-effect | quiet, loud or legendary. |
<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.