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 NME. 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.

Terminal
npm run build:tokens   # tokens/*.tokens.json → CSS variables + Tailwind theme
npm test               # behaviour tests and an automated accessibility scan per component
Page.tsx
import { 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="nme">
      {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.

  1. 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-highlight and the uc:font-display, uc:font-sans and uc:font-editorial families. Tailwind’s default palette and fonts are removed, so uc:bg-red-500 builds nothing.
  2. 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.
  3. Treat retailer colours as artwork. A retailer’s logo background comes from Retailer.background and stays the same on every publisher. It is never a theme value.
  4. 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.
  5. 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).
  6. 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.
  7. 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).
  8. Every component ships with tests. Behaviour and accessible names are tested with Testing Library, and each test runs an axe check (npm test).
  9. 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 NME sets them. Shared components use only these. Change a value in the token file, run the build, and every component follows.

RoleCSS variableTailwindValue
actionButtons, links and the 'Get code' step. The one colour a reader should act on.--uc-actionuc:{bg,text,border}-action#151515
on-actionText and icons on an action-coloured fill, such as a solid button label.--uc-on-actionuc:{bg,text,border}-on-action#ffffff
highlightRules under headings, category icons and hover states. Decoration that points, never a call to action.--uc-highlightuc:{bg,text,border}-highlight#151515
inkBody text and offer descriptions.--uc-inkuc:{bg,text,border}-ink#151515
lineDividers between offers and card borders.--uc-lineuc:{bg,text,border}-line#ebebeb
surfaceBackground of cards, lists and dialogs.--uc-surfaceuc:{bg,text,border}-surface#ffffff
errorForm validation errors and failed actions. A state colour, the same on every publisher.--uc-erroruc:{bg,text,border}-error#cc0000
font-displayPage and section headlines, set in the publisher's headline face.--uc-font-displayuc:font-displayHelvetica Neue
font-sansInterface text: offer titles, buttons, tabs, labels.--uc-font-sansuc:font-sansHelvetica Neue
font-editorialLonger editorial copy, such as merchant introductions.--uc-font-editorialuc:font-editorialHelvetica Neue

Generated CSS

