Getting Started
Use a comparison matrix to show how your library and its alternatives support each feature: features in rows, projects in columns. See the demo.
Install
sh
npm install -D vitepress-comparisonThe matrix follows the colors and layout of the VitePress default theme in light and dark mode.
Add a comparison page
Define the matrix in a TypeScript file next to the page:
ts
import { defineMatrix } from "vitepress-comparison"
export const matrix = defineMatrix({
projects: [
{ id: "mine", name: "My Library", version: "1.2.0" },
{ id: "other", name: "Other Library", version: "3.0.1", url: "https://example.com" },
],
groups: [
{
id: "basics",
title: "Basics",
features: [
{
id: "caching",
title: "Caching",
description: "Cache the results of repeated calls.",
cells: {
mine: "supported",
other: { status: "limited", note: "Only in memory." },
},
},
],
},
],
})Render it on the page with ComparisonMatrix:
md
---
aside: false
---
<script setup>
import { ComparisonMatrix } from "vitepress-comparison"
import { matrix } from "./matrix"
</script>
# Comparison
<ComparisonMatrix :matrix="matrix" />The matrix needs no VitePress configuration and no stylesheet import.
- Give the data file a name other than the page's, such as
matrix.tsforcomparison.md: withcleanUrls, the dev server servescomparison.tsat the URL ofcomparison.md. - Set
aside: false, so that the matrix takes the width of the outline column.
See Matrix Data for the projects, features, and cells that a matrix takes.