The Button block A piece of a page, such as a paragraph, a picture or a button. In WordPress you build a page by putting blocks one after another. is one call to action. A click can go to a link or do something on the page, and it can do a second thing on the same click, for example copy a code and scroll to a section. See it working on the Button page.
Add a button
Add the Button block where you want it.
Type the words on the button itself.
In the Settings tab, pick What the button does, and fill in the field it shows.
What the button does
What the button does starts as Goes to a link. Each choice shows the fields it needs:
- Goes to a link: the Link, a web address or a Gillish Node link. Switch on Open in a new tab if you want that; screen readers A program that reads the screen aloud, for people who cannot see it well. They move around the page with the keyboard and hear what is there. are told it opens a new tab. Switch on Paid link for a link you are paid for, such as an affiliate link, and search engines are told so. A button with no link shows as plain text.
- Opens a modal and Closes a modal: Opens which modal? takes the modal’s id. A Button added together with a Modal is linked already. A closing button goes inside the modal.
- Closes a callout and Sends the form: place the button inside the callout box or the Form block.
- Downloads a file: File to download, the address of a PDF, an image or a zip. A click saves it instead of opening it.
- Copies text: Text to copy, and “Copied!” feedback (optional), the words the button shows for a moment after a copy. Screen readers are told about each copy.
- Prints the page: opens the browser’s print window.
- Shares the page: opens the device’s share window. Address to share (optional) and Title to share (optional) let you share another page. Where there is no share window, as on many computers, the button copies the link and shows “Link copied”.
- Scrolls to a section: Section to scroll to, the HTML anchor of the target block, for example pricing. Set it on that block under Advanced, HTML anchor.
- Controls media: Media to control (id), and What to do: Play / pause, Play, Pause or Mute / unmute.
- Shows or hides content: Content to show or hide (id), the HTML anchor of the block to show or hide.
- Does nothing (for show): a real button that stays put on a click, for showing how a button looks. It still reacts when you point at it, reach it with Tab or press it, and it has no And also.
And also (optional) adds a second action on the same click, for example scroll to a section and close the modal. It offers the same choices, apart from going to a link, downloading a file, opening a modal and sending a form.
Size and place
- Style: Filled (the default), Outline or Text link, all three shown below.
- Size: Small, Normal (the default) or Large. The size of the words is set in the Styles tab.
- Width: Fit the text (the default), Full width, or Custom, a share of the width there is.
- Alignment: left (the default), centre or right.
- Icon: pick one from the Cairnstone set, type a Dashicon name or paste your own SVG, and choose whether it sits before or after the words.
Try them: the three styles of the Button block itself. Point at them or reach them with Tab to see each state; a click keeps you on this page.
A filled button starts with the colour of your page’s text as its fill, and white or black words, whichever reads better. The Cairnstone data panel puts a field such as the post’s title or date into the button’s words.
Colours and shape
Where you set the look depends on where you edit the block. In a normal post or page, the Styles tab has WordPress’s own controls: typography. In a saved Cairnstone block, under Cairnstone → Blocks, the Styles tab has Cairnstone’s full set: colour, typography, border, shadow, filters, and size and spacing. There, a switch sets colours and shape for each state: Default, Hover, Focus, Active and Disabled. See Style a block in the Styles tab.
What visitors can do
- A button that goes to a link is a real link. Every other button is a real button: Tab reaches it, and Enter or Space runs it.
- A button that shows or hides content tells screen readers whether the content is open.
- Scrolling is smooth, unless the visitor has asked their device for less motion.
Next, read Fold answers away in an accordion.
