Skip to content
Klarhimmel UI

Comparison, us versus them

Comparison, us versus them previewComparison, us versus them preview

Install

npx shadcn add https://ui.klarhimmel.com/r/comparison-table.json
DetailsAbout, usage, props and more

A table comparing you with one to three alternatives, feature by feature. Each cell says Included, Not included or Partly in words beside its icon.

Import

Import

import Block from '@/components/klarhimmel/blocks/comparison-table';
Also called
  • comparison/table
About
A table comparing you with one to three alternatives, feature by feature. Each cell says Included, Not included or Partly in words beside its icon.
Category
How it differs from the alternatives: a table that says yes, no or partly in words. New project? Set it up once: /get-started/installation.

Notes

When to use it

A feature-by-feature table of you against one to three alternatives, for readers who are already comparing. If the honest answer depends on who the reader is, comparison-cards fits better.

Writing for it

- Each row gives one verdict for you, then one per alternative, in the order of the column names. A row with the wrong count of values is the usual mistake. - Verdicts are said in words beside the icon. Change the three words in the words field for another language instead of leaving the English ones. - The block takes three to ten rows. A note of 100 characters under a feature is the place to explain a partial.

Watch out for

On a narrow container the table scrolls sideways inside its own region, with a hint under it. Name the table in the caption, because that is what a screen reader announces first.

Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import ComparisonTable from '@/components/klarhimmel/blocks/comparison-table';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <ComparisonTable props={{
          "eyebrow": "Name the topic",
          "title": "Say how the options differ",
          "description": "Say in one or two sentences what the table compares and why it is honest.",
          "caption": "Say what is compared, so a screen reader can name the table.",
          "featureLabel": "Name the rows",
          "ours": "Our option",
          "others": [
            "First option",
            "Second option"
          ],
          "rows": [
            {
              "feature": "Name a first feature, in a line",
              "values": [
                "yes",
                "no",
                "yes"
              ]
            },
            {
              "feature": "Name a second feature, in a short line",
              "note": "Say what it means for them",
              "values": [
                "yes",
                "partial",
                "yes"
              ]
            },
            {
              "feature": "Name a third feature, in a line",
              "values": [
                "yes",
                "partial",
                "no"
              ]
            }
          ],
          "words": {
            "yes": "Included",
            "no": "Not included",
            "partial": "Partly"
          },
          "scrollHint": "Say how to reveal the other columns",
          "cta": {
            "label": "Main action",
            "href": "#trial"
          }
        }} />
      </BlockSurface>
    </Theme>
  );
}

Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

PropTypeDefaultDescription
eyebrowstring'Name the topic'Text, up to 60 characters.
titlestring'Say how the options differ'Text, up to 120 characters.
descriptionstring'Say in one or two sentences what th…'Text, up to 300 characters.
captionstring'Say what is compared, so a screen r…'Text, up to 80 characters.
featureLabelstring'Name the rows'Text, up to 30 characters.
oursstring'Our option'Text, up to 30 characters.
othersstring[]2 itemsList of 1 to 3.
rows{ feature, note, values }[]6 itemsList of 3 to 10. Each item: feature, note (optional), values.
words{ yes, no, partial }{…}Fields: yes, no, partial.
scrollHintstring'Say how to reveal the other columns'Text, up to 40 characters.
ctaLink{…}See the type.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.