Slide-Over Cart Drawer
A basket panel with the dialog mechanics usually missing: focus trap, focus return, Escape to close and a background scroll lock.
The wallet buttons above the form, and what they do to it: the address a wallet returns is shown and stays editable, and the row disappears entirely when no wallet is actually available.
components/checkout-express-payment.tsxnpx hoverlab add checkout-express-payment
Or over MCP, from your editor's agent — no account needed.
Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.
Start a page with this section — add more, order them, and leave with the page source.
Total £84.00
Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.
'use client'
/**
* <CheckoutExpressPayment> — the wallet row, and what it does to the form.
*
* Cart & Checkout had the drawer, the line items, the summary panel and
* the checkout form. The wallet buttons are the piece that sits above all
* of them and is nearly always got wrong, because the mistake is not
* visual — it is where in the flow they appear and what happens after one
* is used.
*
* THE ONE THING THIS GETS RIGHT THAT MOST DO NOT
*
* Paying with a wallet returns an address, and the form shows what it got.
* Most implementations either jump straight to a confirmation — so the
* buyer never sees which of their four saved addresses was used — or drop
* the returned data and ask again, which wastes the whole point. Here the
* fields fill in, visibly, and stay editable with a line saying where the
* values came from. Shipping to the wrong address is the most expensive
* recoverable error in commerce, and it is nearly always this.
*
* A BUTTON FOR A WALLET NOBODY HAS IS WORSE THAN NO BUTTON
*
* Availability is a runtime question — `ApplePaySession.canMakePayments()`,
* the Payment Request API's `canMakePayment()`, or whatever the processor
* exposes — and it must be asked before the row renders. An Apple Pay
* button on Android is a dead end that makes the whole checkout look
* broken. The demo below fakes the answer with a toggle so both states are
* visible; the comment where that toggle lives is where the real check
* goes, and the row disappears entirely when nothing is available rather
* than leaving a labelled empty box.
*
* ABOVE THE FORM, ALWAYS
*
* A wallet button under the card fields saves nobody anything: by then the
* typing is done. It is the first thing on the page or it is decoration.
*
* THE DIVIDER IS A REAL SEPARATOR
*
* `role="separator"` with a label, not an `<hr>` with text floated over
* it. The word "or" alone, read out between two groups of controls, is
* one of the more confusing things a checkout can say.
*
* ACCESSIBILITY: the wallet row is a labelled group; each button says what
* it will do ("Pay with Apple Pay, £84.00") rather than carrying a
* wordmark and nothing else; the fill-in is announced through a polite
* live region, because the form changing under you is otherwise silent.
*/
import * as React from 'react'
import { CreditCard, Info, ShieldCheck, Wallet } from 'lucide-react'
export interface ExpressWallet {
id: string
label: string
/** In production this is a runtime capability check, not a constant. */
available: boolean
}
export interface CheckoutExpressPaymentProps {
total?: string
wallets?: ExpressWallet[]
className?: string
}
const DEFAULT_WALLETS: ExpressWallet[] = [
{ id: 'apple', label: 'Apple Pay', available: true },
{ id: 'google', label: 'Google Pay', available: true },
{ id: 'paypal', label: 'PayPal', available: true },
]
const RETURNED_BY_WALLET = {
email: 'sam.keller@icloud.com',
name: 'Sam Keller',
line1: 'Flat 4, 18 Bickerton Road',
city: 'London',
postcode: 'N19 5JR',
}
export function CheckoutExpressPayment({
total = '£84.00',
wallets = DEFAULT_WALLETS,
className = '',
}: CheckoutExpressPaymentProps) {
/*
Per-instance prefix for every id this block emits.
The literals these replaced were a latent duplicate the moment the
block appeared twice on one document, and `aria-labelledby` on a
duplicated id resolves to the first match -- so the second copy was
labelled by the first copy's heading. Client component, so `useId` is
the right tool.
*/
const uid = React.useId()
/*
Stand-in for the real capability check. Replace with
`ApplePaySession.canMakePayments()`, `PaymentRequest.canMakePayment()`
or your processor's equivalent — and keep the "render nothing" branch.
*/
const [walletsSupported, setWalletsSupported] = React.useState(true)
const [filledBy, setFilledBy] = React.useState<string | null>(null)
const available = walletsSupported ? wallets.filter((w) => w.available) : []
const values = filledBy
? RETURNED_BY_WALLET
: { email: '', name: '', line1: '', city: '', postcode: '' }
return (
<section className={`mx-auto w-full max-w-md px-4 py-16 sm:px-6 ${className}`}>
<div className="rounded-2xl border border-border bg-card p-6">
<div className="flex items-baseline justify-between">
<h2 className="text-lg font-semibold text-foreground">Checkout</h2>
<p className="text-sm text-muted-foreground">
Total <span className="font-semibold tabular-nums text-foreground">{total}</span>
</p>
</div>
{/* The row is first, or it is decoration. */}
{available.length > 0 ? (
<>
<div
role="group"
aria-label="Express payment"
className="mt-5 grid gap-2 sm:grid-cols-3"
>
{available.map((wallet) => (
<button
key={wallet.id}
type="button"
onClick={() => setFilledBy(wallet.label)}
/* Says what it does and for how much, not just a wordmark. */
aria-label={`Pay with ${wallet.label}, ${total}`}
className="min-w-0 inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-border bg-background text-sm font-semibold text-foreground transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
>
<Wallet aria-hidden className="h-4 w-4 shrink-0" />
<span className="min-w-0 break-words">{wallet.label}</span>
</button>
))}
</div>
{/* A labelled separator, not an hr with a word floated over it. */}
<div
role="separator"
aria-label="Or pay by card instead"
className="my-5 flex items-center gap-3"
>
<span aria-hidden className="h-px flex-1 bg-border" />
<span aria-hidden className="text-xs text-muted-foreground">
or pay by card
</span>
<span aria-hidden className="h-px flex-1 bg-border" />
</div>
</>
) : (
/* Nothing available: no row, no empty labelled box. */
<p className="mt-4 text-xs text-muted-foreground">
No wallet is available in this browser, so the card form is the
whole checkout.
</p>
)}
{/* What the wallet handed back, shown rather than assumed. */}
<p aria-live="polite" className="min-h-5 text-xs text-muted-foreground">
{filledBy
? `${filledBy} filled these in. Check the address before you place the order — you can still change it.`
: ''}
</p>
{/*
The fields stay uncontrolled so they remain editable after the
wallet fills them; the `key` is React's documented way of
resetting an uncontrolled input when its default changes.
*/}
<form className="mt-3 space-y-4">
{[
{ id: 'ep-email', label: 'Email', value: values.email, type: 'email', autoComplete: 'email' },
{ id: 'ep-name', label: 'Full name', value: values.name, type: 'text', autoComplete: 'name' },
{ id: 'ep-line1', label: 'Address', value: values.line1, type: 'text', autoComplete: 'address-line1' },
].map((field) => (
<div key={field.id}>
<label htmlFor={field.id} className="block text-sm font-medium text-foreground">
{field.label}
</label>
<input
id={field.id}
type={field.type}
autoComplete={field.autoComplete}
defaultValue={field.value}
key={`${field.id}-${filledBy ?? 'empty'}`}
className="mt-1.5 h-10 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
/>
</div>
))}
<div className="grid grid-cols-2 gap-3">
<div className="min-w-0">
<label htmlFor={`${uid}-ep-city`} className="block truncate text-sm font-medium text-foreground">
City
</label>
<input
id={`${uid}-ep-city`}
type="text"
autoComplete="address-level2"
defaultValue={values.city}
key={`ep-city-${filledBy ?? 'empty'}`}
className="mt-1.5 h-10 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
/>
</div>
<div className="min-w-0">
<label htmlFor={`${uid}-ep-postcode`} className="block truncate text-sm font-medium text-foreground">
Postcode
</label>
<input
id={`${uid}-ep-postcode`}
type="text"
autoComplete="postal-code"
defaultValue={values.postcode}
key={`ep-postcode-${filledBy ?? 'empty'}`}
className="mt-1.5 h-10 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
/>
</div>
</div>
<button
type="button"
className="inline-flex h-11 w-full items-center justify-center gap-1.5 rounded-lg bg-primary px-4 text-sm font-semibold text-primary-foreground transition hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
>
<CreditCard aria-hidden className="h-4 w-4" />
Pay {total}
</button>
<p className="flex items-start gap-1.5 text-xs text-muted-foreground">
<ShieldCheck aria-hidden className="mt-0.5 h-3.5 w-3.5 shrink-0" />
Card details go straight to the payment provider. They never touch
this site.
</p>
</form>
{/* Demo control for the capability check described above. */}
<label className="mt-5 flex items-start gap-2 border-t border-border pt-4 text-xs text-muted-foreground">
<input
type="checkbox"
checked={!walletsSupported}
onChange={(event) => setWalletsSupported(!event.target.checked)}
className="mt-0.5 h-3.5 w-3.5 rounded border-field accent-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
/>
<span className="flex items-start gap-1.5">
<Info aria-hidden className="mt-0.5 h-3.5 w-3.5 shrink-0" />
Pretend no wallet is available — the state a real capability check
has to produce, and the one nobody designs.
</span>
</label>
</div>
</section>
)
}
bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.Drop it at components/checkout-express-payment.tsx and import it where you need the section:
import { CheckoutExpressPayment } from '@/components/checkout-express-payment'1 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.
Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.
| Prop | Type | Default |
|---|---|---|
total | string | '£84.00' |
wallets | ExpressWallet[] | DEFAULT_WALLETS |
className | string | '' |
The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.
This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.
<!--
Express Payment Row — markup from the Hoverlab catalog.
This is the block rendered once to HTML and wrapped as a component
file. It is not a port of the React source: the Tailwind classes carry
the design, which is the part that took the work, and they are the same
in every framework.
This block is interactive in React and the handlers are NOT here.
Buttons, toggles and menus render in their initial state and do
nothing until you wire them up.
-->
<section class="mx-auto w-full max-w-md px-4 py-16 sm:px-6 ">
<div class="rounded-2xl border border-border bg-card p-6">
<div class="flex items-baseline justify-between">
<h2 class="text-lg font-semibold text-foreground">Checkout</h2>
<p class="text-sm text-muted-foreground">Total <span class="font-semibold tabular-nums text-foreground">£84.00</span></p>
</div>
<div role="group" aria-label="Express payment" class="mt-5 grid gap-2 sm:grid-cols-3">
<button type="button" aria-label="Pay with Apple Pay, £84.00" class="min-w-0 inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-border bg-background text-sm font-semibold text-foreground transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-wallet h-4 w-4 shrink-0" aria-hidden="true">
<path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"></path>
<path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"></path>
</svg>
<span class="min-w-0 break-words">Apple Pay</span>
</button>
<button type="button" aria-label="Pay with Google Pay, £84.00" class="min-w-0 inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-border bg-background text-sm font-semibold text-foreground transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-wallet h-4 w-4 shrink-0" aria-hidden="true">
<path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"></path>
<path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"></path>
</svg>
<span class="min-w-0 break-words">Google Pay</span>
</button>
<button type="button" aria-label="Pay with PayPal, £84.00" class="min-w-0 inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-border bg-background text-sm font-semibold text-foreground transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-wallet h-4 w-4 shrink-0" aria-hidden="true">
<path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"></path>
<path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"></path>
</svg>
<span class="min-w-0 break-words">PayPal</span>
</button>
</div>
<div role="separator" aria-label="Or pay by card instead" class="my-5 flex items-center gap-3">
<span aria-hidden="true" class="h-px flex-1 bg-border"></span>
<span aria-hidden="true" class="text-xs text-muted-foreground">or pay by card</span>
<span aria-hidden="true" class="h-px flex-1 bg-border"></span>
</div>
<p aria-live="polite" class="min-h-5 text-xs text-muted-foreground"></p>
<form class="mt-3 space-y-4">
<div>
<label for="ep-email" class="block text-sm font-medium text-foreground">Email</label>
<input id="ep-email" type="email" autoComplete="email" class="mt-1.5 h-10 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background" value="" />
</div>
<div>
<label for="ep-name" class="block text-sm font-medium text-foreground">Full name</label>
<input id="ep-name" type="text" autoComplete="name" class="mt-1.5 h-10 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background" value="" />
</div>
<div>
<label for="ep-line1" class="block text-sm font-medium text-foreground">Address</label>
<input id="ep-line1" type="text" autoComplete="address-line1" class="mt-1.5 h-10 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background" value="" />
</div>
<div class="grid grid-cols-2 gap-3">
<div class="min-w-0">
<label for="_R_0_-ep-city" class="block truncate text-sm font-medium text-foreground">City</label>
<input id="_R_0_-ep-city" type="text" autoComplete="address-level2" class="mt-1.5 h-10 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background" value="" />
</div>
<div class="min-w-0">
<label for="_R_0_-ep-postcode" class="block truncate text-sm font-medium text-foreground">Postcode</label>
<input id="_R_0_-ep-postcode" type="text" autoComplete="postal-code" class="mt-1.5 h-10 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background" value="" />
</div>
</div>
<button type="button" class="inline-flex h-11 w-full items-center justify-center gap-1.5 rounded-lg bg-primary px-4 text-sm font-semibold text-primary-foreground transition hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-credit-card h-4 w-4" aria-hidden="true"><rect width="20" height="14" x="2" y="5" rx="2"></rect><line x1="2" x2="22" y1="10" y2="10"></line></svg>Pay £84.00</button>
<p class="flex items-start gap-1.5 text-xs text-muted-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-shield-check mt-0.5 h-3.5 w-3.5 shrink-0" aria-hidden="true"><path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"></path><path d="m9 12 2 2 4-4"></path></svg>Card details go straight to the payment provider. They never touch this site.</p>
</form>
<label class="mt-5 flex items-start gap-2 border-t border-border pt-4 text-xs text-muted-foreground">
<input type="checkbox" class="mt-0.5 h-3.5 w-3.5 rounded border-field accent-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background" />
<span class="flex items-start gap-1.5"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info mt-0.5 h-3.5 w-3.5 shrink-0" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><path d="M12 16v-4"></path><path d="M12 8h.01"></path></svg>Pretend no wallet is available — the state a real capability check has to produce, and the one nobody designs.</span>
</label>
</div>
</section>
What each framework gets across the whole catalog — effects convert properly; this rung is markup.
The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.
Want the whole screen instead of this one section? Open a page and copy it entire.
All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.
Browse Cart & CheckoutCopying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.
A basket panel with the dialog mechanics usually missing: focus trap, focus return, Escape to close and a background scroll lock.
Quantity steppers and remove-with-undo, with every total derived rather than stored so the basket can never disagree with itself.
The full autocomplete token set that lets a browser fill eight fields in one tap, plus address labels that follow the selected country.
Subtotal, discount, delivery and tax all derived from the lines, with the free-delivery nudge driven by the same threshold as the charge.
The gifting step, placed in the cart where it is a choice rather than at checkout where it is friction.
The only checkout where the buyer is not the recipient - live preview, a send date with a stated timezone, and the confirm-the-address field that prevents the expensive typo.
Guest as the default and the whole form, with a real autocomplete token on every field and the account offer moved to the end, where it costs one checkbox.
The offer popup with four rules applied: triggered by intent, a decline button of equal weight, a dismissal that is remembered, and the terms on its face.