Menu
All plugins

Clickable Parent for Bricks

A Bricks extension (no new element) for the Section, Container, Block and Div elements. Tick one box and the whole element becomes clickable, using the clickable parent (stretched link) pattern.

Version: 0.1.0 · Requires: Bricks 1.9+, WordPress 6.5+ · See the live demo

Installation

  1. Upload and activate the plugin. Bricks must be active.
  2. Select a Section, Container, Block or Div in Bricks. The Clickable parent group is on the Content tab.
  3. Switch on Make the whole element clickable.

Settings

  • Make the whole element clickable (default: Off)
  • Which link to stretch (default: Heading link, else first link). Other choices: Link inside a heading, First link, Link with a CSS class.
  • Link CSS class. Shown when Link with a CSS class is chosen. A single class name, with or without the dot.
  • Cover other links and buttons too (default: Off)
  • Keyboard focus outline (default: Around the whole element). The other choice is Around the link only.
  • Focus outline colour (default: the text colour) and Focus outline offset (default: 4px).

Quick start

  1. Build a card: a Block with an Image, a Heading, and a text.
  2. Give the Heading a link. A dynamic link such as the post URL works, so it suits query loops.
  3. On the Block, tick Make the whole element clickable.
  4. View the page. A click anywhere on the card follows the heading link.

How it works

Wrapping a whole card in one link makes a screen reader read the entire card as the link’s name. The clickable parent pattern avoids that. The real link stays on the heading, with the heading text as its name. The plugin then stretches that link’s click area over the element with a CSS pseudo-element (::after with inset: 0). The element becomes the positioning boundary, so the click area stops at its edge. There is no JavaScript.

The plugin finds the link when the element renders, then marks it with a data-nl-cp-link attribute. The stylesheet only loads on pages that use the extension.

Which link is stretched

  • Heading link, else first link: a link inside a heading wins, because it gives the best accessible name. Otherwise the first link is used.
  • Link inside a heading: only a heading link counts. If there is none, nothing is stretched.
  • First link: the first link in the element.
  • Link with a CSS class: the first link that has the class. Add the class to a Text Link, Button or Heading link.

Links with no destination, and hidden links (aria-hidden="true" or tabindex="-1"), are never used, so the stretched link is always reachable from the keyboard.

Other links inside the element

Other links, buttons, form fields, summaries and nested clickable parents are lifted above the stretched link, so a category tag or a Share button still does its own job. Tick Cover other links and buttons too to make every click follow the main link instead.

Keyboard focus

When the stretched link has keyboard focus, the outline is drawn around the whole element and the link’s own outline is hidden. It shows for keyboard focus only (:focus-visible), never for a mouse click. Browsers without :has() keep the normal link outline. Choose Around the link only to turn this off.

Query loops and card listings

Tick the box on the root element of a card template and every card the loop renders is clickable, including cards loaded by page numbers or Load more. Each card finds its own link. The Card Listings demo and this plugin’s demo page show it with page numbers.

Cards inside cards

Each clickable parent only looks at its own links, ignoring links inside a clickable parent nested within it. An inner card follows its own link, and the rest of the outer card follows the outer link.

Tips

  • Put the link on the Heading. It gives screen reader users a clear link name and keeps the page outline intact.
  • Give the card a hover state, such as a border colour or shadow, so visitors can see it is clickable. The pointer already changes to a hand.
  • If the card has a picture that links somewhere else, leave it as its own link. It stays clickable above the stretched link.

Troubleshooting

  • The click area is smaller than the card: a positioned or transformed element between the link and the clickable parent, such as an image wrapper with position: relative, becomes the boundary instead. Remove the position, or move the link out of it.
  • Nothing happens in the builder: expected. Nothing is added inside the builder, so you can still select elements.
  • Nothing is stretched: the element has no usable link. Check that the link has a destination, is not hidden, and (for Link with a CSS class) that the class is on the link itself.
  • I cannot select the text: the overlay covers the text. That is how the pattern works.

For developers

  • nl_cp/elements filters the Bricks elements that get the control group. The default is section, container, block and div.

Known limits

  • Not applied inside the builder.
  • Links added to the element by JavaScript after page load are not seen. The link is chosen on the server.
  • With nested clickable parents, tabbing to an inner link also outlines the outer element.