Skip to content

Latest commit

 

History

History
278 lines (226 loc) · 13.1 KB

File metadata and controls

278 lines (226 loc) · 13.1 KB

export const meta = { title: 'Card', package: '@twilio-paste/card', description: 'The Twilio Paste Card', slug: '/components/card/', };

import Image from 'next/image'; import {Anchor} from '@twilio-paste/anchor'; import {Box} from '@twilio-paste/box'; import {Button} from '@twilio-paste/button'; import {Callout, CalloutHeading, CalloutText} from '@twilio-paste/callout'; import {Card} from '@twilio-paste/card'; import {Heading} from '@twilio-paste/heading'; import {Text} from '@twilio-paste/text'; import {Paragraph} from '@twilio-paste/paragraph'; import {Stack} from '@twilio-paste/stack'; import {Separator} from '@twilio-paste/separator' import Changelog from '@twilio-paste/card/CHANGELOG.md';

import {DoDont, Do, Dont} from '../../../components/DoDont'; import {SidebarCategoryRoutes} from '../../../constants'; import PrimaryDo from '../../../assets/images/do1-primary-button.png'; import PrimaryDont from '../../../assets/images/dont1-primary-button.png'; import HeadingDo from '../../../assets/images/do2-heading-in-card.png'; import MultipleDont from '../../../assets/images/dont2-multiple-primary.png'; import packageJson from '@twilio-paste/card/package.json'; import ComponentPageLayout from '../../../layouts/ComponentPageLayout'; import {getFeature, getNavigationData} from '../../../utils/api';

export default ComponentPageLayout;

export const getStaticProps = async () => { const navigationData = await getNavigationData(); const feature = await getFeature('Card'); return { props: { data: { ...packageJson, ...feature, }, navigationData, mdxHeadings, pageHeaderData: { categoryRoute: SidebarCategoryRoutes.COMPONENTS, githubUrl: 'https://github.com/twilio-labs/paste/blob/main/packages/paste-core/components/card/', storybookUrl: '/?path=/story/components-card--default', }, }, }; };

<LivePreview scope={{Card, Paragraph, Heading, Anchor}} language="jsx"> {<Card> <Heading as="h2" variant="heading20">Parable of the Talents</Heading> <Paragraph> Choose your leaders with wisdom and forethought. To be led by a coward is to be controlled by all that the coward fears. To be led by a fool is to be led by the opportunists who control the fool. To be led by a thief is to offer up your most precious treasures to be stolen. To be led by a liar is to ask to be lied to. To be led by a tyrant is to sell yourself and those you love into slavery. </Paragraph> <Paragraph marginBottom="space0">— <Anchor href="https://www.goodreads.com/book/show/60932.Parable_of_the_Talents">Octavia Butler</Anchor></Paragraph> </Card>}

Guidelines

About Cards

Cards are specifically-styled containers that group related content and actions. Cards are a great tool for placing a concise amount of related information together in one object, much like a business card or baseball card in real life.

Card is an extremely flexible container that does not require specific components inside of it. You can compose a Card to support your use case, but elements such as Heading, Paragraph, and Button or Anchor are commonly used.

A Card does not handle any interactive events such as hover, click, or focus, though children composed inside of it may commonly have event handlers.

Acknowledging the flexibility of Card component, there are several non-negotiable properties of a Card that differentiate it from a more basic page-layout element, such as Box including background color, border width, border radius, and border color.

Card vs. Box

At its core, Card is a Box with specific styling attributes and more explicit use cases that you can find in Examples. If you find yourself limited by the default styling and constraints of a Card, you may consider using a Box instead, but first consider bringing the problem you are trying to solve to Design System Office Hours to see if another component or pattern could fit your needs.

Examples

Default Card

By default, a Card has space100 padding, which can be adjusted with padding props and spacing tokens.

<LivePreview scope={{Card, Paragraph, Heading, Anchor}} language="jsx"> {<Card> <Heading as="h2" variant="heading20">Parable of the Talents</Heading> <Paragraph> Choose your leaders with wisdom and forethought. To be led by a coward is to be controlled by all that the coward fears. To be led by a fool is to be led by the opportunists who control the fool. To be led by a thief is to offer up your most precious treasures to be stolen. To be led by a liar is to ask to be lied to. To be led by a tyrant is to sell yourself and those you love into slavery. </Paragraph> <Paragraph marginBottom="space0">— <Anchor href="https://www.goodreads.com/book/show/60932.Parable_of_the_Talents">Octavia Butler</Anchor></Paragraph> </Card>}

Adjusting padding

You can set non-default padding on all sides of a Card.

<LivePreview scope={{Card, Box, Button, Paragraph, Heading, Separator, PrimaryDo}} language="jsx"> {<Box maxWidth="size40"> <Card paddingLeft="space0" padding="space0"> <Box> <img src="/assets/illustrations/alerts_and_notifications" alt="" height="100px" width="100px"/> </Box> <Separator orientation="horizontal" verticalSpacing="space0" /> <Box paddingY="space60" paddingX="space90"> <Heading as="h2" variant="heading40">Alerts and notifications</Heading> <Paragraph> Inform, engage, and drive customers to take action. Deliver reliable multichannel notifications through Twilio. </Paragraph> <Button variant="secondary" size="small">Try notifications</Button> </Box> </Card> </Box>}

