Components
Typed React components for the UpCoupons publisher coupon pages, styled with Tailwind from one set of theme tokens. Every example on this page is live and themed for Tom’s Hardware. A 2026 rebuild of the system I designed at Upfeat, showing how I maintain it today.
- React
19.3.0 - Components
- TypeScript
5.9.3 - Typed props
- Tailwind CSS
4.3.5 - Styling from the token theme
- Next.js
16.4.5 - This docs site
- Vitest
3.2.7 - Test runner
- Testing Library
16.3.3 - Behaviour tests
- axe-core
4.14.0 - Automated accessibility scan
- Shiki
3.23.0 - Code highlighting
Setup
Theme values live in one token file per publisher, the equivalent of one Figma variable mode. The build checks every publisher sets every role, then writes CSS custom properties and the Tailwind theme. Utilities are prefixed uc: and only the shared roles exist, so a component can’t reach for a colour outside the theme.
npm run build:tokens # tokens/*.tokens.json → CSS variables + Tailwind theme
npm test # behaviour tests and an automated accessibility scan per componentimport { OfferCard, OfferDialog, type Offer } from './ui';
import './ui/ui.css';
export function Featured({ offers }: { offers: Offer[] }) {
const [offer, setOffer] = useState<Offer | null>(null);
return (
<div data-uc-publisher="toms-hardware">
{offers.map((o) => <OfferCard key={o.id} offer={o} onSelect={setOffer} />)}
<OfferDialog offer={offer} onClose={() => setOffer(null)} storeHref={offer ? storeUrl(offer) : ''} />
</div>
);
}Rules
Written to be followed without asking, by a designer, an engineer or an AI model building a new page. The source is ui/rules.ts.
- Style with the shared roles only. Use
uc:bg-action,uc:text-on-action,uc:text-ink,uc:border-line,uc:bg-surface,uc:text-highlightand theuc:font-display,uc:font-sansanduc:font-editorialfamilies. Tailwind’s default palette and fonts are removed, souc:bg-red-500builds nothing. - Keep publisher extras out of shared components. Extras such as Forbes’s section colours live under extra in that publisher’s token file and are left out of the Tailwind theme. Only a component built for that publisher may use them.
- Treat retailer colours as artwork. A retailer’s logo background comes from
Retailer.backgroundand stays the same on every publisher. It is never a theme value. - One offer, one button. An offer card or coupon row is a single button that opens the offer dialog (
aria-haspopup="dialog"). Extra links, like “More Dell coupons”, sit beside it, never inside it. - Photos are decoration; logos name the retailer. Offer photos have empty alt text because the title already says what the offer is. A logo’s alt text is the retailer’s name, unless the name is visible next to it (decorative).
- Extend before adding. If a request changes how an offer looks, add a variant to an existing component. If it changes how the offer works, as cashback does, add a new component.
- Every interactive element shows focus. Buttons, links and tabs get a 2px outline in the action colour on keyboard focus (
uc:focus-visible:outline-action). - Every component ships with tests. Behaviour and accessible names are tested with Testing Library, and each test runs an axe check (
npm test). - Import from the index. Use
import { OfferCard } from "./ui", so a component’s file can move without breaking the pages that use it.
Testing
Every component has tests in ui/*.test.tsx, run with npm test. Each component section below lists its tests by name, read from those files when this page is built.
- Behaviour: Testing Library renders the component and uses it as a reader would: by its accessible name, with clicks and the keyboard.
- Accessibility scan: each component’s tests also run axe-core, which checks the rendered HTML against WCAG rules such as names for buttons, links and images, valid ARIA, and labelled form fields. A test proves the scan fails on a real problem.
- Not covered: colour contrast (the test environment doesn’t render styles) and testing with a real screen reader.
Foundations
The shared roles as Tom’s Hardware sets them. Shared components use only these. Change a value in the token file, run the build, and every component follows.
| Role | CSS variable | Tailwind | Value |
|---|---|---|---|
actionButtons, links and the 'Get code' step. The one colour a reader should act on. | --uc-action | uc:{bg,text,border}-action | #101f9e |
on-actionText and icons on an action-coloured fill, such as a solid button label. | --uc-on-action | uc:{bg,text,border}-on-action | #ffffff |
highlightRules under headings, category icons and hover states. Decoration that points, never a call to action. | --uc-highlight | uc:{bg,text,border}-highlight | #d8383b |
inkBody text and offer descriptions. | --uc-ink | uc:{bg,text,border}-ink | #333333 |
lineDividers between offers and card borders. | --uc-line | uc:{bg,text,border}-line | #dddddd |
surfaceBackground of cards, lists and dialogs. | --uc-surface | uc:{bg,text,border}-surface | #ffffff |
errorForm validation errors and failed actions. A state colour, the same on every publisher. | --uc-error | uc:{bg,text,border}-error | #cc0000 |
font-displayPage and section headlines, set in the publisher's headline face. | --uc-font-display | uc:font-display | UC Open Sans |
font-sansInterface text: offer titles, buttons, tabs, labels. | --uc-font-sans | uc:font-sans | UC Open Sans |
font-editorialLonger editorial copy, such as merchant introductions. | --uc-font-editorial | uc:font-editorial | UC Open Sans |
Generated CSS
[data-uc-publisher="toms-hardware"] {
--uc-action: #101f9e;
--uc-on-action: #ffffff;
--uc-highlight: #d8383b;
--uc-ink: #333333;
--uc-line: #dddddd;
--uc-surface: #ffffff;
--uc-error: #cc0000;
--uc-font-display: 'UC Open Sans', 'Arial', sans-serif;
--uc-font-sans: 'UC Open Sans', 'Arial', sans-serif;
--uc-font-editorial: 'UC Open Sans', 'Arial', sans-serif;
}Source: tokens/toms-hardware.tokens.json
{
"$description": "Tom’s Hardware.",
"color": {
"action": {
"$value": "#101f9e"
},
"on-action": {
"$value": "#ffffff"
},
"highlight": {
"$value": "#d8383b"
},
"ink": {
"$value": "#333333"
},
"line": {
"$value": "#dddddd"
},
"surface": {
"$value": "#ffffff"
},
"error": {
"$value": "#cc0000"
}
},
"font": {
"display": {
"$value": [
"UC Open Sans",
"Arial",
"sans-serif"
]
},
"sans": {
"$value": [
"UC Open Sans",
"Arial",
"sans-serif"
]
},
"editorial": {
"$value": [
"UC Open Sans",
"Arial",
"sans-serif"
]
}
}
}OfferCard
One offer in the style the publisher uses: led by a photo, by the retailer’s logo, or by text. Every variant shows the same content and opens the offer the same way, which is why they are variants of one component, not three components.
import { OfferCard } from './ui';const [offer, setOffer] = useState<Offer | null>(null);
<OfferCard offer={dell} variant="photo" onSelect={setOffer} />
<OfferCard offer={ulta} variant="logo" onSelect={setOffer} />
<OfferCard offer={kohls} variant="text" onSelect={setOffer} moreHref="/stores/kohls/" />
<OfferDialog offer={offer} onClose={() => setOffer(null)} storeHref={offer ? storeUrl(offer) : ''} />API
| Prop | Type | Default | Description |
|---|---|---|---|
offer | Offer | — | Retailer, title, category, and optional code and photo. |
variant | 'photo' | 'logo' | 'text' | 'photo' | How the card leads. A photo card without offer.photo falls back to logo. |
onSelect | (offer: Offer) => void | — | Called when the reader opens the offer, normally to show OfferDialog. |
moreHref | string | — | Adds a “More {retailer} coupons” link under the card. |
Tokens
linesurfaceinkactionfont-sansfont-display
Accessibility
- The card is one button named by the retailer logo and the title, with aria-haspopup="dialog".
- The photo has empty alt text: the title already says what the offer is.
- The “More coupons” link sits outside the button, so it is its own tab stop with its own name.
Tests
- Each variant: one button named by retailer and offer that opens the offer
- treats the photo as decoration, so screen readers hear the retailer and title once
- falls back to the logo card when an offer has no photo
- adds a link to the retailer’s other coupons
Also scanned for accessibility problems with axe-core. See Testing.
Usage
Use for
- Featured offers on home, merchant and category pages.
- Any grid where each offer needs its own card.
Not for
- Long lists of offers: use CouponList.
- Cashback offers, which work differently and get their own component.
CouponList
'use client'- 2 tests
A column of compact coupon rows: one list, or several the reader switches between with tabs, such as Top Picks and Popular.
import { CouponList } from './ui';<CouponList
label="Featured coupons"
tabs={[
{ id: 'picks', label: 'Top Picks', offers: picks },
{ id: 'popular', label: 'Popular', offers: popular },
]}
onSelect={setOffer}
/>API
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Names the list, or the set of tabs, for screen readers. |
offers | Offer[] | — | A single list. Use this or tabs, not both. |
tabs | CouponListTab[] | — | Two or more lists to switch between: { id, label, offers }. |
defaultTab | string | first tab | The tab shown first. |
onSelect | (offer: Offer) => void | — | Called when the reader opens an offer. |
Tokens
lineinkactionfont-sans
Accessibility
- WAI-ARIA tabs: one tab stop for the set; Left and Right move between tabs; Home and End jump to the ends.
- Each panel is labelled by its tab and keeps its list semantics, so screen readers announce how many offers it holds.
- The props are a union: TypeScript rejects passing both offers and tabs.
Tests
- renders a labelled list of offers
- switches tabs with the arrow keys, keeping one tab stop
Also scanned for accessibility problems with axe-core. See Testing.
Usage
Use for
- The column beside featured offers on the homepage.
- A merchant’s full list of coupons.
Not for
- Offers that need a photo or more than a line: use OfferCard.
- Moving between pages: tabs only switch lists in place.
OfferDialog
'use client'- 7 tests
The dialog every offer opens. A code offer shows the code with a Copy button; a deal says no code is needed. Either way the main action is the link to the retailer. Publisher-specific content, such as the related offer, comes in through props, so the dialog itself has no publisher logic.
import { OfferDialog } from './ui';<OfferDialog
offer={offer}
onClose={() => setOffer(null)}
storeHref={storeUrl(offer)}
usedToday={32}
related={{ heading: 'Top home offer', offer: adairs }}
onSelectRelated={setOffer}
/>API
| Prop | Type | Default | Description |
|---|---|---|---|
offer | Offer | null | — | The offer to show. Open while set; null closes it. |
onClose | () => void | — | Close button, Escape or a click on the backdrop. |
storeHref | string | — | The retailer link. Opens in a new tab with rel="sponsored". |
usedToday | number | — | Social proof above the offer. |
related | { heading, offer } | — | A cross-sell under the offer, chosen per publisher. |
onSelectRelated | (offer: Offer) => void | — | Opens the related offer, normally by swapping it in. |
newsletter | boolean | true | Shows NewsletterSignup at the bottom. |
note | ReactNode | — | Small print, such as terms. |
Tokens
surfaceinklineactionon-actionfont-editorialfont-sans
Accessibility
- Native <dialog> opened with showModal(): the browser traps focus, closes on Escape and returns focus to the offer that opened it.
- Named by the offer title and described by the retailer and category.
- Copy announces the result in a status region. If the clipboard is blocked, the code is selected so it can be copied by keyboard.
- The retailer link says it opens in a new tab. Feedback buttons are toggles (aria-pressed) in a labelled group.
Tests
- opens as a modal named by the offer
- copies the code and says so
- selects the code when the clipboard is blocked
- links to the retailer as a sponsored link in a new tab
- records feedback as a toggle
- swaps in the related offer, which is a deal with no code
- closes from the close button
Also scanned for accessibility problems with axe-core. See Testing.
Usage
Use for
- Revealing a code or confirming a deal before the reader goes to the retailer.
Not for
- Anything that isn’t an offer.
- Hard-coding a publisher’s related offer inside the component: pass it as related.
RetailerTile
A large retailer logo with its coupon count, linking to the retailer’s coupon page.
import { RetailerTile } from './ui';<RetailerTile retailer={ulta} count={25} href="/stores/ulta/" />API
| Prop | Type | Default | Description |
|---|---|---|---|
retailer | Retailer | — | Name, logo artwork and brand colour. |
count | number | — | Live offers. Singular and plural are handled. |
href | string | — | The retailer’s coupon page. |
Tokens
lineinkactionfont-sans
Accessibility
- A link named by the logo and the count, e.g. “Ulta 25 coupons”.
Tests
- links to the retailer, named by logo and count
Also scanned for accessibility problems with axe-core. See Testing.
Usage
Use for
- Store strips on the homepage.
- Retailer directories.
Not for
- Attributing an offer to a retailer: use RetailerLogo.
RetailerLogo
A retailer’s logo on its own brand colour, in a square tile. The tile colour belongs to the retailer, so it is the same on every publisher.
import { RetailerLogo } from './ui';

<RetailerLogo retailer={dell} />
<RetailerLogo retailer={amazon} size="sm" decorative />API
| Prop | Type | Default | Description |
|---|---|---|---|
retailer | Retailer | — | Name, logo artwork and brand colour. |
size | 'sm' | 'md' | 'md' | 80px beside offer titles; 60px in compact rows. |
decorative | boolean | false | Hides the logo from screen readers when the name is visible next to it. |
Tokens
none: the tile colour is retailer artwork
Accessibility
- Alt text is the retailer’s name.
- Set decorative when the name is already visible, so it isn’t read twice.
Tests
- names the retailer, unless it is decorative
Also scanned for accessibility problems with axe-core. See Testing.
Usage
Use for
- Next to offer titles in cards, lists and dialogs.
Not for
- Publisher logos and mastheads.
- Linking to a retailer: use RetailerTile.
SectionHeading
The one editorial heading for offer sections: dark text over a fine rule, with optional supporting copy.
import { SectionHeading } from './ui';Top Offers, Deals, Coupons & Codes
Hand-picked by our editors and checked daily.
Latest Deals
<SectionHeading
title="Top Offers, Deals, Coupons & Codes"
description="Hand-picked by our editors and checked daily."
/>
<SectionHeading title="Latest Deals" level={3} href="/latest/" />API
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | The heading text. |
level | 2 | 3 | 4 | 2 | Match the page outline. |
description | string | — | Supporting copy under the heading. |
href | string | — | Makes the title a link. |
id | string | — | Anchor for in-page links. |
Tokens
lineinkactionfont-editorialfont-sans
Accessibility
- A real heading at the level you choose, so the page outline stays correct.
Tests
- renders the requested level, optionally as a link
Also scanned for accessibility problems with axe-core. See Testing.
Usage
Use for
- Every offer section on home, merchant and category pages.
Not for
- Page titles, which belong to the publisher’s header.
Not yet ported
These are still the original HTML reconstruction. Each one moves into the reference above as it’s rebuilt in React.
Search results
Featured savings
Original PC imagery with a retailer badge, sample offer and grey caption.
Need an upgrade? Take an extra $200 off any PC build over $1000.
photo-coupon-card · editorial-offer
Photo and compact coupon cards
Three-column photo grids and dashed compact rows reuse shared offer components.
Compact coupon rows
photo-coupon-card · photo-coupon-section · logo-offer-card
Directories
Shared grouped links for store and category discovery.
Category links
Popular categories
grouped-link-directory
Editorial & Footer
About global offers
Save on tools, tech and home projects
For power tools, compare the bare-tool price with the price of a kit that includes a battery and charger. Check whether your existing batteries fit before switching systems.
For computers and home electronics, compare the exact model and specification, not just the product name. Check warranty coverage, return windows and the condition of refurbished items before choosing an offer.
Publisher Footer
rich-text · footer-toms-hardware