Skip to main content

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

File Location: snippets/button.liquid Renders a styled link element that looks like a button. Used for navigation and CTAs throughout the theme.

Parameters

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 text
  • style_class - Button style class
  • open_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 via block.settings.style_class:

Open in New Tab

When block.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: false
string
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:
Shows cart icon + text, fully interactive.
Button is disabled, no icon shown.
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 via settings.add_to_cart_animation:
add-to-cart-button.liquid
Animation Types:
  • 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
This image is used for cart animations.

Icon Only Mobile

Hides text on mobile when icon_only_on_mobile is true:
add-to-cart-button.liquid
Useful for compact layouts like product cards or quick add buttons.

Button Markup

Complete button structure:

JavaScript Events

The button emits events for cart updates:
Handled by the add-to-cart-component web component.

Accessibility

Uses proper <button type="submit"> element with name="add" for form submission.
Properly disabled when product unavailable.
Text remains accessible to screen readers even when hidden on mobile:

Examples

Block Schema Settings

When used in blocks, common settings include:
  • quick-add.liquid - Quick add modal functionality
  • Cart Summary - Cart totals and checkout
  • quantity-selector.liquid - Product quantity input