Content presentation – Card
Use a card to visually group related content and actions to help users do what they need to more quickly.
When to use a card
Use a card to visually group related content and actions to help users do what they need to more quickly. You can group several cards together.
If you are grouping cards to create a hub page (sometimes called a landing page), use the hub page pattern.
When not to use a card
Do not use a card to highlight content on a page of long form content.
Before using a card, consider using:
- the care card pattern to help users decide when and where to get care
- details
- an expander
- inset text
- tabs
- a warning callout
How to use a card
There are two types of cards:
Both cards can be clickable or non-clickable.
A card can include different elements, such as:
- a heading
- text
- a link or links
You can also add an image or add actions. If you include a link, the link should mirror the heading of the page it links to.
For clickable cards, avoid wrapping the entire card in an anchor tag as this can be a difficult experience for screen reader users.
Keep the card short so it is easy to scan for relevant and actionable information.
Primary card
Primary cards are more visually prominent than secondary cards.
Primary card clickable
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Primary card with chevron
The chevron icon on this primary card makes it even more prominent.
There is only a clickable version of this card.
Read about how to use primary cards with chevrons in the hub page pattern.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Primary card non-clickable
Use the non-clickable card when you are using more than 1 link.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Secondary card
The secondary card has less visual impact than the primary cards.
When used with other cards, use the secondary card to group less important content or actions.
Secondary card clickable
This card is also used in the hub page pattern.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Secondary card non-clickable
Use the non-clickable card when you have more than 1 link in the content.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Adding an image
Only use cards with images if you have evidence that they help your users, for example, where you can show that they motivate users.
Images in a card will be displayed above the heading and text. The image is set as a decorative image by default, with the alternative text being null.
Image card clickable
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Image card non-clickable
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Adding actions
You can add links for 1 or more actions to a card. They show below the heading on small screens and right-aligned on bigger screens.
Card actions cannot be used on clickable cards.
They can be used in summary cards.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Add a short, relevant and unique card heading which identifies what the card contains. When a screen reader reads out a card action, it also reads out the card heading, making each action link unique.
Write link text that makes it clear what will happen when you click the action. Keep it short and do not add more than 3 actions.
Examples of card actions include:
- delete appointment
- edit appointment
- update issue
- approve application
- cancel order
If the card title includes the word "appointment", for example, you may only need the words "edit" or "delete" in the link text.
If a card action cannot easily be undone or might have serious consequences, consider adding a warning or asking the user for confirmation.
Grouping cards
You can group multiple cards to show a collection of related topics or highlight key information and figures.
If you are grouping cards to create a hub page (sometimes called a landing page), use the hub page pattern.
Card width
We define the width of the cards using the grid system. For example, nhsuk-grid-column-one-half is used to make the cards half width.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
For thirds, use nhsuk-grid-column-one-third.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
When using thirds or quarters, check your content on smaller screens as the cards become narrow. Avoid adding paragraphs of text that will become hard to read.
For quarters, use nhsuk-grid-column-one-quarter.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Accessibility
Heading level and size
Use headings correctly to reflect the page structure. If you need to, change the default h2 heading.
Here's an example of replacing the default h2 heading with an h3.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
You can change the size of the heading using heading typography styles.
When using Nunjucks, you can set the size of card headings using the size option, for example: size: "s". You can use sizes xxs, xs, s, m, l, xl.
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work. These are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the card. |
| heading | object | Required. Heading of the card component. See macro options for heading. |
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Required.
Replaced by the heading.html option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.classes option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.size option.
|
|
heading |
integer |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.level option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.id option.
|
|
heading |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the heading.visuallyHiddenText option.
|
| href | string |
The card link href attribute.
|
| clickable | boolean |
If set to true, then the whole card will become a clickable card variant.
|
| variant | string |
Optional variant of card – "feature", "primary", "secondary", "warning", "non-urgent", "urgent" or "emergency".
|
| type | string |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant option.
|
| feature | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "feature" option.
|
| primary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "primary" option.
|
| secondary | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "secondary" option.
|
| warning | boolean |
Deprecated in 10.4.0 (see GitHub).
Replaced by the variant: "warning" option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.src option.
|
|
img |
string |
Deprecated in 10.3.0 (see GitHub).
Replaced by the image.alt option.
|
| image | object | Can be used to add an image to the card component. See macro options for image. |
| description | object |
Description to use within the card content. If descriptionHtml is provided, the description option will be ignored.
See macro options for description.
|
|
description |
string |
Deprecated in 10.6.0 (see GitHub).
Replaced by the description.html option.
|
| actions | object | Can be used to add actions to the card component. See macro options for actions. |
| caller | nunjucks-block |
Not strictly an option but supports the call block as an alternative to the html option. To use it, you will need to wrap the entire card component in a call block.
|
| classes | string | Classes to add to the card. |
| attributes | object | HTML attributes (for example data attributes) to add to the card. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the heading. |
| text | string |
Required.
If html is set, this is not required. Text for the heading.
|
| html | string |
Required.
If text is set, this is not required. HTML for the heading.
|
|
visually |
string | Optional visually hidden prefix used before the heading. |
| size | string |
Size of the heading – "xxs", "xs", "s", "m", "l" or "xl".
|
| level | integer |
Optional heading level. Defaults to 2.
|
| classes | string | Classes to add to the heading. |
| attributes | object | HTML attributes (for example data attributes) to add to the heading. |
| Name | Type | Description |
|---|---|---|
| src | string | Required. The URL of the image in the card. |
| alt | string | The alternative text of the image in the card. |
| html | string |
HTML to use for the image content. If html is provided, the src and alt options will be ignored.
|
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text to use within the card content. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within the card content. If html is provided, the text option will be ignored.
|
| classes | string | Classes to add to the card content. |
| attributes | object | HTML attributes (for example data attributes) to add to the card content. |
| Name | Type | Description |
|---|---|---|
| items | array | Array of actions as links for use in the card component. See macro options for actions items. |
| classes | string | Classes to add to the actions wrapper. |
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the action item. |
| text | string |
Required.
If html is set, this is not required. Text to use within each action item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use within each action item. If html is provided, the text option will be ignored.
|
|
visually |
string |
Actions rely on context from the surrounding content so may require additional accessible text. Text supplied to this option is appended to the end. Use html for more complicated scenarios.
|
| name | string |
Name for the action as a button. If href is provided, this has no effect.
|
| type | string |
Type of action as a button – "button", "submit" or "reset". Defaults to "submit" unless href is provided.
|
| value | string |
The value attribute for the action as a button. If href is provided, this has no effect.
|
| href | string |
Required.
The action href attribute. If set, the action will use an <a> tag automatically unless type is provided.
|
| classes | string | Classes to add to the action item. |
| attributes | object | HTML attributes (for example data attributes) to add to the action item. |
Research
We have tested cards on the NHS website, summary care record and NHS login help centre. We found that they helped users:
- scan for relevant information
- decide where to go next
Help us improve this guidance
Share insights or feedback and take part in the discussion. We use GitHub as a collaboration space. All the information on it is open to the public.
Feed back or share insights on GitHubRead more about how to feed back or share insights.
If you have any questions, get in touch with the service manual team.
Updates to this page
Updated: June 2026