How to Design a Website Sticky Add to Cart Bar: Mobile Patterns, Placement, and CSS Examples

by | Nov 20, 2026 | Uncategorized | 0 comments

A sticky add to cart bar is a persistent element that stays pinned to the screen (usually the bottom on mobile) while a shopper scrolls through a product page. It keeps the price, the variant choice and the primary action within reach at every scroll depth, which matters a lot on long product pages full of images, specs, reviews and upsells.

Most of the advice you will find online points to a paid app. This guide takes the opposite approach: it explains the design and engineering decisions behind a good sticky bar so you can build one yourself on any platform (custom build, WooCommerce, Shopify, headless) without a monthly subscription and without hurting Core Web Vitals.

Quick answer: what a good sticky add to cart bar does

  • Appears only after the main product form scrolls out of view, not on page load.
  • Sits at the bottom on mobile (thumb zone) and either bottom or top on desktop.
  • Is 64 to 76 px tall plus the device safe area, with a tap target of at least 48 px.
  • Never covers the real add to cart button, the footer or legal content.
  • Causes zero layout shift because it is taken out of the document flow and animated with transform.
  • Reflects the selected variant (price, availability, image) and stays in sync with the main form.
  • Is announced correctly to screen readers and removed from the accessibility tree while hidden.
mobile phone shopping cart button

When should the bar appear on scroll?

Showing the bar immediately is the most common mistake. If the real add to cart button is already visible, the sticky version is pure noise: it duplicates the action, eats vertical space and makes the page feel like an ad.

The three trigger strategies

Trigger How it works Best for
Element based (recommended) An IntersectionObserver watches the main product form. Bar shows when the form leaves the viewport. Almost every store. Accurate on all screen sizes.
Scroll distance Shows after X pixels or X percent of page height. Quick fixes on templates where the form has no stable selector.
Always visible Fixed from page load. Single product landing pages with no in-page buy box.

Hide it again at the right moments

  1. When the original add to cart form scrolls back into view.
  2. When the footer enters the viewport (legal links and contact details must stay tappable).
  3. When a modal, cart drawer or size guide is open.
  4. When the on-screen keyboard is open on a form field such as a gift message or quantity input.

IntersectionObserver example

const form = document.querySelector('#product-form');
const footer = document.querySelector('#site-footer');
const bar  = document.querySelector('.sticky-atc');

let formVisible = true;
let footerVisible = false;

function render() {
  const show = !formVisible && !footerVisible;
  bar.classList.toggle('is-visible', show);
  bar.toggleAttribute('inert', !show);
  bar.setAttribute('aria-hidden', show ? 'false' : 'true');
}

new IntersectionObserver(function (entries) {
  formVisible = entries[0].isIntersecting;
  render();
}, { threshold: 0, rootMargin: '0px 0px -10% 0px' }).observe(form);

new IntersectionObserver(function (entries) {
  footerVisible = entries[0].isIntersecting;
  render();
}, { threshold: 0 }).observe(footer);

IntersectionObserver runs off the main thread, so it is far cheaper than a scroll listener and it will not cause jank on mid range Android devices.

mobile phone shopping cart button

Placement: bottom, top or inline sticky?

Placement Pros Cons
Bottom (mobile) Natural thumb zone, matches native app patterns, no conflict with the sticky header. Competes with chat widgets, cookie banners and browser UI.
Top (desktop) Can merge with the sticky header, keeps the product name visible. Stacked bars reduce the usable viewport and look heavy.
Sticky buy box column Elegant on wide screens, uses position: sticky only. Needs a two column layout, useless below 1024 px.

Our default recommendation: bottom fixed bar under 1024 px, sticky buy box column above 1024 px, and a slim top bar on desktop only when the page is very long.

Sizing for thumb reach on mobile

The bottom third of a phone screen is where the thumb moves most comfortably, which is exactly why native apps put their primary action there. Size the bar so the action is obvious without stealing half the screen.

Element Recommended value
Bar height (content) 64 to 76 px, plus env(safe-area-inset-bottom)
Primary button height 48 px minimum (44 px absolute floor)
Primary button width At least 55 to 60 percent of the bar width
Gap between tap targets 8 px minimum
Button label size 16 px, 600 weight
Max elements in the bar 3 (thumbnail or price, variant chip, primary button)
Contrast ratio 4.5:1 for text, 3:1 for the button border or background

