Overview
Horizon includes two main button snippets for different use cases:- button.liquid - Styled link buttons for navigation
- add-to-cart-button.liquid - Product add to cart functionality
Button (Link)
File Location:snippets/button.liquid
Renders a styled link element that looks like a button. Used for navigation and CTAs throughout the theme.
Parameters
string
required
URL to link to. If blank, renders a disabled link with
aria-disabled="true".object
required
Block object containing settings for label, style, and behavior.Required Settings:
label- Button textstyle_class- Button style classopen_in_new_tab- Whether to open in new tab
Usage
Basic Example
Complete Block Example
blocks/button.liquid
Button Styles
The snippet supports three button styles viablock.settings.style_class:
Open in New Tab
Whenblock.settings.open_in_new_tab is enabled:
button.liquid
The
rel="noopener noreferrer" attribute is included for security when opening links in new tabs.Disabled State
When link is blank, the button renders in a disabled state:button.liquid
Styling
The snippet includes scoped styles for link buttons:button.liquid (stylesheet)
Add to Cart Button
File Location:snippets/add-to-cart-button.liquid
Renders an “Add to Cart” button with dynamic states, animations, and visual feedback.
Parameters
boolean
required
Whether the product can be added to the cart. When
false, button is disabled.string
Custom button text. Falls back to translation
'actions.add_to_cart'.object
required
The product object to be added to the cart.
boolean
If
true, only shows the cart icon on mobile devices (hides text).Default: falsestring
Additional CSS classes to apply to the button.
string
The ID attribute for the button element.
string
Testing identifier for automated tests.
Usage
Basic Example
Complete Product Form Example
blocks/add-to-cart.liquid
With Custom Text
Icon Only on Mobile
Button States
The button supports multiple visual states:Available (Default)
Available (Default)
Disabled (Out of Stock)
Disabled (Out of Stock)
Added (Success State)
Added (Success State)
Shows checkmark burst animation after successful add to cart:Triggered by JavaScript on successful cart addition.
Add to Cart Animations
The button supports different animation styles viasettings.add_to_cart_animation:
add-to-cart-button.liquid
- Checkmark burst (default)
- Product image fly-to-cart
- Ripple effect
Product Variant Media
The snippet automatically determines the correct variant image:add-to-cart-button.liquid
Icon Only Mobile
Hides text on mobile whenicon_only_on_mobile is true:
add-to-cart-button.liquid
Button Markup
Complete button structure:JavaScript Events
The button emits events for cart updates:add-to-cart-component web component.
Accessibility
Disabled State
Disabled State
Examples
Block Schema Settings
When used in blocks, common settings include:Related Snippets
quick-add.liquid- Quick add modal functionality- Cart Summary - Cart totals and checkout
quantity-selector.liquid- Product quantity input