Card with Title, Body and Button

One of the most common use cases for a Card is to relate a title (Heading), supporting body copy (Paragraph), and primary action (Button) together. Relating these three elements together with a Card makes it easy for a user to digest and provides a clear call to action.

<LivePreview scope={{Stack, Card, Paragraph, Heading, Button}} language="jsx"> {<Stack orientation="vertical" spacing="space40"> <Card padding="space120"> <Heading as="h2" variant="heading20">The Transgender District</Heading> <Paragraph> The mission of the Transgender District is to create an urban environment that fosters the rich history, culture, legacy, and empowerment of transgender people and its deep roots in the southeastern Tenderloin neighborhood. The transgender district aims to stabilize and economically empower the transgender community through ownership of homes, businesses, historic and cultural sites, and safe community spaces. </Paragraph> <Button variant="primary" as="a" href="https://www.transgenderdistrictsf.com/">Support The Transgender District</Button> </Card> <Card padding="space120"> <Heading as="h2" variant="heading20">Inside Out</Heading> <Paragraph> Inside Out empowers, educates, and advocates for LGBTQ+ of youth from the Pikes Peak Region in Southern Colorado. Inside Out does this by creating safe spaces, support systems and teaching life skills to all youth in the community and working to make the community safer and more accepting of gender and sexual orientation diversity. </Paragraph> <Button variant="primary" as="a" href="https://insideoutys.org/">Support Inside Out</Button> </Card> <Card padding="space120"> <Heading as="h2" variant="heading20">The Audre Lorde Project</Heading> <Paragraph> The Audre Lorde Project is a Lesbian, Gay, Bisexual, Two Spirit, Trans and Gender Non Conforming People of Color center for community organizing, focusing on the New York City area. Through mobilization, education and capacity-building, they work for community wellness and progressive social and economic justice. Committed to struggling across differences, they seek to responsibly reflect, represent and serve their various communities. </Paragraph> <Button variant="primary" as="a" href="https://alp.org/">Support The Audre Lorde Project</Button> </Card> </Stack>}

Marketing card

Use these layouts when you need to draw customers’ attention to upsell and cross-sell opportunities. Use them sparingly, mainly when they’ll help customers solve immediate problems.

Research insight on marketing and cross-selling Research from Twilio has shown that cross-sell cards aren’t useful when the developers are in the product focused on urgent problems. They’re likely to ignore these cards, regardless of how they’re presented, until they’re relevant to a current project they’re working on.

To create a marketing card, start by layering items from the top of this list. Add or remove items as you work your way down to create the right level of emphasis for your card:

  1. Place the content at the top of the page.
  2. Add more padding than other text content or Cards around it. Start with space-130 and size up in 8px increments from there.
  3. Add an illustration.
  4. If you’re cross-selling across platforms (e.g., Segment, SendGrid, Communications, Flex), add a brand Badge.

Most marketing content in the product is a suggestion to customers. As you layer items from the list, make sure you’re not distracting from their main goals on a page. A marketing Card should catch a customer’s attention but not at the expense of everything else in the flow.

Don’t use everything in the list at once. If your marketing content is not the main content of a page, use 1-2 items. If it is the main content, use no more than 3 items.

You might even find out that you don’t need to put your content in a Card. To emphasize the content without using Card, use Box and color-background-weak.

Use more padding and illustrations:

<LivePreview scope={{Card, Paragraph, Heading, Anchor}} language="jsx"> {<Card> example </Card>}

<LivePreview scope={{Card, Paragraph, Heading, Anchor}} language="jsx"> {<Card> example </Card>}

Use illustrations and a marketing Badge:

<LivePreview scope={{Card, Paragraph, Heading, Anchor}} language="jsx"> {<Card> example </Card>}

Don’t use Card at all:

<LivePreview scope={{Card, Paragraph, Heading, Anchor}} language="jsx"> {<Card> example </Card>}

If these options don’t work for your use case and you need to create something custom, request a creative review with the Brand team and partner with them to make sure it aligns with Twilio’s brand guidelines.

Pricing cards

Use this layout to show a group of cards with pricing plans. Use a brandmarketing Badge to highlight a “recommended” plan and decorative Badges for a customer’s current plan.

The text layout in each Card is a suggestion. Adjust it as needed for your use case.

<LivePreview scope={{Card, Paragraph, Heading, Anchor}} language="jsx"> {<Card> example </Card>}

Composition notes

When a Card contains text content, use the following guidelines:

  • Use a Heading to highlight the most important information.
  • Use a Paragraph to add additional context. Do not repeat the information in the header. Front-load the most critical information.
  • When presenting multiple Cards of equal weight on a single page, structure each Card's content similarly.

Do and don't