Skip to main content
Placements let you control where Swish UI elements appear on your store. Each placement targets elements using a CSS selector and defines how a Swish component is mounted relative to the matched elements. There are three default locations where Swish places buttons. You can customize each one or add new placements entirely.

How placements work

By default, Swish places buttons through the app embed. Use the placement API for custom positioning:
Swish watches the DOM using a mutation observer, so buttons are automatically mounted on elements that are added dynamically (e.g. infinite scroll, quick view modals). Add the swish-ignore attribute to any target element that should be skipped:

Passing placements at initialization

You can also pass placements under the placements option in SwishOptions:

Mount options

The mount object controls where the button is inserted relative to the target. The at option lets you insert the button relative to a parent or child of the target element:

Layout types

The layout determines how the button is positioned. Choose between overlay, anchored, and inline.

Overlay

Position the button as an absolute overlay anchored to a corner of the target’s parent. This is the typical layout for save buttons on collection cards.

Inline

Place the button in a flex row alongside the target element. This is the typical layout for save buttons on product detail pages.

Anchored

Position the button relative to any element in the DOM, even if it is a sibling or cousin of the mount target. Use this when the element you want to overlay is not a direct parent of where the button is inserted.

Styling

Pass design tokens under design to style a button per placement. All values support responsive breakpoints.

Save button tokens

Home button tokens

Responsive values

Every design token accepts a responsive object with named breakpoints. The default breakpoints are sm at 500px and lg at 700px.
You can define custom breakpoints on the placement:

Save button attributes

When creating save buttons, you can set these HTML attributes:
When using placements, the product-id and variant-id attributes are automatically resolved from the target element’s data attributes (data-product-id, data-variant-id, data-product-handle) or from the page URL.

Save button animation

Save buttons can play an animation when a customer taps one to save an item: Pulse, Jello or Particles, a burst of small copies of the icon. Pick it under Global → Save button → Save animation, or set ui.saveButton.animation. Every save button plays the same one, placed buttons and the hearts in the drawer alike. It plays once the save goes through, never for an item that was already saved, and not for customers who turn on reduced motion.

Home button attributes

Programmatic creation

Create buttons outside of the placement system:

Further reading