Comparison
Side-by-side comparisons for features and specifications
npm run add ComparisonUse 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.
| Feature | Free | Pro |
|---|---|---|
| Image Carousel | ||
| Customizable CTA | ||
| Sticky CTA | ||
| Add Pricing |
<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:
data: Thedataprop is capable of handlingtrueandfalsevalues that renders a check or x icon.trueColor: Sets the color of icons rendered bytruevalues.falseColor: Sets the oclor of icons rendered byfalsevalues.
If no trueColor and falseColor props are present, the icons will take the text color:
| Feature | Free | Pro |
|---|---|---|
| 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:
| Feature | Free | Pro |
|---|---|---|
| Image Carousel | ||
| Customizable CTA | ||
| Sticky CTA | ||
| Add Pricing |
---// Import SVG stringsimport { 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={[ ... ]}/>Alignment
Alignment of the columns can also be set using the alignment prop. This will set the alignment of icons only and every table heading, except for the first column:
| Feature | Free | Pro |
|---|---|---|
| Image Carousel | ||
| Customizable CTA | ||
| Sticky CTA | ||
| Add Pricing |
| Feature | Free | Pro |
|---|---|---|
| Image Carousel | ||
| Customizable CTA | ||
| Sticky CTA | ||
| Add Pricing |
<Comparison headings={['Feature', 'Free', 'Pro']} alignment="center" data={[...]}/><Comparison headings={['Feature', 'Free', 'Pro']} alignment="right" data={[...]}/>API
type ComparisonProps = { data: (string | boolean)[][] trueIcon?: string falseIcon?: string trueColor?: string falseColor?: string alignment?: 'center' | 'right'} & Omit<TableProps, 'data'>Table component for the TableProps type. | Prop | Default | Purpose |
|---|---|---|
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. |
alignment | left | Set the alignment of icons and table headings. |