How placements work
By default, Swish places buttons through the app embed. Use the placement API for custom positioning:swish-ignore attribute to any target element that should be skipped:
Passing placements at initialization
You can also pass placements under theplacements option in SwishOptions:
Mount options
Themount 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 underdesign 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 aresm at 500px and lg at 700px.
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 setui.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
- Placements reference for the complete API
- Intents to configure save behavior
- Design for global design tokens