import {ComparisonTable} from '@primer/react-brand'
A heading can be provided using the heading
prop on the root <ComparisonTable>
. This will render a heading at an appropriate size relative to the table, and present it accordingly.
For granular control over heading markup or appearance, we recommend using Heading
.
By default, the first data column will be marked as featured
. This is to draw attention to a particular product as the basis of a comparison against adjacent columns.
Featured columns will have the visually-hidden text featured
appended to their column title. This text is used to identify the featured column to screen reader users and can be customized using the visuallyHiddenFeaturedLabel
prop.
Use featuredColumn
to alternate the highlighted column if needed.
The default colors can be customized through dedicated CSS variables.
Name | Default |
---|---|
--brand-ComparisonTable-featured-color-start | --base-color-scale-pink-4 |
--brand-ComparisonTable-featured-color-end | --base-color-scale-indigo-5 |
Comparison tables are typically generated using data from an API or content management system.
ComparisonTable
accepts ReactNode
as a valid child, to facilitate conditional and dynamic rendering.
ComparisonTable
has an alternative visual presentation mode called minimal
. This will display the data without the featured columns.
This variant is suitable for embedding into long-form content, or in situations where usage of on-screen color needs to be minimized.
name | type | default | required | description |
---|---|---|---|---|
children | ComparisonTable.Row , ComparisonTable.Cell , ComparisonTable.Footnotes , ReactNode | undefined | true | Valid children. Accepts ReactNode for conditional rendering. |
heading | string | undefined | false | Optional heading that appears above table, preconfigured as a h3 . |
featuredColumn | number | 1 | false | Indicates that the data column at the specified index is visually important and unique in relation to its adjacent cells, and will be styled accordingly. |
visuallyHiddenFeaturedLabel | string | "featured" | false | A visually-hidden label which is appended to the end of the column title. Used to identify the featured column to screen reader users. |
variant | "default" , "minimal" | "default" | false | Applies alternative presentation. |
The first row in a table is automatically styled as a table header row.
name | type | default | required | description |
---|---|---|---|---|
children | ComparisonTable.Cell | undefined | true | Cells (columns) to be displayed inside the row. |
The first cell in a row is automatically styled as a header cell.
name | type | default | required | description |
---|---|---|---|---|
children | ReactNode | undefined | true | Content to be displayed inside the column cell. |
Optional node that appears below the table. This is useful for adding additional context or disclaimers.
name | type | default | required | description |
---|---|---|---|---|
children | ReactNode | undefined | true | Content to be displayed inside the column cell. |
id
, className
and ref
are forwarded by default to all children.
css | js |
---|---|
--brand-ComparisonTable-featured-color-start | brand.ComparisonTable.featured.color.start |
--brand-ComparisonTable-featured-color-end | brand.ComparisonTable.featured.color.end |