Resist the temptation to add wishlist, share, compare and quantity steppers. A sticky add to cart bar with four competing targets converts worse than one with a single dominant button.

mobile phone shopping cart button

CSS positioning techniques

1. The bottom fixed bar

.sticky-atc {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -6px 18px rgba(0, 0, 0, .08);
  transform: translateY(110%);
  transition: transform .22s ease;
  content-visibility: auto;
}

.sticky-atc.is-visible { transform: translateY(0); }

.sticky-atc__cta {
  flex: 1 1 auto;
  min-height: 48px;
  font-size: 16px;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .sticky-atc { transition: none; }
}

@media (min-width: 1024px) {
  .sticky-atc { display: none; }
  .product-buybox { position: sticky; top: 96px; }
}

Three details that are easy to miss:

  • env(safe-area-inset-bottom) keeps the button above the home indicator on iPhones and gesture bars on Android.
  • Animate transform, never height, top or bottom. Transform runs on the compositor and cannot shift the layout.
  • Use dvh units elsewhere on the page if you rely on viewport height, because mobile browser chrome resizes the viewport while scrolling.

2. Do not cover key content

A fixed bar floats over the document, so the last block of content can become unreachable. Two fixes:

/* Reserve space at the end of the page */
.page-product { padding-bottom: 96px; }

@media (min-width: 1024px) {
  .page-product { padding-bottom: 0; }
}

/* Keep anchor targets clear of the bar */
:root { scroll-padding-bottom: 96px; }

Also check the stacking order with every other floating element. A simple z-index contract avoids ugly surprises:

Layer z-index
Sticky header 50
Sticky add to cart bar 60
Chat widget 70 (offset upward by 80 px on mobile)
Cart drawer and modals 90
Cookie or consent banner 100 (bar stays hidden until consent is given)

3. Avoiding layout shift (CLS)

Fixed elements do not contribute to Cumulative Layout Shift by themselves, but the way they are implemented often does. Follow these rules:

  • Render the bar in the HTML with transform: translateY(110%) rather than injecting it with JavaScript after load.
  • Set explicit width and height on the product thumbnail inside the bar, and load it with loading="lazy" and decoding="async".
  • Reserve the price width with min-width or tabular numbers so a variant change does not reflow the row.
  • Never push the page down. A top bar that uses position: sticky inside normal flow will shift content when it appears. Use fixed plus a padding compensation instead.
  • Do not change the body padding on scroll. Apply it once in CSS at the matching breakpoint.

Handling variant selectors

The bar is only useful if it respects the shopper’s current choice. Two valid patterns:

Pattern A: mirror only

The bar shows the selected variant as a read only chip (“Blue / 42”) and the button submits the main form. Tapping the chip scrolls back to the selector. This is the simplest and least error prone pattern.

Pattern B: compact selector in the bar

The bar contains a condensed select or a bottom sheet that opens on tap. Better for stores where 80 percent of sessions are mobile, but you must keep both selectors in sync in both directions.

const mainForm = document.querySelector('#product-form');
const barPrice = document.querySelector('[data-bar-price]');
const barCta   = document.querySelector('[data-bar-cta]');

mainForm.addEventListener('change', function () {
  const variant = getSelectedVariant(mainForm); // your own lookup

  barPrice.textContent = variant.priceFormatted;
  barCta.disabled = !variant.available;
  barCta.textContent = variant.available ? 'Add to cart' : 'Sold out';
  barCta.setAttribute(
    'aria-label',
    (variant.available ? 'Add ' : 'Sold out: ') + variant.title + ' to cart'
  );
});

// Submit the real form so server side validation stays intact
barCta.addEventListener('click', function () {
  mainForm.requestSubmit();
});

Edge cases to handle:

  1. No variant selected yet. Label the button “Choose size” and scroll to the selector instead of submitting.
  2. Sold out variant. Disable the button, keep it visible, and expose a “Notify me” fallback.
  3. Required personalisation fields (engraving, upload). Always scroll back to the form rather than submitting a partial payload.
  4. Bundles and quantity breaks. Show the computed unit price in the bar so the number never contradicts the buy box.
  5. After a successful add. Swap to a short confirmation state, then offer “View cart” or “Checkout” for about three seconds.
mobile phone shopping cart button

Accessibility notes for screen readers

