← All writing

2 min readDesign systemsCSSArchitecture

Theme settings, not partner flags

When one client needs your page to look different, the quick fix is an if-statement with their name in it. What I learned restyling a checkout for a wallet partner through configuration instead.

When a big partner asks for your product to look like theirs, the first change is always tempting: an if with their name in it.

const logoHeight = isPartner ? 24 : 16;

It works, it ships the same day, and it’s correct. The trouble starts with the second partner, and the fifth. Each one adds another branch, until a page that should render one way per theme renders one way per customer, and nobody can change anything without checking every name in the code.

Here’s what I learned restyling our checkout for a wallet partner, and the rules I’d follow from the start next time.

1. Every special case is a setting waiting to happen

We did write that flag first: a shorter logo for this one partner. Then it became what it should have been, a setting:

// Any merchant can set it; the default keeps everyone else as before.
const logoHeight = theme.logoHeight ?? 16;

The test I use now: if another client asked for this tomorrow, would I have to touch this line again? If yes, it’s a setting.

2. Put defaults in one place

The new page-background setting first had its fallback written where it was used, a different grey in a couple of spots. Moving the default into the base theme fixed two problems at once. Merchants without the setting look exactly as before, and there’s exactly one place to change what “default” means.

const BASE_THEME = { windowBackground: 'var(--gray-2)', radius: 8, logoHeight: 16 };
const theme = { ...BASE_THEME, ...merchantTheme };

3. Map settings to CSS variables

The page doesn’t need to know why a corner is round, only how round. Turning each setting into a CSS variable at the top of the page means components read var(--radius) and never look at the theme object at all:

.pay-button { border-radius: var(--radius); background: var(--primary); }

That’s also what makes the live demo on the case study possible: change one value, and everything that uses it follows.

4. One path for every theme

Our second pass took the partner’s colours, background and rounded buttons and fed them through the same theme resolution every merchant uses. Before that, the partner’s look was partly a side path, which meant a theming fix might quietly skip them. Afterwards, there was no partner-specific rendering code left.

5. Shared pieces belong in the shared library

The theme helpers and a new text style went into our shared component library, not into one app. The next co-branded checkout starts with them already there.

Where flags still make sense

Not everything is a theme. A partner may genuinely need a different flow: an extra step, a different payment method order, a legal notice. Those are behaviour, not appearance, and a clearly named feature flag is fine for them. The rule I follow: appearance is configuration; behaviour can be a flag; a customer’s name is neither.

↑↓ move↵ openesc close