Search documentation v0.9.0

Comparison

Side-by-side comparisons for features and specifications

Source ↗️ Report Issue ↗️

Use the Comparison component to present side-by-side comparisons of features, specifications, or options to help users make informed decisions. You can use them to compare pricing and plans, tiers or service packages.

Preview
FeatureFreePro
Image Carousel
Customizable CTA
Sticky CTA
Add Pricing
Unlock code
How to use the Comparison component in Astro
<Comparison
headings={['Feature', 'Free', 'Pro']}
striped="row"
trueColor="var(--w-color-success)"
falseColor="var(--w-color-alert)"
data={[
['Image Carousel', true, true],
['Customizable CTA', true, true],
['Sticky CTA', false, true],
['Add Pricing', false, true]
]}
/>

The Comparison component is an extended version of the Table component, meaning you can use the component with existing Table component props. The above example uses the following Comparison component-specific props:

If no trueColor and falseColor props are present, the icons will take the text color:

FeatureFreePro
Image Carousel
Customizable CTA
Sticky CTA
Add Pricing

Icons

You can customize the default icons using the trueIcon and falseIcon props which must be an SVG string. For example:

FeatureFreePro
Image Carousel
Customizable CTA
Sticky CTA
Add Pricing
Unlock code
How to use custom icons
---
// Import SVG strings
import { check, close } from 'webcoreui/icons'
---
<Comparison
headings={['Feature', 'Free', 'Pro']}
trueIcon={check}
falseIcon={close}
trueColor="var(--w-color-success)"
falseColor="var(--w-color-alert)"
data={[ ... ]}
/>

API

Unlock code
Component API reference
type ComparisonProps = {
data: (string | boolean)[][]
trueIcon?: string
falseIcon?: string
trueColor?: string
falseColor?: string
} & Omit<TableProps, 'data'>
Please see the documentation of the Table component for the TableProps type.
PropDefaultPurpose
data [] Sets the table cells. Must be a multidimensional array of strings or booleans.
trueIcon circle-check Sets the icon used for true values in the data prop.
falseIcon circle-close Sets the icon used for false values in the data prop.
trueColor var(--w-color-primary) Sets the color of icons when using true.
falseColor var(--w-color-primary) Sets the color of icons when using false.