Menu
All plugins

Choice Option for Bricks

Choice Option cards for the Radio and Checkbox fields of a Bricks Form. Each option becomes a card with a label, an optional heading strip, a side text such as a price and a rich content area underneath.

Version: 0.4.0 · Requires: Bricks, WordPress 6.5+, PHP 8.1+ · See the live demo

Installation

  1. Upload and activate the plugin. Bricks must be active.
  2. In a Form element, add a Radio or Checkbox field and list its options as usual, one per line.
  3. Set Choice Option cards on the field, then fill in Option cards.

Why a field setting

A Bricks Form is not nestable and only collects the fields defined in its own settings, so a separate element can never sit inside it. Instead the cards are a display for the Form’s own Radio and Checkbox fields. The native field stays in the form, so submission, required checks, emails, saved entries and conditions all work as normal. The cards are built around its inputs, which are moved and never copied.

Option cards

One block per option, in the same order as the options, with a line of — between blocks. In each block, Heading:, Label: and Side: are optional. Label defaults to the option text. Everything from Content: onwards is the rich content, so it takes paragraphs, lists, links and dynamic data.

Heading: Best value
Side: <s>£264</s> £119.99
Content:
<p>Everything in the 30-day plan, plus:</p>
<ul><li>Priority support</li></ul>
---
Label: 30-day plan
Side: £49.99
Content: <p>Billed once.</p>

Settings on the field

  • Choice Option cards (default: Standard Bricks input). Set to Choice Option cards to switch the field to cards.
  • Tick box look (default: Automatic). Automatic uses the Pure Form tick box whenever that skin is active on the page, and the Styled one otherwise. Styled always uses the card tick box. Pure Form always uses the skin, and shows browser controls if the skin is off. Browser appearance shows the browser own checkbox or radio.
  • Turn off the clickable parent (default: Off, so the clickable parent is on). On, a click anywhere on the card chooses the option, while links, buttons and fields in the content or side text keep working. Off, only the label and tick box are clickable.
  • Show bulleted lists in the content with ticks (default: Off).
  • Columns (1 to 4), Gap, Corner radius and Inner spacing, with the selected, border, background, selected background, heading background and heading text colours as hex values.

How it works

Each option stays a real input with a linked label, so it works with the keyboard and with screen readers. The heading and the content are announced as the description of the input.

The clickable parent is an empty label stretched over the card with CSS. Because it is a label, a click on it chooses the option the normal way. Links and buttons in the content sit above it.

Pure Form

The Pure Form skin draws its own tick box on the label of any control inside a wrapper with the class pure-checkbox or pure-radiobutton. In Automatic and Pure Form modes the card adds that class, and a small script checks whether the skin is drawing a box on the label. If it is, the card tick box steps aside and the skin draws its own. The check runs again when the skin is switched on or off, as the switch on the demo page does. Without JavaScript, Automatic stays Styled.

In Styled mode the skin is kept from drawing a second box.

For developers

  • CSS variables: –cob-accent, –cob-border, –cob-bg, –cob-selected-bg, –cob-heading-bg, –cob-heading-ink, –cob-ink, –cob-muted, –cob-radius and –cob-pad.
  • Classes: cob, cob__card, cob__heading, cob__label, cob__content, cob__aside, with cob–form, cob–radio, cob–checkbox, cob–auto, cob–styled, cob–pure and cob–browser on each card.

Tips

  • Keep the content short. The card is for choosing, so link to the detail instead of repeating it.
  • Use one column for related options. A narrow form, around 34rem, reads best.

Known limits

  • Cards are not shown in the builder canvas, only on the front end.
  • A card can not be disabled on its own, because the native options have no per-option disabled state.
  • Automatic needs JavaScript to switch to the Pure Form look.
  • The card highlight uses the CSS :has() selector, which every current browser supports.