Skip to content
Mesh
3.0.0-rc.0

Product Card

A product card displays information about a product including title, price, description, and benefits.

Installation

bash
npm install @nib-components/product-card

Usage

There is no default export for the product card package. Instead, there are a collection of components for you to compose together to fit your specific needs.

jsx
import {ProductCardWrapper, ProductCardHeader, ProductCardBody, HighlightMessage, HospitalTiersBadgeModal, MinHeight, InclusionList, ResponsiveInclusionList} from '@nib-components/product-card';

Interactive demo

Our most popular hospital product in NSW

Basic Essential Hospital Plus

$254.31
$165.57*
Weekly
*With an age-based discount applied

Cover for the basics, like accidental injury benefit, some specific hospital services and emergency ambulance cover with no annual limits.

jsx

Note: GreyBox is not a product card component, it is purely for demonstration purposes.

Props

HighlightMessage

PropTypeDefaultDescription
children (required)nodeThe message to display above the highlighted product card. All children will be rendered inside our <Copy> component.

ProductCardWrapper

All props passed to <ProductCardWrapper/> will be applied to the underlying <div> as attributes.

PropTypeDefaultDescription
type (required)stringThe type of product the card is displaying. Must be one of hospital, extras or combined.
tierstringThe tier of the hospital product. Not to be used on extras. Must be one of 'basic', 'basic-plus', 'bronze', 'bronze-plus', 'silver', 'silver-plus' or 'gold'.
spacenumber or objectSpacing value to be passed to internal stack component. A size from our spacing scale. Can be made responsive by passing an object of breakpoints. Value(s) must be one of 1...10.
childrennodeThe contents of the card.

ProductCardHeader

Gold Top Hospital

$254.31
$165.57*
Weekly
$175.20 from April 1
*With an age-based discount applied
jsx

Note: GreyBox is not a product card component, it is purely for demonstration purposes.

All props passed to <ProductCardHeader/> will be applied to the underlying <div> as attributes.

PropTypeDefaultDescription
type (required)stringThe type of product the card is displaying. Must be one of hospital, extras or combined.
tierstringThe tier of the hospital product. Not to be used on extras. Must be one of 'basic', 'basic-plus', 'bronze', 'bronze-plus', 'silver', 'silver-plus' or 'gold'.
spacenumber or object6Spacing value to be passed to internal stack component. A size from our spacing scale. Can be made responsive by passing an object of breakpoints. Value(s) must be one of 1...10.
heightnumberA min-height for the prduct card header, in pixels.
isLoadingbooleanfalseRenders the Loader component if true.
childrennodeThe contents of the card.

The ProductCardHeader has a number of sub-components.

jsx
<ProductCardHeader.Name>Basic Hospital</ProductCardHeader.Name>
<ProductCardHeader.Price hasDisclaimer>45.00</ProductCardHeader.Price>
<ProductCardHeader.PaymentFrequency>Weekly</ProductCardHeader.PaymentFrequency>
<ProductCardHeader.SmallText></ProductCardHeader.SmallText>
<ProductCardHeader.StrikeThroughPrice>900.00</ProductCardHeader.StrikeThroughPrice>

All subcomponents expect children.

ProductCardHeader.Name

The product name is rendered as an <h3> by default. It is important that pages have semantic heading hierarchy for screen reader users.

To alter this heading level to suit your page structure you can use the styled-components polymorphic as prop:

jsx
<ProductCardHeader.Name as="h4">Basic Hospital</ProductCardHeader.Name>
<ProductCardHeader.Name as="div">Basic Hospital</ProductCardHeader.Name> //If you cannot know for sure the heading hierarchy of the page a div is safest

ProductCardHeader.Price

PropTypeDefaultDescription
hasDisclaimerbooleanfalseWhether the price should have an asterisk appended to the end.

ProductCardBody

All props passed to <ProductCardBody/> will be applied to the underlying <div> as attributes.

PropTypeDefaultDescription
spacenumber or object6Spacing value to be passed to internal stack component. A size from our spacing scale. Can be made responsive by passing an object of breakpoints. Value(s) must be one of 1...10.
isUnavailablebooleanfalseRenders an overlay over the product card body when unavailable.
childrennodeThe contents of the card.

HospitalTiersBadgeModal

A button that opens a modal to explain the hospital tiers, highlighting the passed in tier. -plus tiers are omitted from the modal for brevity unless the selected tier is one of "basic-plus", "bronze-plus" or "silver-plus".

Should not be included in Extras product cards.

jsx

The hospital tier heading is rendered as an <h4> within a <button> by default. It is important that pages have semantic heading hierarchy for screen reader users.

To alter this heading level to suit your page structure you can use the styled-components polymorphic as prop:

jsx
<HospitalTiersBadgeModal tier="silver-plus" as="h5">
<HospitalTiersBadgeModal tier="silver-plus" as="div"> //If you cannot know for sure the heading hierarchy of the page a div is safest
PropTypeDefaultDescription
tierstringThe tier of the hospital product. Not to be used on extras. Must be one of 'basic', 'basic-plus', 'bronze', 'bronze-plus', 'silver', 'silver-plus' or 'gold'.

MinHeight

Forcing subsections of product cards to align with different content lengths unfortunately requires setting some fixed min-heights.

PropTypeDefaultDescription
height (required)number or objectThe value in px for the min-height. Useful for faking equal height product cards with varying contents. Can be made responsive by passing an object of breakpoints.

ResponsiveInclusionList

If product cards are stacking on mobile, inclusions list should collapse behind a toggle to save vertical space. This component hides the inclusion list below the xxl breakpoint by default.

PropTypeDefaultDescription
breakpointstring'xxl'Must be one of our standard breakpoints: 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' or 'xxxl'.
spacenumber or objectSpacing value to be passed to internal stack component. A size from our spacing scale. Can be made responsive by passing an object of breakpoints. Value(s) must be one of 1...10.

InclusionList

A list of inclusions. Static or dynamic.

PropTypeDefaultDescription
isStaticbooleanfalseTo just display the inclusion name and coverType icon, with no onCLick or modal for further detail.
inclusions (required)arrayEach item in the array should match the below structure.
products (required)arrayEach item in the array should match the below structure.
productIdnumberThe id of the product. Required for extras products with dynamic inclusion lists to highlight the correct row in the AnnualLimitsTable.
limitsForActiveServiceForEachProductarrayEach item in the array should match the below structure.
onInclusionModalOpenfunctionA function to call when the inclusion modal opens.
onInclusionModalClosefunctionA function to call when the inclusion modal closes.
policyBookletLinkstring'/docs/policy-booklet'Each.

Dynamic inclusion

js
{
id: PropTypes.number,
name: PropTypes.string,
description: PropTypes.string,
coveredTypeCode: PropTypes.oneOf(['Inclusion', 'Exclusion', 'MBP', 'etc.']),
waitingPeriod: PropTypes.string
}

Static inclusion

If you have a static inclusion list you can probably get away with:

js
{
id: PropTypes.number,
name: PropTypes.string,
coveredTypeCode: PropTypes.oneOf(['Inclusion', 'Exclusion', 'MBP', 'etc.']),
}

Products

An array of products that match the following shape:

js
{
claimsPercentage: PropTypes.number,
description: PropTypes.string,
id: PropTypes.number,
name: PropTypes.string,
productServices: PropTypes.array,
type: PropTypes.string
}

productId

The id of the product. Required for extras products with dynamic inclusion lists to highlight the correct row in the AnnualLimitsTable.

Optional. A number.

limitsForActiveServiceForEachProduct

For a given serviceId, an array of annual limit information for each product that has the service as an inclusion.

To be dynamically passed to InclusionList based upon the service clicked.

Required. An array of inclusions.

Each inclusion should match the following structure:

js
{
annualIncrease: PropTypes.number,
applyToName: PropTypes.string,
limitAmount: PropTypes.number,
limitText: PropTypes.string,
maxLimitPerTimePeriod: PropTypes.number,
productId: PropTypes.number,
productName: PropTypes.string,
serviceId: PropTypes.number,
timePeriod: PropTypes.string
}

onInclusionModalOpen

A function that is called as the inclusion modal opens. Generally to be used with an extras product to load the appropriate annualLimits data for the active inclusion.

You must ensure that the products prop is also passed in to the InclusionList as this function is called with fixed arguments:

onInclusionModalOpen(inclusion.id, products)

This hook is very specific to our usecase and will likely not support any other cases. If you need this function to be more flexible for your usecase, please open an issue or PR.

onInclusionModalClose

A function that is called as the inclusion modal closes. Generally to be used with an extras product to clear the annualLimits data for the active inclusion.

The url of the link to the policy booklet referenced in many of the modals. Not needed if your InclusionList is static. Required if your product card is being whitelabelled.

Optional. A string. Defaults to '/docs/policy-booklet'.

Considerations

Product card groups

Product cards can be used individually or in a group of two or more cards. When displaying a product card group, arrange the products in a continuum from cheapest (first) to most expensive (last).

Product highlight

A product card can contain a product highlight, appearing as a sentence above a product card. A product highlight assigns a card more emphasis within a product card group. Only highlight one card in a product card group and should be used to call out a recommended product or value for money product.

Long benefit lists

If you have a long benefit list, users may not scroll down beyond the list. Ensure no pertinent content appears below the product card, or alternatively apply a toggle to the benefit list so it is hidden until a user requests it.