Import
import { UsageCard } from '@contentful/f36-components';// orimport { UsageCard } from '@contentful/f36-usage-card';
Examples
Basic UsageCard of usage variant
function UsageCardUsageExample() { return ( <UsageCard variant="usage" header={ <UsageCard.Header title="Asset Bandwidth Usage" tooltip="This is a tooltip for the usage card" /> } description={ <UsageCard.Description> This is a description of the usage card. {' '} <TextLink target="_blank" rel="noopener noreferrer" href={'https://www.contentful.com'} > Learn more </TextLink> </UsageCard.Description> } > <UsageCount variant="periodic" value={150} valueUnit="GB" periodType="year" /> </UsageCard> ); }
Basic UsageCard of info variant
function UsageCardInfoExample() { return ( <UsageCard variant="info" header={ <UsageCard.Header title="This is an Info Card" tooltip="This is a tooltip for Info Card" /> } description={ <UsageCard.Description> This is a description of the info card. {' '} <TextLink target="_blank" rel="noopener noreferrer" href={'https://www.contentful.com'} > Learn more </TextLink> </UsageCard.Description> } > <UsageCount variant="consumption" value={150} valueUnit="GB" valueDescription="Used this month" /> </UsageCard> ); }
UsageCard areas
The UsageCard component offers 4 individually setable areas, three of them can be set via the props header, description and variant.
Prop | Description | Recommended child components |
|---|---|---|
children | Elements handed over as children to the UsageCard component will be
rendered as the UsageCard body. The common case is using | UsageCount |
header |
| UsageCard.Header |
description |
| UsageCard.Description with Text or TextLink |
variant |
| N/A |
Props (API reference)
Open in StorybookName | Type | Default |
|---|---|---|
| className | string CSS class to be appended to the root element | |
| description | string number bigint false true ReactElement<unknown, string | JSXElementConstructor<any>> Iterable<ReactNode> ReactPortal Promise<AwaitedReactNode> | |
| header | string number bigint false true ReactElement<unknown, string | JSXElementConstructor<any>> Iterable<ReactNode> ReactPortal Promise<AwaitedReactNode> | |
| testId | string A [data-test-id] attribute used for testing purposes | |
| variant | "usage" "info" The type of the card. | 'usage' |