A sticky add to cart bar duplicates an existing control, which is exactly the kind of thing that confuses assistive technology if you are careless.

  • Remove it from the accessibility tree while hidden. Use inert plus aria-hidden="true", not just opacity: 0, otherwise keyboard users will tab into an invisible button.
  • Give the duplicate button a unique accessible name, for example aria-label="Add Trail Runner, Blue, size 42 to cart", so a screen reader user understands it is the same action in context.
  • Announce the result, not the appearance. Never announce “bar appeared”. Use a polite live region for “Added to cart, 1 item”: <p role="status" aria-live="polite" class="visually-hidden"></p>.
  • Label the container with role="region" and aria-label="Quick add to cart" so it can be found in the landmarks list.
  • Keep a visible focus ring with at least 3:1 contrast against the bar background.
  • Honour prefers-reduced-motion by removing the slide animation.
  • Test at 200 percent zoom and at 320 px width. The button label must not truncate mid word.
  • Do not trap focus. The bar is not a dialog. If it contains a variant sheet, that sheet is a dialog and needs proper focus management and Escape handling.

Platform notes

WooCommerce

Hook a template part after woocommerce_after_single_product, read the price from .woocommerce-variation-price, and listen to the found_variation and reset_data jQuery events to keep the bar in sync. Submit the existing form.variations_form so add to cart validation and third party plugins still run.

Shopify

Add a section or snippet inside main-product.liquid and reuse the existing product form id with the form attribute on the button. Listen to your theme’s variant change event (Dawn based themes dispatch one on the variant picker) instead of polling the DOM. An app is convenient, but a 15 line snippet avoids an extra script request on every product page.

Custom and headless builds

Render the bar server side with the default variant already applied, then hydrate. This keeps the markup in the initial HTML, which is better for Largest Contentful Paint and for crawlers.

mobile phone shopping cart button

Pre launch QA checklist

  1. Bar is hidden on page load and on short product pages where the form stays visible.
  2. Bar hides when the footer or the original form is on screen.
  3. Safe area padding verified on iPhone with the gesture bar and on Android with gesture navigation.
  4. No overlap with the chat widget, back to top button or consent banner.
  5. Price, availability and image match the selected variant in every combination.
  6. CLS stays at 0 on the product template in a Lighthouse mobile run.
  7. Keyboard tab order is logical and the hidden bar is not focusable.
  8. Screen reader announces the add to cart confirmation once, not twice.
  9. Bar does not appear while the on-screen keyboard is open.
  10. Event tracking distinguishes sticky bar adds from in-page adds, so you can measure the real impact.

How to measure the impact

Do not assume a lift. Tag the sticky bar clicks with a separate event parameter and compare, over at least two full weeks and separated by device:

  • Product page to add to cart rate
  • Add to cart to checkout rate (a bar that produces many wrong variant adds will show up here)
  • Scroll depth on product pages, to confirm you are not pushing people to buy before reading key specs
  • Return rate on size sensitive categories

FAQ

What is a sticky bar on a website?

It is any element that remains fixed in the viewport while the rest of the page scrolls. On product pages, the most common version is the sticky add to cart bar, which keeps the price and the buy button permanently accessible.

Does a sticky add to cart bar hurt Core Web Vitals?

Not if it is in the initial HTML and animated with transform. Problems appear when the bar is injected by a third party script after load, when its image has no dimensions, or when it pushes content down, all of which can create layout shift and extra main thread work.

Should the bar be at the top or the bottom?

Bottom on mobile, because that is the thumb zone and it matches native app behaviour. On desktop, a sticky buy box column is usually better than a full width bar, and if you do use a bar, keep it slim and merged with the header.

Do I need an app or plugin to add one?

No. A sticky add to cart bar is roughly 40 lines of HTML, CSS and JavaScript. Apps are useful if you need A/B testing, analytics and no-code editing, but a native implementation is faster, cheaper and easier to make accessible.

Does it actually increase conversions?

It usually helps on long mobile product pages with rich content below the buy box. Gains are small or negative on short pages where the real button is almost always visible, so treat it as a test, not a certainty.

Should it show on every page?

No. Limit it to product pages. On collection, blog or checkout pages it has no purpose and simply reduces the usable viewport.

Need help implementing it?

At FatCow Web Design we build ecommerce front ends that are fast, accessible and measurable. If you want a sticky add to cart bar implemented natively in your theme, with proper variant handling and zero layout shift, get in touch and we will audit your product template first.

Search Keywords

Recent Posts

Subscribe Now!