Button

One link shown as a button.

When to use it

The one action that matters most in a part of a page: book, buy, download, read on.

When not to

Links inside a sentence (write them in the text) and several actions side by side (use buttons). Two buttons of the same weight make neither stand out.

Accessibility

A real link with visible text that says where it goes. Write "Book a table", not "Click here".

See it live

The component library shows this component in the default theme, in every variant: open it in the component library

The button example as the component library shows it in the default theme

Fields

What the component’s dialog asks for. In a Doc, keyed rows start with the key; rows in order follow the order below. One row, its cells in the order of the fields.

Field

Key

Kind

Required

Link

link

A link: its text and address

Yes

Variants

This component has no variants of its own; a theme can add some.

Warnings it can raise

The editor and the build say these when a block of this component needs a fix. All warnings are listed in the warnings reference.

Code

What it says

button_without_link

A button cell has no link and was skipped: "{text}"

In Google Docs

A component is a table. Its first cell names it; the rows below hold its fields. This is the example table:

button

Book now (https://example.com/book/)

In a page file

In a site kept as a folder or in Git, the same component is a block of the page’s JSON file:

JSON
{
  "name": "button",
  "rows": [
    [
      {
        "link": "Book now",
        "href": "https://example.com/book/"
      }
    ]
  ]
}

Markup and classes

What the component writes takes these classes, for a theme’s CSS: the component’s own name, name__part for its parts and name--variant for each variant (the variant’s plain name is there too).

Class

What it marks

button

The component

The HTML the example above writes, as the component library builds it in the default theme:

html
<a class="button" href="https://example.com/book/">Book now</a>

Extending it

Its files in SeedPage. A theme or a site changes the markup by giving a file of the same name (the Liquid part), and a new component can extend this one.

  • src/components/button.js
  • src/components/button/button.liquid