IBM Carbon JS behaviour

Selectable Tile

The click-to-select tile: the whole surface is the checkbox — a corner checkmark and carbon-blue border inversion on select, in single- or multi-select groups.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

The tile is the checkbox

Click anywhere on a tile — the hidden input follows, the border inverts to carbon blue and the corner check snaps on. The plan group is single-select; add-ons stack.

Support plan

Add-ons

Monthly total 340 $ VAT at 10% is added at checkout.

The whole family

Radio, checkbox, clickable and icon-carrying tiles — one flat frame, one corner check, one blue border.

selectable · radio
selectable · checkbox
icon

Important props

Important props
Prop Type Default What it does
selected boolean false The selected state; the tile border flips to #0f62fe and the end-top corner checkmark appears.
name string null The radio group name; same-named tiles become single-select, unnamed ones multi-select.
handleTitle string 'label' The accessible title of the hidden input; screen readers announce the whole tile as one control.

Snippet

<label class="cbtl" data-selected="false">
<input type="radio" name="plan">
<span class="cbtl-check">✓</span>
<b>Growth plan</b>
<small>12 cores · daily backups</small>
</label>

<style>
.cbtl { position: relative; display: grid; gap: .25rem; padding: 1rem;
border: 1px solid #e0e0e0; background: #fff; cursor: pointer;
font-family: 'IBM Plex Sans', sans-serif; }
.cbtl:has(input:checked) { border: 1px solid #0f62fe; background: #edf5ff; }
.cbtl-check { position: absolute; inset-block-start: 0; inset-inline-end: 0;
visibility: hidden; padding: .25rem; background: #0f62fe; color: #fff; }
.cbtl:has(input:checked) .cbtl-check { visibility: visible; }
</style>
// app/Pages/Checkout.jsx — Inertia page; renders the React snippet
// below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import PlanTiles from '@/components/PlanTiles';

export default function Checkout() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <PlanTiles />
      </main>
    </NabuXUIProvider>
  );
}
// PlanTiles.jsx — Carbon selectable tiles: the whole surface is the checkbox
import { useState } from 'react';
import '@nabuxai/ui-core/css';

const PLANS = [
  { id: 'starter', name: 'Starter', detail: 'Community support', price: 0 },
  { id: 'growth', name: 'Growth', detail: '4-hour response · monthly report', price: 240 },
  { id: 'scale', name: 'Scale', detail: '1-hour response · dedicated engineer', price: 590 },
];
const ADDONS = [
  { id: 'backup', name: 'Daily backup', price: 60 },
  { id: 'monitor', name: 'Uptime monitor', price: 35 },
];

