Skip to main content
The card component creates a responsive grid where each element is a card that displays data. Cards automatically adjust to screen size and can include images, rich text, icons, and embedded content.

Basic Usage

SELECT 'card' AS component;
SELECT 'My Card' AS title, 'This is the card body' AS description;

Top-Level Properties

title
text
Text header at the top of the card grid
description
text
A short paragraph displayed below the title
description_md
text
A short paragraph below the title, formatted using Markdown
columns
integer
Number of columns in the grid. This is a hint - the grid adjusts dynamically to screen size.

Item Properties

title
text
required
Name of the card, displayed at the top
description
text
The body of the card (plain text only)
description_md
text
The body of the card in Markdown format with bold, italics, links, images, etc.
top_image
url
URL of an image to display at the top of the card
Muted text to display at the bottom of the card
Muted text at the bottom, formatted using Markdown
URL to navigate to when the card is clicked
URL to navigate to when the footer is clicked
icon
icon
Name of an icon to display on the card (from tabler-icons.io)
color
color
Color displayed on the left side to highlight the card
background_color
color
Background color of the card
active
boolean
Whether this card is “active” (displayed more prominently)
width
integer
Card width from 1 (smallest) to 12 (full-width). Default is 3 (4 cards per line).
embed
url
URL whose contents will be fetched and injected into the card. Use ?_sqlpage_embed for SQLPage files.
embed_mode
text
Set to ‘iframe’ to embed in an iframe instead of fetching content
style
text
Inline CSS styles for iframe embeds (e.g., “background-color: #FFFFFF”)

Examples

Simple Cards

SELECT 'card' AS component, 
       'Popular SQLPage features' AS title, 
       2 AS columns;

SELECT 
    'Download as spreadsheet' AS title,
    '?component=csv#component' AS link,
    'Using the CSV component, you can download your data as a spreadsheet.' AS description,
    'file-plus' AS icon,
    'green' AS color,
    'SQLPage can both [read](?component=form) and [write](?component=csv) **CSV** files.' AS footer_md;

SELECT 
    'Custom components' AS title,
    '/custom_components.sql' AS link,
    'Create your own components with HTML.' AS description,
    'code' AS icon,
    'orange' AS color;

Dashboard Cards

SELECT 'card' AS component, 4 AS columns;

SELECT 
    '**152** sales today' AS description_md,
    true AS active,
    'currency-euro' AS icon;

SELECT 
    '**13** new users' AS description_md,
    'user-plus' AS icon,
    'green' AS color;

SELECT 
    '**2** complaints' AS description_md,
    'alert-circle' AS icon,
    'danger' AS color,
    '?view_complaints' AS link,
    'red-lt' AS background_color;

SELECT 
    '**1** pending support request' AS description_md,
    'mail-question' AS icon,
    'warning' AS color;
SELECT 'card' AS component,
       'My favorite animals in pictures' AS title,
       3 AS columns;

SELECT 
    'Lynx' AS title,
    'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Lynx_lynx-4.JPG/640px-Lynx_lynx-4.JPG' AS top_image,
    'The **lynx** is a medium-sized **wild cat** native to Europe and Asia.' AS description_md,
    'star' AS icon;

SELECT 
    'Squirrel' AS title,
    'https://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Tamias-rufus-001.jpg/640px-Tamias-rufus-001.jpg' AS top_image,
    'The **chipmunk** is a small, striped rodent of the family Sciuridae.' AS description_md;

Variable Width Cards

SELECT 'card' AS component, 
       'Beautifully colored cards' AS title;

SELECT 
    'Red card' AS title,
    'red' AS color,
    'red-lt' AS background_color,
    'Penalty! You are out!' AS description,
    'play-football' AS icon;

SELECT 
    'Blue card' AS title,
    'blue' AS color,
    6 AS width,
    'blue-lt' AS background_color,
    'The Blue Card facilitates migration.' AS description,
    'currency-euro' AS icon;

SELECT 
    'Green card' AS title,
    'green' AS color,
    'green-lt' AS background_color,
    'Welcome to the USA!' AS description,
    'user-dollar' AS icon;

Cards with Embedded Content

SELECT 'card' AS component,
       'Card with embedded remote content' AS title,
       2 AS columns;

SELECT 
    'Embedded Chart' AS title,
    '/examples/chart.sql?_sqlpage_embed' AS embed;

SELECT 
    'Embedded Video' AS title,
    'https://www.youtube.com/embed/mXdgmSdaXkg' AS embed,
    'iframe' AS embed_mode,
    'accelerometer; autoplay; clipboard-write' AS allow,
    '350' AS height;

Notes

Cards automatically adapt to screen size. On mobile devices, cards stack vertically regardless of the columns setting.
Use the width property on individual cards for more control over layout than the global columns property.
When embedding external content without embed_mode="iframe", make sure the source is trusted as the content is injected directly into your page.

Build docs developers (and LLMs) love