Cards
Displays content structured as one or more cards.
Usage
The Cards component can be used to display various types of content (other components) in a card-based layout. It can be used to display information, images, audio, videos, and form components.
Anatomy
In the screenshot above, we see a Cards component with 4 cards.
- The first card has a title, description, and uses an Image component to display an image as media.
- The second card has a title, description, and uses an Audio component to display an audio clip as media.
- The third card has a title, description, and uses a Video component to display a video as media.
- The fourth card has a title, description, and uses a Checkboxes component to display a confirmation checkbox below the description.
Visually, a card will typically display content in this order:
- At the top, a
media
component (e.g., image, video, audio clip) is displayed if specified (incards[0].media
). You can also change the media position to be displayed at the bottom by settingmediaPosition
tobottom
on the component. - Below the media, the title is displayed if specified (in
cards[0].title
). - Below the title, the description is displayed if specified (in
cards[0].description
). - Below the description, the content of the card is displayed if specified (in
cards[0].children
). - Below the content, any text specified in
cards[0].footer
is displayed. - At the bottom, any
media
component is displayed if specified andmediaPosition
is set tobottom
.
Style
This component has several properties to control its appearance. Experiment with these settings to achieve a consistent look that complements both form and media components within the cards.
color
can be set on the component to control the background color of the cards. You can choose betweenneutral
andsubtle
.minWidth
is used to determine the minimum width of each card. The default value if not specified is250px
, and this will determine how many cards can be on a row. In addition topx
, you can also userem
and%
to specify the width.minMediaHeight
is used to determine the minimum height of components specified inmedia
(e.g., image, video, audio clip). The default value is150px
. Here too, you can usepx
,rem
, and%
to specify the height.
Properties
The following is a list of available properties for Cards.
We are currently updating how we implement components. The list of properties may therefore be somewhat inaccurate.
Property | Type | Description |
---|---|---|
mediaPosition | string | Determines the position of the media component. Can be top or bottom . Default is top . |
minMediaHeight | string | Determines the minimum height of components specified in media (e.g., image, video, audio clip). Default is 150px . |
minWidth | string | Determines the minimum width of each card. Default is 250px . |
color | string | Determines the background color of the cards. Can be neutral or subtle . |
cards | array | An array of cards to display. |
cards[0].title | string | The title of the card. |
cards[0].description | string | The description of the card. |
cards[0].footer | string | The footer text of the card. |
cards[0].media | string | The ID of a media component to display on the top/bottom of the card. |
cards[0].children | array | An array of IDs of components to display in the card. |
Configuration
We are currently updating Altinn Studio with more configuration options!
The documentation is updated continuously, but there may be more settings available than described here and some settings may be in beta.
Add component
You can add a component in Altinn Studio Designer by dragging it from the component list to the page area.
When you select the component, the settings panel for it will be displayed.
Basic component:
App/ui/layouts/{page}.json
{
"$schema": "https://altinncdn.no/toolkits/altinn-app-frontend/4/schemas/json/layout/layout.schema.v1.json",
"data": {
"layout": [
{
"id": "myCards",
"type": "Cards",
"minWidth": "250px",
"minMediaHeight": "150px",
"mediaPosition": "top",
"color": "subtle",
"cards": [
{
"title": "Audio file",
"description": "This can also be an ID for a text resource",
"media": "myAudio"
},
{
"title": "cards.video.title",
"description": "cards.video.description",
"media": "myVideo"
},
{
"title": "With components and footer, but without media",
"description": "Example text",
"children": ["myCheckboxes"],
"footer": "Example text"
}
]
}
]
}
}