---
updatedAt: 2026-05-14T17:26:53.000Z
agentTools:
  siteIndex: https://docs.affirm.com/llms.txt
  projectIndex: https://docs.affirm.com/developers/llms.txt
---

# Checkout Button

Learn more about our pre-styled Checkout button, which makes implementing Affirm even easier. 

<HTMLBlock>{`
<style>
  .dropdown-menu {
    font-family: Arial, sans-serif;
    max-width: 250px;
    margin-left: auto; /* Align to the right */
  	margin-right: 0; /* Ensure it's flush to the right */
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    background: #4A4AF4;
    overflow: hidden; /* Ensure the container grows with content */
  }

  .dropdown-item {
    margin-bottom: 10px;
  }

  .dropdown-toggle {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
  }

  .dropdown-toggle:hover {
    background: #f0f0f0;
  }

  .dropdown-content {
    display: none;
    margin-top: 5px;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
  }

  .dropdown-item.open .dropdown-content {
    display: block;
  }

  .flag-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
  }

  .product-item {
    margin-bottom: 5px;
  }

  .product-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
  }
  
  .country-title {
    font-family: Arial, sans-serif;
    font-size:20px;
    text-align: center;
    font-weight: bold;
    color: #ffffff;
  } 

</style>
  <div class="dropdown-menu">
    <p class="country-title" alt="Countries where this product is available">Country Availability</p>

    <div class="dropdown-item">
      <button class="dropdown-toggle" onclick="toggleDropdown(event)" alt="Drop down menu displaying the available countries for this product">
        <b>Country List</b> ⬇️
      </button>
      <div class="dropdown-content">
        <div class="product-item">
          <img src="https://files.readme.io/a4c8b3d6596d943e2b93c82cb1d432a2edaf6998667835c2e97ef4a31d460c7e-us-circle-01.png" alt="USA" class="flag-icon">
          USA
        </div>
        <div class="product-item">
          <img src="https://files.readme.io/3ca294a1b4b8b8506c3ff32876abc6e3e33d0e65a509dab81398915094bdbc5c-61TcZ33ZrJL._AC_UY1000_.jpg" alt="Canada" class="flag-icon">
          Canada
        </div>
        <div class="product-item">
          <img src="https://files.readme.io/db98461fef617df7c9970e98f01150f067fcee1fc823a450f09056138b9f70be-united-kingdom-flag-rounded-icon-uk-flag-union-jack-vector.jpg" alt="UK" class="flag-icon">
          UK
        </div>
      </div>
    </div>

  </div>
`}</HTMLBlock>

## Overview

To streamline the Affirm implementation process, we offer a pre-styled checkout button that you can use on your website. The available attributes enable you to adjust the button size, shape, color, and more to help meet your business needs.

<Image align="center" alt="screenshot of new checout button on mobile devices" border={true} src="https://files.readme.io/36f6eef7f5fc49dcbe0c714061efdc56b03b9b14967bcd3cd30b8c7300169d17-mockup_1600_x_600_px_1.svg" className="border" />

<br />

## Steps

### 1. Update your site

Add the `affirm-checkout-button-container` class to a container div on your website. Affirm.js then renders the `<affirm-checkout-button>` custom element button inside the container.

### 2. Add attributes

Use the available attributes to indicate the page type and to adjust the button style. For details, see the Affirm.js Reference section below.

### 3. (Optional) Call the function

Call `affirm.ui.checkoutButton.render()` to automatically render Affirm checkout buttons for all containers on the page with the `affirm-checkout-button-container` class.

<Callout icon="📘" theme="info">
  **Note:** If you add a new button container later on, you may need to call the function again manually in Single Page Applications (SPAs).
</Callout>

<br />

## Affirm.js Reference

The button can be styled using the following attributes:

<Table align={["left","left"]}>
  <thead>
    <tr>
      <th>
        Attribute
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        **data-page-type**  
        <span style={{ color: "crimson" }}>required</span>
      </td>

      <td>
        Indicates which page type the button displays on. Values:

        * `banner`
        * `category`
        * `cart`
        * `homepage`
        * `landing`
        * `marketplace`
        * `payment`
        * `product`
        * `search`
      </td>
    </tr>

    <tr>
      <td>
        **data-size**  
        _optional_
      </td>

      <td>
        Sets a button size. Values:

        * `small`
        * `medium` (default option)
        * `large`
      </td>
    </tr>

    <tr>
      <td>
        **data-full-width**  
        _optional_
      </td>

      <td>
        Boolean attribute that sets the button to expand to 100% of its parent container's width.
      </td>
    </tr>

    <tr>
      <td>
        **data-theme**  
        _optional_
      </td>

      <td>
        Sets the button to display in dark theme or light theme. Values:

        * `dark` (default option)
        * `light`
      </td>
    </tr>

    <tr>
      <td>
        **data-shape**  
        _optional_
      </td>

      <td>
        Sets the button shape. Values:

        * `sharp`
        * `pill` (default option)
        * `rounded`
      </td>
    </tr>

    <tr>
      <td>
        **data-button-text**  
        _optional_
      </td>

      <td>
        Sets the contents of the button. Values:

        * `buy-now`: Displays “Buy now with affirm” (default option)
        * `checkout`: Displays “Checkout with affirm”
        * `logo-only`: Display only the Affirm Logo
      </td>
    </tr>
  </tbody>
</Table>

<Image align="center" alt="two different versions of the pre-styled button that you can adjust" border={true} src="https://files.readme.io/a154c89e022a371790939b8ce0d9d518469cfef3cccad554ed01bf790017cc03-updated_buttons.svg" className="border" />

<br />

## Examples

**Default button styling on a product page**:

<HTMLBlock>{`
<iframe width="100%" height="300" src="//jsfiddle.net/madisonreardon/ct0nsmex/2/embedded/result,html/" frameborder="0" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe>
`}</HTMLBlock>

**Full-width button**:

<HTMLBlock>{`
<iframe width="100%" height="300" src="//jsfiddle.net/chantalaffirm/tmxn47ks/2/embedded/result,html/" frameborder="0" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe>
`}</HTMLBlock>

**Styled button with checkout text**:

<HTMLBlock>{`
<iframe width="100%" height="300" src="//jsfiddle.net/madisonreardon/3vdm4rob/embedded/result,html/" frameborder="0" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe>
`}</HTMLBlock>

**Styled logo-only button**:

<HTMLBlock>{`
<iframe width="100%" height="300" src="//jsfiddle.net/madisonreardon/numrqw29/embedded/result,html/" frameborder="0" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe>
`}</HTMLBlock>

**Passing locale fr\_CA**:

<HTMLBlock>{`
<iframe width="100%" height="300" src="//jsfiddle.net/chantalaffirm/3osbcgzn/10/embedded/result,html/" frameborder="0" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe>
`}</HTMLBlock>

<br />

## Recommended Topics

* <Anchor label="Set Up Direct API" target="_blank" href="https://docs.affirm.com/payments/docs/transactions-web">Set Up Direct API</Anchor>
* <Anchor label="Checkout Overview" target="_blank" href="https://docs.affirm.com/developers/docs/affirm-checkout-overview">Checkout Overview</Anchor>
* <Anchor label="Solutions We Offer" target="_blank" href="https://docs.affirm.com/developers/docs/solutions-we-offer">Solutions We Offer</Anchor>

# Sibling pages

* [Checkout Overview](https://docs.affirm.com/developers/docs/affirm-checkout-overview.md)
* [About Express Checkout](https://docs.affirm.com/developers/docs/express-checkout.md)
* [Set up Express Checkout](https://docs.affirm.com/developers/docs/set-up-express-checkout.md)
* [Open Affirm Checkout](https://docs.affirm.com/developers/docs/open-affirm-checkout.md)
* [Open Affirm Virtual Card Checkout](https://docs.affirm.com/developers/docs/open-affirm-virtual-card-checkout.md)
* [Modal vs. Redirect Checkout](https://docs.affirm.com/developers/docs/modal-vs-redirect-checkout.md)
* [Modal with Direct Checkout](https://docs.affirm.com/developers/docs/modal-with-direct-checkout.md)
* [Additional Features](https://docs.affirm.com/developers/docs/additional-features.md)