export default function PlanTiles() {
  const [plan, setPlan] = useState('growth');
  const [addons, setAddons] = useState({ backup: false, monitor: true });
  const total =
    PLANS.find((p) => p.id === plan).price +
    ADDONS.reduce((sum, a) => sum + (addons[a.id] ? a.price : 0), 0);
  const flip = (id) => setAddons((a) => ({ ...a, [id]: !a[id] }));

  const tile = (checked, input) => (
    <>
      {/* Hidden input; the visible chrome reacts through :has(:checked). */}
      {input}
      <span className="cbtl-check" aria-hidden="true">✓</span>
      {checked}
    </>
  );

  return (
    <>
      <style>{`
        .cbtl-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(9rem, 1fr));
                     max-inline-size: 30rem; margin-block-end: 1rem; }
        .cbtl { position: relative; display: grid; align-content: start; gap: .25rem; padding: 1rem;
                border: 1px solid #e0e0e0; background: #f4f4f4; cursor: pointer;
                font: 400 .875rem/1.4 'IBM Plex Sans', sans-serif; }
        .cbtl:hover { background: #e8e8e8; }
        .cbtl:has(input:checked) { border-color: #0f62fe; box-shadow: inset 0 0 0 1px #0f62fe; }
        .cbtl input { position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; opacity: 0; }
        .cbtl-check { position: absolute; inset-block-start: 0; inset-inline-end: 0; display: grid; place-items: center;
                      inline-size: 1.375rem; block-size: 1.375rem; background: #0f62fe; color: #fff; visibility: hidden; }
        .cbtl:has(input:checked) .cbtl-check { visibility: visible; }
        .cbtl b { font-weight: 600; }
        .cbtl small { font-size: .75rem; color: #525252; }
        .cbtl-price { font-weight: 600; font-size: 1.125rem; }
        .cbtl-total { display: flex; gap: 1rem; align-items: baseline; max-inline-size: 30rem; padding: .75rem 1rem;
                      background: #f4f4f4; border-block-start: 2px solid #0f62fe; }
        .cbtl-total b { font-size: 1.25rem; }
      `}</style>
      <div className="cbtl-grid" role="radiogroup" aria-label="Support plan">
        {PLANS.map((p) => (
          <label className="cbtl" key={p.id}>
            {tile(<><b>{p.name}</b><small>{p.detail}</small><span className="cbtl-price">${p.price}</span></>,
              <input type="radio" name="plan" checked={plan === p.id} onChange={() => setPlan(p.id)} />)}
          </label>
        ))}
      </div>
      <div className="cbtl-grid" role="group" aria-label="Add-ons">
        {ADDONS.map((a) => (
          <label className="cbtl" key={a.id}>
            {tile(<><b>{a.name}</b><span className="cbtl-price">+${a.price}</span></>,
              <input type="checkbox" checked={addons[a.id]} onChange={() => flip(a.id)} />)}
          </label>
        ))}
      </div>
      <div className="cbtl-total" role="status">
        <span>Monthly total</span>
        <b>${total}</b>
      </div>
    </>
  );
}
<!-- PlanTiles.vue — Carbon selectable tiles: the whole surface is the checkbox -->
<script setup lang="ts">
import { computed, reactive, ref } from 'vue';
import '@nabuxai/ui-core/css';

const plans = [
  { id: 'starter', name: 'Starter', detail: 'Community support', price: 0 },
  { id: 'growth', name: 'Growth', detail: '4-hour response · monthly report', price: 240 },
  { id: 'scale', name: 'Scale', detail: '1-hour response · dedicated engineer', price: 590 },
];
const addonsList = [
  { id: 'backup', name: 'Daily backup', price: 60 },
  { id: 'monitor', name: 'Uptime monitor', price: 35 },
];
const plan = ref('growth');
const addons = reactive({ backup: false, monitor: true });
const total = computed(
  () =>
    plans.find((p) => p.id === plan.value)!.price +
    addonsList.reduce((sum, a) => sum + (addons[a.id] ? a.price : 0), 0),
);
</script>

<template>
  <div class="cbtl-grid" role="radiogroup" aria-label="Support plan">
    <!-- Hidden input; the visible chrome reacts through :has(:checked). -->
    <label v-for="p in plans" :key="p.id" class="cbtl">
      <input v-model="plan" type="radio" name="plan" :value="p.id" />
      <span class="cbtl-check" aria-hidden="true">✓</span>
      <b>{{ p.name }}</b>
      <small>{{ p.detail }}</small>
      <span class="cbtl-price">${{ p.price }}</span>
    </label>
  </div>
  <div class="cbtl-grid" role="group" aria-label="Add-ons">
    <label v-for="a in addonsList" :key="a.id" class="cbtl">
      <input v-model="addons[a.id]" type="checkbox" />
      <span class="cbtl-check" aria-hidden="true">✓</span>
      <b>{{ a.name }}</b>
      <span class="cbtl-price">+${{ a.price }}</span>
    </label>
  </div>
  <div class="cbtl-total" role="status">
    <span>Monthly total</span>
    <b>${{ total }}</b>
  </div>
</template>

<style scoped>
.cbtl-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(9rem, 1fr));
             max-inline-size: 30rem; margin-block-end: 1rem; }
.cbtl { position: relative; display: grid; align-content: start; gap: .25rem; padding: 1rem;
        border: 1px solid #e0e0e0; background: #f4f4f4; cursor: pointer;
        font: 400 .875rem/1.4 'IBM Plex Sans', sans-serif; }
