File size: 4,408 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Card

Cards are used as containers to group similar information and tasks together to make it easier to scan and read.

> Includes both `Card` and `CompactCard`

## Usage

```jsx
import { Card, CompactCard } from '@automattic/components';

function render() {
	return (
		<div className="your-stuff">
			<Card>
				<span>Your stuff in a Card</span>
			</Card>

			<CompactCard>
				<span>Your stuff in a CompactCard</span>
			</CompactCard>
		</div>
	);
}
```

### Props

| Name            | Type     | Default | Description                                                                                                                                                                                                                                                                      |
| --------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `className`     | `string` | null    | Adds CSS classes.                                                                                                                                                                                                                                                                |
| `href`          | `string` | null    | URL of the card. Adds a right chevron icon.                                                                                                                                                                                                                                      |
| `tagName`       | `string` | null    | Allows you to control the tag name of the card wrapper (only if `href` is not specified).                                                                                                                                                                                        |
| `displayAsLink` | `bool`   | false   | Used for cards without a `href` that need to display as a link. Primarily intended for use when `tagName` is "button" and when an `onClick` attribute is set. The corresponding button will render with the same visual appearance as a link (including the right chevron icon). |
| `target`        | `string` | null    | If used with `href`, this specifies where the link opens. Changes the icon to `external`.                                                                                                                                                                                        |
| `compact`       | `bool`   | false   | Decreases the size of the card.                                                                                                                                                                                                                                                  |
| `highlight`     | `string` | null    | Displays a colored highlight. If specified (default is no highlight), can be one of `info`, `success`, `error`, or `warning`.                                                                                                                                                    |
| `showLinkIcon`  | `bool`   | true    | Shows the link indicator(icon) when there is href specified                                                                                                                                                                                                                      |

### Additional usage information

- **Compact**: Use to save vertical space when displaying many consecutive cards in a list. The `CompactCard` component slightly modifies the `Card` component (and is equivalent to using `<Card compact />`).
- **Highlight**: Use when you need to highlight information that is neither a `Notice` or `Banner`.

### General guidelines

- Avoid using cards within cards. This is an inefficient use of space.
- Don't display more than one primary button or action in a single card.

## Related components

- To expand/collapse a card, use the [FoldableCard](./foldable-card) component.
- To add a text heading to a card, use the [CardHeading](./card-heading) component.
- To add a call to action, use the [ActionCard](./action-card) component.