tokens/tokens.generated.css
[data-uc-publisher="nme"] {
  --uc-action: #151515;
  --uc-on-action: #ffffff;
  --uc-highlight: #151515;
  --uc-ink: #151515;
  --uc-line: #ebebeb;
  --uc-surface: #ffffff;
  --uc-error: #cc0000;
  --uc-font-display: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
  --uc-font-sans: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
  --uc-font-editorial: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
}
Source: tokens/nme.tokens.json
tokens/nme.tokens.json
{
  "$description": "NME.",
  "color": {
    "action": {
      "$value": "#151515"
    },
    "on-action": {
      "$value": "#ffffff"
    },
    "highlight": {
      "$value": "#151515"
    },
    "ink": {
      "$value": "#151515"
    },
    "line": {
      "$value": "#ebebeb"
    },
    "surface": {
      "$value": "#ffffff"
    },
    "error": {
      "$value": "#cc0000"
    }
  },
  "font": {
    "display": {
      "$value": [
        "Helvetica Neue",
        "Helvetica",
        "Arial",
        "sans-serif"
      ]
    },
    "sans": {
      "$value": [
        "Helvetica Neue",
        "Helvetica",
        "Arial",
        "sans-serif"
      ]
    },
    "editorial": {
      "$value": [
        "Helvetica Neue",
        "Helvetica",
        "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.

ui/OfferCard.tsx
import { OfferCard } from './ui';
variant="photo"
variant="logo"
variant="text" moreHref

API

PropTypeDefaultDescription
offerOffer—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.
moreHrefstring—Adds a “More {retailer} coupons” link under the card.

Tokens

  • line
  • surface
  • ink
  • action
  • font-sans
  • font-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

A column of compact coupon rows: one list, or several the reader switches between with tabs, such as Top Picks and Popular.

ui/CouponList.tsx
import { CouponList } from './ui';

API

PropTypeDefaultDescription
labelstring—Names the list, or the set of tabs, for screen readers.
offersOffer[]—A single list. Use this or tabs, not both.
tabsCouponListTab[]—Two or more lists to switch between: { id, label, offers }.
defaultTabstringfirst tabThe tab shown first.
onSelect(offer: Offer) => void—Called when the reader opens an offer.

Tokens

  • line
  • ink
  • action
  • font-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

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.

ui/OfferDialog.tsx
import { OfferDialog } from './ui';

API

PropTypeDefaultDescription
offerOffer | null—The offer to show. Open while set; null closes it.
onClose() => void—Close button, Escape or a click on the backdrop.
storeHrefstring—The retailer link. Opens in a new tab with rel="sponsored".
usedTodaynumber—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.
newsletterbooleantrueShows NewsletterSignup at the bottom.
noteReactNode—Small print, such as terms.

Tokens

  • surface
  • ink
  • line
  • action
  • on-action
  • font-editorial
  • font-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.

NewsletterSignup

Email sign-up with inline validation. Used at the bottom of OfferDialog and anywhere a page asks for an email.

ui/NewsletterSignup.tsx
import { NewsletterSignup } from './ui';

Sign up to our newsletter for more of the best offers and discounts from Dell

Sample form. Your email is never sent or stored.

API

PropTypeDefaultDescription
retailerNamestring—Completes the heading: “…from {retailerName}”.
onSubscribe(email: string) => void | Promise<void>—Called with a valid address. Resolve to confirm; throw to show an error.
legalReactNode—Terms or privacy links under the form.
headingLevel2 | 3 | 43Match the page outline.

Tokens

  • line
  • surface
  • ink
  • action
  • on-action
  • error
  • font-editorial

Accessibility

  • The field has a real label (visually hidden). Errors are announced (role="alert"), tied to the field with aria-describedby, and focus returns to the field.
  • The confirmation replaces the form and is announced as a status.

Tests

  • explains a bad address, ties the message to the field and keeps focus there
  • confirms a valid sign-up as a status

Also scanned for accessibility problems with axe-core. See Testing.

Usage

Use for

  • Newsletter sign-up in the offer dialog, page footers and sidebars.

Not for

  • Forms with more than one field: compose them from inputs instead.

RetailerTile

A large retailer logo with its coupon count, linking to the retailer’s coupon page.

ui/RetailerTile.tsx
import { RetailerTile } from './ui';

API

PropTypeDefaultDescription
retailerRetailer—Name, logo artwork and brand colour.
countnumber—Live offers. Singular and plural are handled.
hrefstring—The retailer’s coupon page.

Tokens

  • line
  • ink
  • action
  • font-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.

SectionHeading

The one editorial heading for offer sections: dark text over a fine rule, with optional supporting copy.

ui/SectionHeading.tsx
import { SectionHeading } from './ui';

Top Offers, Deals, Coupons & Codes

Hand-picked by our editors and checked daily.

Latest Deals

API

PropTypeDefaultDescription
titlestring—The heading text.
level2 | 3 | 42Match the page outline.
descriptionstring—Supporting copy under the heading.
hrefstring—Makes the title a link.
idstring—Anchor for in-page links.

Tokens

  • line
  • ink
  • action
  • font-editorial
  • font-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.

Button

The shared action button. Solid for the one action that matters most in its area; outline for secondary actions on light or dark backgrounds.

ui/Button.tsx
import { Button } from './ui';

API

PropTypeDefaultDescription
variant'solid' | 'outline''solid'Solid fills with the action colour; outline takes the text colour it sits on.
type'button' | 'submit' | 'reset''button'Defaults to button so it never submits a form by accident.
...propsComponentProps<"button">—disabled, onClick, aria-* and the rest pass through.

Tokens

  • action
  • on-action
  • font-sans

Accessibility

  • A native button: Enter and Space work and disabled is announced.
  • A 2px focus outline in the action colour.

Tests

  • never submits a form unless asked to
  • passes native attributes through and stays accessible

Also scanned for accessibility problems with axe-core. See Testing.

Usage

Use for

  • Copy code, Get deal, All stores.
  • Any action that changes something on the page.

Not for

  • Going to another page: use a link.
  • Opening an offer: OfferCard and CouponList already do that.

Not yet ported

These are still the original HTML reconstruction. Each one moves into the reference above as it’s rebuilt in React.

Header & Search

Original NME wordmark, retailer navigation and working desktop/mobile search.

NME

header-nme · search · results

Homepage Hero

Get The Best UK Discount Codes & Deals

Explore sample coupons and promo codes for fashion, home, beauty and more from your favourite UK stores.

Photo Offers

Original photography and merchant badges. Desktop grids become swipeable offer rails on mobile.

Featured savings

news-offer-section · editorial-offer

Voucher Cards

Offer text and retailer links stay in normal flow. Logos retain their correct background colours.

voucher-summary

Directories

Shared category and merchant discovery links.

Category Directory

Popular categories

grouped-link-directory

Editorial & Footer

Helpful Savings Guidance

How it all works

Choose an offer that matches what you plan to buy, then check the minimum spend, exclusions and expiry date. Code offers need to be entered at checkout; deals without a code usually apply through the retailer’s offer page.

Compare the total cost with delivery included. Check whether student, membership or first-order discounts have extra conditions, and avoid adding something you do not need just to reach a threshold.

Publisher Footer
32 People Used Today

Copy this coupon code and paste at checkout

Historical 2024 sample. This prototype does not redeem offers.