Skip to content

Extending ​

Custom statuses ​

To add statuses of your own, pass statuses with the default ones and yours:

ts
import { defaultStatuses, defineMatrix } from "vitepress-comparison"
import deprecated from "./icons/deprecated.svg?raw"
import removed from "./icons/removed.svg?raw"

export const matrix = defineMatrix({
  statuses: {
    ...defaultStatuses,
    deprecated: { label: "Deprecated", icon: deprecated, color: "var(--vp-c-purple-1)" },
    removed: { label: "Removed", icon: removed, color: "var(--vp-c-red-1)", requiresHref: true },
  },
  projects: [...],
  groups: [...], // cells: { other: "deprecated" }
})

The matrix shows them in its cells and legend:

FeatureKvik2.4.0Acme Store5.1.2Globex DB0.18.3
#Client API
  • Supported
  • Not supported
  • Not reviewed yet
  • Deprecated
  • Removed

Each status has:

  • label: its name in the legend and in the popovers of its cells.
  • icon: the SVG markup of its icon, which the matrix draws 18 pixels wide. Give the SVG a viewBox and draw it with currentColor, so that it takes color.
  • color: the CSS color of its icon.
  • requiresHref: when true, each cell of the status sets href, as declined does.

The legend lists the statuses that the cells take, in the order of their keys. To override a default status, spread its definition and change its fields, such as supported: { ...defaultStatuses.supported, label: "Yes" }. To leave out default statuses, list the ones you keep, such as unknown: defaultStatuses.unknown, instead of spreading them all. Keep unknown: a project without a cell takes it.

To share a set between matrices, declare it with satisfies StatusDefinitions, so that types still require href in the cells of a status with requiresHref: true.