NUI-Widgets documentation has moved to Storybook hosted on Github Pages.

Card

import Card from '@concur/nui-widgets/lib/Cards/Card';

Cards are customizable content containers that group related information (e.g. expense reports, invoices, apps, etc.) in a flexible-sized container visually resembling a playing card. Cards are best suited for cases when users browse for information, rather than search. Cards must be contained within a CardDeck. Sizing of cards is controlled by the CardDeck.

Examples

Types

The different types of cards refer to the styling on the header for each card. Use the type property to define the desired type.

<CardDeck>
    <Card
        footer='Footer'
        header='Default'
        onClick={() => {}}>
        Card 1
    </Card>
    <Card
        footer='Footer'
        header='Success'
        onClick={() => {}}
        type='success'>
        Card 2
    </Card>
    <Card
        footer='Footer'
        header='Danger'
        onClick={() => {}}
        type='danger'>
        Card 3
    </Card>
    <Card
        footer='Footer'
        header='Info'
        onClick={() => {}}
        type='info'>
        Card 4
    </Card>
</CardDeck>

Clickable vs. Not Clickable

Clickable cards allow users to click anywhere on the card to view additional details. Because of this, the card itself will receive focus, so they cannot contain additional interactive elements (e.g. fields, buttons, links). They will display a drop shadow and hover state by default. Non-clickable cards should contain interactive elements that will each receive focus. Use the onClick property to define a callback function and to make a card clickable.

<CardDeck>
    <Card className='text-center' onClick={() => {}}>Card Clickable</Card>
    <Card className='text-center'>
        <p>
            Card Not Clickable
        </p>
        <div>
            <Button>Click me</Button>
        </div>
    </Card>
</CardDeck>

Usage

Properties

Property Type Default Description
children Node   Renderable content for the body of the card.
className String   Custom classes to add to the card’s <li> tag.
footer Node   Renderable content for the footer of the card. If not provided, no footer will appear.
header Node   Renderable content for the header of the card. If not provided, no header will appear.
tabIndex String   Set the tab index of the <a> tag.
type String   Type/style of card header (if provided). Options are 'success', 'danger', 'info'.

Callbacks

Property Parameters Description
onClick event Callback function when the card is clicked. If not provided, the card will not appear or be clickable.