.cbtl:hover { background: #e8e8e8; }
.cbtl:has(input:checked) { border-color: #0f62fe; box-shadow: inset 0 0 0 1px #0f62fe; }
.cbtl input { position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; opacity: 0; }
.cbtl-check { position: absolute; inset-block-start: 0; inset-inline-end: 0; display: grid; place-items: center;
              inline-size: 1.375rem; block-size: 1.375rem; background: #0f62fe; color: #fff; visibility: hidden; }
.cbtl:has(input:checked) .cbtl-check { visibility: visible; }
.cbtl b { font-weight: 600; }
.cbtl small { font-size: .75rem; color: #525252; }
.cbtl-price { font-weight: 600; font-size: 1.125rem; }
.cbtl-total { display: flex; gap: 1rem; align-items: baseline; max-inline-size: 30rem; padding: .75rem 1rem;
              background: #f4f4f4; border-block-start: 2px solid #0f62fe; }
.cbtl-total b { font-size: 1.25rem; }
</style>
<!-- PlanTiles.svelte — Carbon selectable tiles: the whole surface is the checkbox -->
<script lang="ts">
  import '@nabuxai/ui-core/css';

  const plans = [
    { id: 'starter', name: 'Starter', detail: 'Community support', price: 0 },
    { id: 'growth', name: 'Growth', detail: '4-hour response · monthly report', price: 240 },
    { id: 'scale', name: 'Scale', detail: '1-hour response · dedicated engineer', price: 590 },
  ];
  const addonsList = [
    { id: 'backup', name: 'Daily backup', price: 60 },
    { id: 'monitor', name: 'Uptime monitor', price: 35 },
  ];
  let plan = $state('growth');
  let addons = $state({ backup: false, monitor: true });
  const total = $derived(
    plans.find((p) => p.id === plan)!.price +
      addonsList.reduce((sum, a) => sum + (addons[a.id] ? a.price : 0), 0),
  );
</script>

<div class="cbtl-grid" role="radiogroup" aria-label="Support plan">
  <!-- Hidden input; the visible chrome reacts through :has(:checked). -->
  {#each plans as p (p.id)}
    <label class="cbtl">
      <input type="radio" name="plan" value={p.id} checked={plan === p.id} onchange={() => (plan = p.id)} />
      <span class="cbtl-check" aria-hidden="true">✓</span>
      <b>{p.name}</b>
      <small>{p.detail}</small>
      <span class="cbtl-price">${p.price}</span>
    </label>
  {/each}
</div>
<div class="cbtl-grid" role="group" aria-label="Add-ons">
  {#each addonsList as a (a.id)}
    <label class="cbtl">
      <input type="checkbox" checked={addons[a.id]} onchange={() => (addons[a.id] = !addons[a.id])} />
      <span class="cbtl-check" aria-hidden="true">✓</span>
      <b>{a.name}</b>
      <span class="cbtl-price">+${a.price}</span>
    </label>
  {/each}
</div>
<div class="cbtl-total" role="status">
  <span>Monthly total</span>
  <b>${total}</b>
</div>

<style>
.cbtl-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(9rem, 1fr));
             max-inline-size: 30rem; margin-block-end: 1rem; }
.cbtl { position: relative; display: grid; align-content: start; gap: .25rem; padding: 1rem;
        border: 1px solid #e0e0e0; background: #f4f4f4; cursor: pointer;
        font: 400 .875rem/1.4 'IBM Plex Sans', sans-serif; }
.cbtl:hover { background: #e8e8e8; }
.cbtl:has(input:checked) { border-color: #0f62fe; box-shadow: inset 0 0 0 1px #0f62fe; }
.cbtl input { position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; opacity: 0; }
.cbtl-check { position: absolute; inset-block-start: 0; inset-inline-end: 0; display: grid; place-items: center;
              inline-size: 1.375rem; block-size: 1.375rem; background: #0f62fe; color: #fff; visibility: hidden; }
.cbtl:has(input:checked) .cbtl-check { visibility: visible; }
.cbtl b { font-weight: 600; }
.cbtl small { font-size: .75rem; color: #525252; }
.cbtl-price { font-weight: 600; font-size: 1.125rem; }
.cbtl-total { display: flex; gap: 1rem; align-items: baseline; max-inline-size: 30rem; padding: .75rem 1rem;
              background: #f4f4f4; border-block-start: 2px solid #0f62fe; }
.cbtl-total b { font-size: 1.25rem; }
</style>