Add a save button
Use HTML attributes or JavaScript to add a save/unsave toggle to any page.- Custom element
- Placement
- React
Wrap your save button in When the rendered DOM doesn’t carry the product reference, pass
<swish-save> and tell it where to read the product from. context="pdp" resolves from the current URL and watches SPA navigation; context="product-card" walks to the nearest product link in the surrounding card and watches its href. Mark conditional children with data-swish-when - the SDK toggles their visibility based on the parent’s state attribute.product and variant attributes explicitly. See the elements reference for the full attribute set.Configuration options
Control how the save and unsave flows behave by passing intent options to the SDK configuration.Save behavior
Set these underintents.saveProduct in your SDK options:
Unsave behavior
Set these underintents.unsaveProduct:
For the full list of intent options, see the SDK configuration
reference.