Afterpay.js Reference
HTML Dataset Attributes
The <afterpay-placement> web component is configurable via a set of data attributes
For Placements initialized through JavaScript, all attributes should be provided in camel-case.
See Mozillas reference on dataset naming conversion for more information.
Attribute List
Amount
The value provided to the AfterpayPlacement through the amount attribute reflects the full price displayed to the customer on the page. The library calculates the installments and displays the messaging appropriately.
On a product page, the amount should be the product price. On the cart page, the amount should be the total.
The Afterpay Messaging will automatically calculate the new instalment price when the amount attribute changes.
HTML
JavaScript
amount-selector
Accepts the CSS selector corresponding to the price element on the page. The AfterpayPlacement element reads the price text from the page and sets the amount attribute on the component.
This attribute takes the second highest precedence after amount, and if neither are specified the default amount is set to zero.
HTML
Configuring the placement with data-amount-selector enables the placement to track updates to the price element. When a change is detected, the installment messaging automatically updates with the new calculated installment amount.
amount-mutation-selector
Accepts any CSS selector corresponding to the “target” element on the page to watch for changes.
When amount-mutation-selector is defined, an attribute to retrieve the current amount on the page must also be defined. There are two ways to achieve this:
-
Setting
data-amount. -
Retrieving the price text from
data-amount-selector.
HTML
Useful for eCommerce platforms like Shopify and BigCommerce where the product price is available to template pages.
HTML
badge-theme
Themes specific to data-logo-type = "badge" and data-logo-type="compact-badge"
See the logo-type section for details on switching between logos.

cart-is-eligible
Accepted values: true, false
When true, the price paragraph displays the normal installment messaging.
When false, the price paragraph renders Afterpay not available messaging.
For more information, see Set Messaging For Unavailable Items.
cbt-enabled
Displays Afterpay cross border trade information in the modal content.
Cross Border Trade
Permitted in the following regions:
-
Australia 🇦🇺
-
New Zealand 🇳🇿
-
United Kingdom 🇬🇧
currency
When provided, formats the currency for a given locale.
HTML

data-amount-range
When you specify a range of possible prices for a product using the data-amount-range attribute and the data-amount attribute is set to 0, a new messaging variant appears. This new messaging variant is based on the lowest price within the range that fits the minimum and maximum price thresholds set by the merchant.
HTML
In the HTML code example above, the message displayed is:

When the above attributes are set and the data-amount is a valid amount, the messaging with the exact instalment amount is displayed.
decimal-separator
Accepts: ".", ","
Sets how the component should parse the provided amount.
intro-text
The first word(s) of the Afterpay Messaging Paragraph.
HTML
is-eligible
Accepted values: true, false
When true, the price paragraph displays the normal installment messaging.
When false, the price paragraph renders “Afterpay not available” messaging
For more information see Set Messaging For Unavailable Items
locale
Accepted values: en_US, en_AU, en_NZ, en_CA, en_GB, fr_CA
Note
fr_CA is not currently available using the <square-placement> tag.
logo-type
Accepted values: badge, lockup, compact-badge
Badge HTML
Badge:
Lockup:
Compact Badge:
lockup-theme
Accepted values are: mint, black, and white
Mint
![]()
Black
![]()
White
![]()
mobile-view-layout
Changes the price table layout for mobile devices and on smaller screen sizes.
Accepted values: two-by-two, four-by-one
Above - two-by-two layout.
modal-id
An attribute provided by Afterpay to display custom modal content.
modal-link-style
HTML
Fully Customize “learn more link” using Slots
Provide a child element to AfterpayPlacement with the attribute/value pair slot="learn-more-link" to render a custom element which opens the Afterpay information modal when clicked.
For example:
modal-theme
Configures the modal theme using one of two predefined colors: mint and white.
White and Mint Modal Themes

payment-amount-is-bold
Accepts a boolean, true , or false. True = payment amount is in bold.
You can also apply this attribute to the afterpay-price-table component:

In the example above, the $50 prices are all in bold.
price-table-theme
Configures the modal theme using one of two predefined colors: mint (default), and white.
Mint Theme

Mint Theme HTML
White Theme

White Theme HTML
show-interest-free
Accepts a boolean, true , or false. If neither are provided, defaults to true
True example
*Or 4 interest-free payments of $10.25 with *![]()
False example
*Or 4 payments of $10.25 with *![]()
show-lower-limit
Determines whether to show the lower amount e.g) **1,000 for products outside of the provided minimum/maximum threshold. See setting a price range
Accepts a boolean, true , or false. If neither are provided, defaults to true
True example
available for orders between 2,000.
False example
available for orders over $1.
show-upper-limit
Accepts a boolean, true , or false. If neither are provided, defaults to true.
True example
available for orders between 2,000.
False example
available for orders over $1.
show-with
Accepts a boolean, true , or false. If neither are provided, defaults to true
True example
or 4 interest-free payments of $75.00 with ![]()
False example
or 4 interest-free payments of $75.00![]()
size
Accepted values: xs, sm, md, lg
The default size for an AfterpayPlacement is md (medium).
thousands-separator
Accepts: ".", ","
Sets how the component should parse the provided amount.
By default, US, CA, AU, and NZ use a comma to parse the amount in thousands.
However, in Europe, the thousands separator is automatically configured to accept amounts formatted with a decimal in the thousands place.
type
Refer to constants for a list of possible values.
Price Table
Price Paragraph
Note
If no the data-type attribute is not provided, the AfterpayPlacement will default to PRICE_PARAGRAPH
Constants
📘 Using Afterpay Constants
Constants are exposed to the window via the Afterpay object Afterpay.<constant_name>.
See some examples below
Constants are available once the Afterpay.ready event has been dispatched.
Functions
Window Events
Constructors
Constructors must be instantiated with “new”.
const Placement = new Afterpay.AfterpayPlacement();
Full example:
