Display components
These components show content and status: they do not take input. Each one is a page element that looks right with no styling of your own, in the default shadcn design. Every example below is live, so you can see each variant as the visitor does.
All of these restyle only while the page has design = "shadcn", which is the default. With design = "none" they still produce the same structure and the same accessibility attributes, just without the look. All the styles sit in :where(), so any style you write yourself wins without a fight.
Cards and badges
card (Persian: کارت)
A framed block for a group of related content. It is made of parts: card header holds the card title, the card description and an optional card action that sits at the end of the header, then come card content and card footer. Every part is optional.
page:
margin = 16
box:
max width = 360
card:
card header:
card title:
content = "Team plan"
end
card description:
content = "Billed monthly"
end
card action:
badge:
variant = "secondary"
content = "Popular"
end
end
end
card content:
paragraph:
content = "Ten seats, unlimited projects and priority support."
end
end
card footer:
button:
content = "Choose plan"
end
end
end
end
endAdd class = "border-b" to the header, or class = "border-t" to the footer, for a divider line.
badge (Persian: نشان)
A small label for a status, a count or a tag. With url it becomes a link and gets hover styles.
page:
margin = 16
box:
layout = "row"
wrap = true
gap = 8
badge:
content = "Default"
end
badge:
variant = "secondary"
content = "Secondary"
end
badge:
variant = "destructive"
content = "Destructive"
end
badge:
variant = "outline"
content = "Outline"
end
badge:
variant = "ghost"
content = "Ghost"
end
badge:
variant = "link"
content = "Link"
end
badge:
url = "#"
variant = "outline"
content = "As a link"
end
end
end| Attribute | Values |
|---|---|
variant | default, secondary, destructive, outline, ghost, link |
url | Makes the badge a link. |
Messages and dividers
alert (Persian: هشدار)
A callout that draws attention to a message. It has role="alert", so screen readers announce it. The parts are alert title, one line, and alert description, in a muted colour. A direct svg child of the alert becomes its icon.
page:
margin = 16
box:
gap = 12
max width = 480
alert:
alert title:
content = "Heads up"
end
alert description:
content = "You can add components to your page with the alert element."
end
end
alert:
variant = "destructive"
alert title:
content = "Payment failed"
end
alert description:
content = "Check your card details and try again."
end
end
end
end| Attribute | Values |
|---|---|
variant | default, destructive |
separator (Persian: جداکننده)
A thin line that divides content. Use orientation = "vertical" between items of a row. The plain line element (HTML hr) gets the same look and keeps its margins.
page:
margin = 16
box:
max width = 360
gap = 8
paragraph:
content = "Above the separator"
end
separator:
end
box:
layout = "row"
gap = 12
height = 24
align = "center"
span:
content = "Blog"
end
separator:
orientation = "vertical"
end
span:
content = "Docs"
end
separator:
orientation = "vertical"
end
span:
content = "Source"
end
end
line:
end
paragraph:
content = "Below the line"
end
end
end| Attribute | Values |
|---|---|
orientation | horizontal (default), vertical |
Progress and loading
progress (Persian: پیشرفت)
A bar that shows how far a task has come. Give it value and max. Without a value the bar is indeterminate and plays an animation, which is right when you do not know how long it takes.
page:
margin = 16
box:
max width = 360
gap = 12
progress:
value = 0
max = 100
end
progress:
value = 40
max = 100
end
progress:
value = 100
max = 100
end
progress:
end
end
endmeter (Persian: سنجه)
A gauge for a value inside a known range, such as disk use. It is not for progress. low, high and optimum split the range into zones, and the colour of the bar tells which zone the value is in. Here the best value is 100, so 90 is good, 50 is so so and 15 is bad.
page:
margin = 16
box:
max width = 360
gap = 12
meter:
min = 0
max = 100
low = 30
high = 70
optimum = 100
value = 90
end
meter:
min = 0
max = 100
low = 30
high = 70
optimum = 100
value = 50
end
meter:
min = 0
max = 100
low = 30
high = 70
optimum = 100
value = 15
end
end
end| Attribute | Meaning |
|---|---|
value | The current value. |
min, max | The range. |
low, high | Where the low and the high zones start. |
optimum | The best value, which decides what counts as good. |
skeleton (Persian: اسکلت)
A grey placeholder that pulses while the real content loads. Set its size with width and height, and shape it with radius, here a circle for an avatar.
page:
margin = 16
box:
layout = "row"
gap = 12
align = "center"
skeleton:
width = 48
height = 48
radius = 999
end
box:
gap = 8
skeleton:
width = 240
height = 16
end
skeleton:
width = 180
height = 16
end
end
end
endspinner (Persian: چرخنده)
A small rotating icon for work in progress. It has role="status", takes the colour of the text around it, and fits inside a button. Its content is the label for screen readers and defaults to "Loading".
page:
margin = 16
box:
layout = "row"
gap = 16
align = "center"
spinner:
end
button:
variant = "outline"
spinner:
end
content = "Please wait"
end
spinner:
content = "Saving"
end
end
endAvatars and ratios
avatar (Persian: آواتار)
A round picture of a person. Put an avatar image and an avatar fallback inside. The fallback, usually initials, shows under the image and stays visible when the image is missing or fails to load, as in the fourth avatar. size is sm, default or lg, which are 24, 32 and 40 pixels. An avatar badge adds a status dot, avatar group overlaps several avatars, and avatar group count is the bubble that says how many more there are.
page:
margin = 16
box:
gap = 16
box:
layout = "row"
gap = 12
align = "center"
avatar:
size = "sm"
avatar fallback:
content = "SM"
end
end
avatar:
avatar fallback:
content = "AB"
end
end
avatar:
size = "lg"
avatar fallback:
content = "LG"
end
end
avatar:
avatar image:
url = "missing.png"
alt = "Missing"
end
avatar fallback:
content = "FB"
end
avatar badge:
end
end
end
avatar group:
avatar:
avatar fallback:
content = "AL"
end
end
avatar:
avatar fallback:
content = "BO"
end
end
avatar:
avatar fallback:
content = "CY"
end
end
avatar group count:
content = "+3"
end
end
end
endaspect ratio (Persian: نسبت تصویر)
A box that keeps a fixed shape whatever its width. ratio is written as a string such as "16/9" or "1/1". Images and videos inside it are cropped to fill it. The ratio is set inline, so it works with any design.
page:
margin = 16
box:
layout = "row"
gap = 16
align = "start"
box:
width = 240
aspect ratio:
ratio = "16/9"
box:
height = 100%
background = "#93c5fd"
align = "center"
justify = "center"
span:
content = "16/9"
end
end
end
end
box:
width = 120
aspect ratio:
ratio = "1/1"
box:
height = 100%
background = "#86efac"
align = "center"
justify = "center"
span:
content = "1/1"
end
end
end
end
end
endTables and text
table (Persian: جدول)
The ordinary table with its header, main, footer, row, column and caption elements, now styled: light dividers, a hover tint on rows and a muted footer. A row with selected = true gets the muted background. The table is wrapped in a container that scrolls sideways when it is too wide for the screen, so nothing about how you write it changes.
page:
margin = 16
box:
max width = 460
table:
caption:
content = "Last orders"
end
header:
row:
column:
content = "Order"
end
column:
content = "Status"
end
column:
content = "Total"
end
end
end
main:
row:
column:
content = "#1001"
end
column:
content = "Paid"
end
column:
content = "$25"
end
end
row:
selected = true
column:
content = "#1002"
end
column:
content = "Pending"
end
column:
content = "$40"
end
end
row:
column:
content = "#1003"
end
column:
content = "Paid"
end
column:
content = "$15"
end
end
end
footer:
row:
column:
content = "Total"
end
column:
end
column:
content = "$80"
end
end
end
end
end
endtypography (Persian: نگارش)
A container that gives the text inside the shadcn look: heading levels 1 to 4, paragraph, block quote, list and code. Four classes change a paragraph: lead for an introduction, large, small and muted. Pages that do not use typography keep the plain browser defaults.
page:
margin = 16
box:
max width = 520
typography:
heading:
level = 1
content = "The garden"
end
paragraph:
class = "lead"
content = "A short note about growing things."
end
heading:
level = 2
content = "Soil first"
end
paragraph:
content = "Good soil holds water and lets roots breathe."
end
code:
content = "compost.add(spring)"
end
block quote:
content = "A garden is never finished."
end
list:
item:
content = "Water early"
end
item:
content = "Mulch in summer"
end
end
paragraph:
class = "small"
content = "Small print"
end
paragraph:
class = "muted"
content = "Muted text"
end
end
end
endEmpty states and entries
empty (Persian: خالی)
The screen to show when there is nothing to list yet. The parts are empty header, empty media, empty title, empty description and empty content for the call to action. empty media takes variant = "icon" for a small muted square that holds an icon or a letter.
page:
margin = 16
box:
max width = 420
empty:
empty header:
empty media:
variant = "icon"
span:
content = "+"
end
end
empty title:
content = "No projects yet"
end
empty description:
content = "Create your first project to get started."
end
end
empty content:
button:
content = "New project"
end
end
end
end
endentry (Persian: مدخل)
A row with a picture, a title, a description and actions, for lists of people, files or settings. It is shadcn's Item. In Salam item already means a list item, so this one is called entry. Wrap several in an entry group. With url the whole entry is a link with a hover tint. The description is cut after two lines. Inside, entry media holds the picture, entry content the entry title and entry description, and entry header and entry footer add a row above or below.
page:
margin = 16
box:
max width = 440
entry group:
entry:
entry media:
variant = "icon"
span:
content = "A"
end
end
entry content:
entry title:
content = "Default entry"
end
entry description:
content = "The plain look, with an icon."
end
end
entry actions:
button:
size = "sm"
variant = "outline"
content = "Open"
end
end
end
entry:
variant = "outline"
entry content:
entry title:
content = "Outline entry"
end
entry description:
content = "Has a border."
end
end
end
entry:
variant = "muted"
size = "sm"
entry content:
entry title:
content = "Muted and small"
end
end
end
entry:
url = "#"
variant = "outline"
entry content:
entry title:
content = "A whole entry as a link"
end
end
end
entry:
entry header:
entry title:
content = "Header, separator and footer"
end
end
entry separator:
end
entry content:
entry description:
content = "The body sits between them."
end
end
entry footer:
entry description:
content = "Footer note"
end
end
end
end
end
end| Element or attribute | Values |
|---|---|
entry variant | default, outline, muted |
entry size | default, sm |
entry media variant | default, icon, image |
| Other parts | entry content, entry title, entry description, entry actions, entry header, entry footer, entry separator |
Navigation and scrolling
breadcrumb (Persian: مسیر)
The trail that shows where the visitor is. Build it from breadcrumb item with a link inside, breadcrumb separator, breadcrumb ellipsis for hidden levels and, last, breadcrumb page for the current page, which is marked with aria-current. The separator is a chevron, mirrored in right to left pages, or the content you give it, like the slash above.
page:
margin = 16
breadcrumb:
breadcrumb item:
link:
url = "#"
content = "Home"
end
end
breadcrumb separator:
end
breadcrumb ellipsis:
end
breadcrumb separator:
end
breadcrumb item:
link:
url = "#"
content = "Components"
end
end
breadcrumb separator:
content = "/"
end
breadcrumb page:
content = "Breadcrumb"
end
end
endpagination (Persian: صفحه بندی)
Links to the pages of a long list. Use pagination link for a number, with active = true for the current one, pagination previous and pagination next at the ends, and pagination ellipsis for skipped numbers. The default labels are "Previous" and "Next", and content replaces them. The arrows turn around in right to left pages.
page:
margin = 16
pagination:
pagination previous:
url = "#"
end
pagination link:
url = "#"
content = "1"
end
pagination link:
url = "#"
active = true
content = "2"
end
pagination link:
url = "#"
content = "3"
end
pagination ellipsis:
end
pagination next:
url = "#"
content = "Next page"
end
end
endscroll area (Persian: ناحیه پیمایش)
A box that scrolls inside the page, with thin rounded scrollbars. Give it a height or width, otherwise it grows with its content and has nothing to scroll.
page:
margin = 16
box:
layout = "row"
gap = 16
scroll area:
height = 120
width = 220
paragraph:
content = "Line 1. Scroll down to read the rest."
end
paragraph:
content = "Line 2"
end
paragraph:
content = "Line 3"
end
paragraph:
content = "Line 4"
end
paragraph:
content = "Line 5"
end
paragraph:
content = "Line 6"
end
paragraph:
content = "Line 7"
end
paragraph:
content = "Line 8"
end
end
scroll area:
orientation = "horizontal"
width = 220
box:
width = 600
height = 60
background = "#93c5fd"
paragraph:
content = "A wide strip: scroll sideways."
end
end
end
end
end| Attribute | Values |
|---|---|
orientation | vertical, horizontal, both |
Practice
- Build a pricing card with a badge in the
card actionand a button in the footer. - Show a
skeletonlist of three rows, then think about what real content would replace it. - Make a file list from an
entry groupwith an icon, a title, a size and an open button in each entry.