cards-lite draws playing cards by code. One call returns an SVG string — in Node at build time or in the browser — so a static site gets its hero art with no script on the page. It is a small library of procedural playing-card illustrations: seed spins the spread, the backs and the court emblems, brand spins the colours. Zero dependencies, 8.7 KB gzipped.
What it draws
- Spreads — fans, rows, cascades, stacks, heaps and blackjack pairs, flat or line art. Every overlapping spread keeps the top-left index of each card uncovered;
pileandstackare the deliberate exceptions, because hiding what is underneath is the motif. - One card or the whole deck —
Cards.card()draws a single card in a 5:7 box,Cards.deck()all 52 faces as one sheet. - Named hands — poker and blackjack hand presets, from
royal-flushtohigh-card, plusblackjackanddouble-down. A preset is data, not an evaluator: the library knows how to build a full house, never how to recognise one. - Backs and courts — card backs are patterned with the trigon, hex and octagon lattices of the sibling libraries; court cards carry a seeded geometric emblem rather than a figure.
How to use it
Install with npm install cards-lite. A plain <script> gets the global Cards, Node and bundlers get module.exports. At build time Cards.hand({ seed: 'example.com', brand: '#7c5cff' }) returns the markup to inline; in the browser Cards.init('#hero-art', { seed: 42, preset: 'royal-flush', motion: 'deal' }) draws into an element, and set() re-renders it with new options. The SVG has a viewBox and no size of its own — size it with CSS. A seed can be a string (a domain name is fine) or a number, which makes seeded hero art for static sites simple: every page gets its own hand, and the same seed always gives the same bytes.
Colour and options
You pass one to three brand colours and get a brand-aware four-colour deck: hearts, diamonds and clubs take your brand's hues, spades stay black and the face stays paper in both themes — a brand-coloured face stops reading as a card. Any role can be pinned with any CSS colour, including a custom property, so an inline hand follows a site's light/dark toggle with no script. Cards.palette() returns the derived colours to reuse on the page.
title gives the picture an accessible name; without it the SVG is aria-hidden. motion: 'deal' adds a one-shot CSS deal; under prefers-reduced-motion: reduce every card simply stays where it belongs.
Licence and stability
The output for a given seed and options is byte-identical, and a seed is independent of the brand: change the colours and no card moves. Within a minor version the output does not change; any change to it is a minor release with a changelog line, so pin the exact version if you render at build time. Nothing in the output names the library — every id, class and keyframe is a seeded token. MIT licence, built by 301ST for spintax.net.