Card β
A Card groups information related to a single topic.
| Name | Value |
|---|---|
| Props | |
icon | |
forceThumbnail | |
thumbnailPosition | |
thumbnailSize | |
separation | |
url | |
| Slots | |
title | |
description | |
supporting-text | |
| View | |
Reading direction | |
Note: For icon properties, the relevant icon also needs to be imported from the @wikimedia/codex-icons package. See the usage documentation for more information. | |
Overview β
When to use Card β
Use the Card component when you need to present individual pieces of information such as articles. Use them to create lists, grids or as standalone elements in the page. Cards can be clickable and offer a way to navigate to the content they represent.
Avoid using Cards when you have to display extensive content, multiple elements, or group unrelated topics together. In such cases, consider using a different component or layout.
About Card β
Card includes the following elements.
Visual element (optional) β
They may include a Thumbnail or an Icon as a visual representation of its content.
Use a Thumbnail when you intend to showcase articles and their associated images.
Use an Icon to help users quickly identify and associate Cards with specific actions or topics.
Image size and layout β
When using an image, consider what size and layout works best for your use case.
- Use an image at the start when recognizing the image first feels most important, like in an article card.
- Use an image at the end when the image is more supplementary to the text, like in a "Did you know?" card.
- Use a small image when space is limited and it feels more important to show more cards at a time.
- Use a large image when space allows or when recognizing the image at a glance feels important.
- Avoid using multiple sizes and/or layouts in a single collection of cards.
Title β
A concise and descriptive title provides a brief description of the Card content.
Description β
A description below the title provides more information about the element represented by the Card. If the Card itself is not a link, you can include links in the description.
Ensure that the content within the Card remains concise and pertinent.
Avoid overcrowding the Card with excessive content or unrelated topics.
Supporting text (optional) β
Supporting text can be included to provide additional context about the Cardβs content. If the Card itself is not a link, you can include links in the supporting text.
Link (optional) β
As long as links are not included in the contents of the Card, the Card itself can be made a link.
Examples β
Basic usage β
With link β
Developer notes
Adding the url prop will make the root element of the Card an anchor element.
Media β
A Card can have either a thumbnail or an icon. For horizontal card layouts, card text will be aligned to the top of the media, unless there is only a title, which will be aligned to the center of the media.
- Always use the same media for each Card in a group.
With Icon β
With Thumbnail β
Larger image β
Use the block-start thumbnail position to show a larger image.
Developer notes
A default aspect ratio of 16/9 is applied to the image. Override the aspect ratio on the cdx-thumbnail__image and cdx-thumbnail__placeholder elements if needed.
Media and title only β
Card groups β
Cards will often be displayed in groups. The height and width of cards can be customized as needed, and when multiple cards are aligned together, their heights should adjust to match the tallest card in the set.
Cards are styled with a visual outline by default for further containment and separation.
Nearby Pages
Developer notes
There are two considerations for Card groups:
- Layout: Layout styles for groups of Cards, e.g. margins or grid layout, must be added by the application. The example above adds some simple layout styles to a group of Cards. Consider using flexbox or CSS grid to lay out Cards consistently.
- Media consistency: As shown above, adding a
thumbnailprop will display the Thumbnail. For groups of Cards, you may want to display a Thumbnail for each Card if available, and otherwise display a placeholder. To enable this behavior, add theforceThumbnailprop, as demonstrated below. The third item has no Thumbnail and display a placeholder Icon instead.
Divider β
Cards can be styled with a visual divider between them in a group for more subtle separation.
- Use a divider only for vertical groups of cards.
Changes to review
Help keep Wikipedia reliable by selecting an edit and reviewing the change.
No separation β
Cards can be styled without any visual separation.
- Use space only to separate cards in a group.
Policies and guidelines
Check what is acceptable and expected on Wikipedia.
Technical implementation β
Vue usage β
Props β
| Prop name | Description | Type | Values | Default |
|---|---|---|---|---|
url | If provided, the Card will be a link to this URL. | string | - | '' |
icon | Icon displayed at the start of the Card. | Icon | - | '' |
thumbnail | Thumbnail image data for the Card. | Thumbnail|null | - | null |
forceThumbnail | Option to force a thumbnail layout. When set to true, the Card will display a Thumbnail. If a thumbnail prop was also provided, the thumbnail image will display. Otherwise, a placeholder icon will display.This is useful when displaying groups of Cards when some of the cards have thumbnail images but some do not. forceThumbnail will provide a consistent layout for that group.Note that this prop is not needed to display a thumbnail image: if the thumbnail prop is provided, it will display. This prop is only needed to enable the display of the thumbnail placeholder icon when the thumbnail prop is not provided. | boolean | - | false |
customPlaceholderIcon | Optional custom icon for the placeholder shown when forceThumbnail is true but no thumbnail is provided.Defaults to the default placeholder icon set in the Thumbnail component. | Icon | - | undefined |
thumbnailPosition | Position of the thumbnail relative to the card container. - inline-start (default): thumbnail before the text (left in LTR, right in RTL). - inline-end: thumbnail after the text. - block-start: thumbnail spans the full width of the card, above the text. | CardThumbnailPosition | 'inline-start', 'inline-end', 'block-start' | 'inline-start' |
thumbnailSize | Size of the thumbnail. Only applies when thumbnailPosition is inline-start or inline-end; has no effect when thumbnailPosition is block-start, where the thumbnail already spans the full card width regardless of this prop.- small (default): 3rem (48px). - large: 6rem (96px). | CardThumbnailSize | 'small', 'large' | 'small' |
separation | Visual separation style of the card. - outline (default): border around the entire card β the original Card appearance. - divider: border and padding along the bottom edge only. - none: no border or padding. | CardSeparation | 'outline', 'divider', 'none' | 'outline' |
Slots β
| Name | Description | Bindings |
|---|---|---|
| title | Card title | |
| description | Card description | |
| supporting-text | Short supporting text |
CSS-only version β
Markup structure β
With link β
To make the entire Card a link, use an <a> element and include the class cdx-card--is-link.
With media β
Image β
To add an image, add the following markup:
- A
<span>with the classescdx-card--thumbnailandcdx-thumbnail - Inside of that
<span>, add an empty<span>element with the classcdx-thumbnail__image, plus a custom CSS class that you can use to add abackground-imagerule (alternately, you can add thebackground-imagerule via astyleattribute on this<span>)
Refer to the CSS-only Thumbnail documentation for more examples.
Icon β
To add an Icon, add a <span> element with the class cdx-card__icon, plus a custom class that you can use to add a CSS-only Icon.
Card groups β
Refer to the documentation above for UX guidelines.
Nearby Pages
Golden Gate National Recreation AreaU.S. National Recreation Area surrounding San Francisco Bay Area Distance: 170m Internet ArchiveAmerican non-profit organization providing archives of digital media since 1996 Distance: 300m Green Apple Books & MusicBookstore in San Francisco Distance: 350mKeyboard navigation β
| Key | Function |
|---|---|
| Tab | If the Card is interactive, it places the focus on the Card. If a non-interactive Card contains a link, this key places the focus in that link. When the focus is placed within an interactive Card or within the link of a non-interactive Card, it moves the focus to the next interactive element in tab order. |
| Shift + Tab | It moves the focus to the previous interactive element. |
| Enter | If the focus is on an interactive Card, it will open its hyperlink. When the focus is on a link within a Card, it will open the link. |