Custom Components
Replace a Sledge widget's markup with your own Liquid template, so Sledge renders your theme's product card instead of its own.
When CSS is not enough — when your theme's product card is structurally different from Sledge's, not just styled differently — you can replace the markup entirely.
A Custom Component is a Liquid template you provide. Sledge renders it instead of its own markup, into the light DOM, so your theme's stylesheet applies to it normally.
Defining one
Add a script tag with the type text/x-liquid and a slot naming the part you are replacing:
<script type="text/x-liquid" slot="product-card">
<div class="card card--product">
<a href="{{ product.url }}" class="card__link">
<img src="{{ product.image }}" alt="{{ product.title }}" loading="lazy">
<h3 class="card__title">{{ product.title }}</h3>
<span class="card__price">{{ product.price }}</span>
</a>
</div>
</script>Because this renders into the light DOM, the classes above are styled by your theme's own CSS with no extra work. That is the whole point — you stop reimplementing your card in Sledge's stylesheet and start reusing the one you already have.
Where to put it
Add the script tag to the template where the widget appears, or to your theme layout if you want it everywhere. It needs to exist in the page before the widget renders.
Why prefer this over CSS
Replacing markup is more durable than overriding it:
| Custom CSS against internal markup | Custom Component | |
|---|---|---|
| Depends on Sledge's internal class names | Yes | No |
| Survives a Sledge release changing markup | Not guaranteed | Yes |
| Reuses your theme's existing styles | No | Yes |
| Effort for a structurally different card | High, and grows | One template |
If you find yourself writing a long stylesheet to reshape a card, a Custom Component is almost certainly less work and will age better.
Keeping behavior
You are replacing presentation, not behavior. Sledge still handles data, wishlist state, add-to-cart, analytics and re-rendering — it just renders through your template.
Your template runs on every render, including re-renders, so it does not need to guard against being called more than once.
When you still need CSS
Custom Components replace a widget's markup, not the widget element itself. Layout of the element in your page — width, alignment, margins — is still document-level styling. See Styling.
Last updated on
Styling
How Sledge styling is layered — base styles, a bridge that inherits your theme's colors and fonts, then your own CSS on top — and how to change each layer.
Events
Sledge dispatches storefront events you can listen to from custom JavaScript — product card renders, cart updates, wishlist changes, search interactions and more.