Skip to content

Primer

Imitates: GitHub Primer · Primer React components and Primer CSS, primitives light/dark default themes Primer React 37 · Primer Primitives 10 · Pack id: primer · Selected by: pack="primer", import Primer, import PrimerReact, import GitHub · Default device: desktop (browser chrome)

140 own elements, plus 116 core elements in this pack's style. Each entry shows the element rendered with sample arguments (and, for the pack's own elements, each of its variants), the role it maps onto, its positional arguments, its defaults and variants.

Pack elements

ActionList

ActionList { ActionListItem("Edit", leadingVisual: "pencil", description:) ; ActionListDivider() }

role list · variants inset, full

First item
Second item
inset
First item
Second item
full
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { ActionList() { Text("First item"); Text("Second item") }.variant("inset"); Text("inset").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { ActionList() { Text("First item"); Text("Second item") }.variant("full"); Text("full").font(.caption).foregroundStyle(.secondary) }
}

ActionListDivider

role divider

Source
ActionListDivider()

ActionListGroup

ActionList.Group("Assignees") { items }

role section · arguments title

Title
First itemSecond item
Source
ActionListGroup("Title") { Text("First item"); Text("Second item") }

ActionListGroupHeading

role text · arguments content

Content
Source
ActionListGroupHeading("Content")

ActionListItem

ActionList.Item(label, leadingVisual:, trailingVisual: text, description:, selected:, variant: .danger)

role listitem · arguments title · variants default, danger

Title
default
Title
danger
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { ActionListItem("Title").variant("default"); Text("default").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { ActionListItem("Title").variant("danger"); Text("danger").font(.caption).foregroundStyle(.secondary) }
}

ActionListLinkItem

role listitem · arguments title

Title
Source
ActionListLinkItem("Title")

ActionMenu

ActionMenu("Sort", open: true) { ActionMenuItem("Newest", checked: true) … } — anchor + overlay

role menu · arguments label · defaults variant: "default"

Label
Source
ActionMenu("Label") { Button("Open"); Button("Save"); Divider(); Button("Close") }

ActionMenuButton

ActionMenu.Button (closed menu trigger)

role button · arguments label · defaults trailingIcon: "triangle-down", variant: "default"

Label
Source
ActionMenuButton("Label")

ActionMenuDivider

role divider

Source
ActionMenuDivider()

ActionMenuItem

Item inside an open ActionMenu: leadingVisual:, trailingVisual: "⌘C", checked:, variant: .danger

role menuitem · arguments label

Source
ActionMenuItem("Label")

Autocomplete

Autocomplete("Search users", text: "mo", open: true) { AutocompleteItem("mona") }

role select · arguments placeholder · defaults variant: "autocomplete"

Placeholder
Source
Autocomplete("Placeholder")

AutocompleteItem

role label · arguments title

Title
Source
AutocompleteItem("Title")

Avatar

Avatar("Mona Lin", image:, size: 20…64, square: true for orgs/bots)

role avatar · arguments name

AL
Source
Avatar("Ana Lima")

AvatarPair

Large avatar with a small one at the bottom right

role zstack

ContentAction
Source
AvatarPair() { Text("Content"); Button("Action") }

AvatarStack

Overlapping avatars: AvatarStack { Avatar … }

role hstack · defaults spacing: 0

ContentAction
Source
AvatarStack() { Text("Content"); Button("Action") }

AvatarToken

AvatarToken("mona", avatar: "Mona Lin")

role chip · arguments text

Text
Source
AvatarToken("Text")

Banner("Title", description:, variant: .info|.success|.warning|.critical|.upsell) { actions }

role alert · arguments title

Source
Banner("Title")

Blankslate

Blankslate("No issues", systemImage: "issue-opened", description:, border: true) { primary / secondary actions }

role emptystate · arguments title

Title
Source
Blankslate("Title")

BlobView

role code · arguments code

1let total = items.count
Source
BlobView("let total = items.count")

Blockquote

role text · arguments content

Content
Source
Blockquote("Content")

BorderBox

Box with border and rounded corners; header: title; children are rows (Box-row)

role card · arguments title · defaults variant: "borderbox"

Title
ContentAction
Source
BorderBox("Title") { Text("Content"); Button("Action") }

Box

Generic container (Box): style it with modifiers; children stack vertically

role vstack

ContentAction
Source
Box() { Text("Content"); Button("Action") }

BoxRow

A Box-row inside a BorderBox (bordered row)

role hstack · defaults spacing: 8

ContentAction
Source
BoxRow() { Text("Content"); Button("Action") }

BranchName

BranchName("feature/login") — monospace accent chip

role text · arguments content

Content
Source
BranchName("Content")

Breadcrumbs(items: ["acme", "rocket", "src"])

role breadcrumb · arguments items

Source
Breadcrumbs(["One", "Two", "Three"])

role link · arguments label

Label
Source
BreadcrumbsItem("Label")

Button

Button("Save", variant: .primary, size: .small|.medium|.large, leadingVisual: "plus", count: 3, trailingAction: "triangle-down")

role button · arguments label · defaults variant: "default" · variants default, primary, danger, invisible, link

Labeldefault
Labelprimary
Labeldanger
Labelinvisible
Labellink
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { Button("Label").variant("default"); Text("default").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Button("Label").variant("primary"); Text("primary").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Button("Label").variant("danger"); Text("danger").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Button("Label").variant("invisible"); Text("invisible").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Button("Label").variant("link"); Text("link").font(.caption).foregroundStyle(.secondary) }
}

ButtonGroup

Joined buttons: ButtonGroup { Button; IconButton }

role toolbar · defaults variant: "group"

Source
ButtonGroup() { Button("Save"); Button("Share") }

Checkbox

Checkbox("Require review", checked: true)

role checkbox · arguments label

Label
Source
Checkbox("Label")

CheckboxGroup

role vstack · defaults alignment: "leading", spacing: 8

ContentAction
Source
CheckboxGroup() { Text("Content"); Button("Action") }

CircleBadge

Round badge with an icon (systemImage:)

role avatar · arguments name

AL
Source
CircleBadge("Ana Lima")

CodeView

Blob view: CodeView("…", language: "ts", highlight: [4], title: "src/app.ts")

role code · arguments code

1let total = items.count
Source
CodeView("let total = items.count")

CommentBox

role card · arguments title · defaults variant: "comment"

Title
ContentAction
Source
CommentBox("Title") { Text("Content"); Button("Action") }

ConfirmationDialog

ConfirmationDialog("Delete branch?", buttons: ["Cancel", "Delete"], destructive: "Delete") { body }

role dialog · arguments title · defaults variant: "confirmation"

Source
ConfirmationDialog("Title") { Text("Content"); Button("Action") }

Counter

Counter(12) or Counter(count: 3, scheme: .primary)

role badge · arguments text · defaults variant: "secondary" · variants primary, secondary

Textprimary
Textsecondary
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { Counter("Text").variant("primary"); Text("primary").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Counter("Text").variant("secondary"); Text("secondary").font(.caption).foregroundStyle(.secondary) }
}

CounterLabel

role badge · arguments text · defaults variant: "secondary" · variants primary, secondary

Textprimary
Textsecondary
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { CounterLabel("Text").variant("primary"); Text("primary").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { CounterLabel("Text").variant("secondary"); Text("secondary").font(.caption).foregroundStyle(.secondary) }
}

DataTable

DataTable(columns: […], rows: [[…]]) — bordered Primer table; title: and footer:

role table

NameStatus
Ana LimaActive
Ben OkaforAway
Source
DataTable(columns: ["Name", "Status"], rows: [["Ana Lima", "Active"], ["Ben Okafor", "Away"]])

Details

Details/summary disclosure

role accordion · arguments title

Title
Source
Details("Title") { Text("Content"); Button("Action") }

Dialog

Dialog("Title", subtitle:) { body } footer: { Button … }

role dialog · arguments title · defaults closable: True

Source
Dialog("Title") { Text("Content"); Button("Action") }

DiffCode

Code cell of a DiffLine (monospace, keeps spaces)

role text · arguments content

Content
Source
DiffCode("Content")

DiffFile

File in a diff: DiffFile("src/app.ts", subtitle: "+12 −3") { DiffHunk(…); DiffLine(…) } action: { … }

role card · arguments title · defaults variant: "diff"

Title
ContentAction
Source
DiffFile("Title") { Text("Content"); Button("Action") }

DiffHunk

@@ hunk header row: DiffHunk { DiffNumber(""); DiffNumber(""); DiffCode("@@ -10,6 +10,8 @@") }

role hstack · defaults spacing: 0, variant: "hunk"

ContentAction
Source
DiffHunk() { Text("Content"); Button("Action") }

DiffLine

One diff row: DiffLine(variant: .addition) { DiffNumber(""); DiffNumber("14"); DiffCode("+ …") }

role hstack · defaults spacing: 0, variant: "context" · variants context, addition, deletion

ContentAction
context
ContentAction
addition
ContentAction
deletion
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { DiffLine() { Text("Content"); Button("Action") }.variant("context"); Text("context").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { DiffLine() { Text("Content"); Button("Action") }.variant("addition"); Text("addition").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { DiffLine() { Text("Content"); Button("Action") }.variant("deletion"); Text("deletion").font(.caption).foregroundStyle(.secondary) }
}

DiffNumber

Line-number gutter cell of a DiffLine

role text · arguments content

Content
Source
DiffNumber("Content")

Disclosure

role accordion · arguments title

Title
Source
Disclosure("Title") { Text("Content"); Button("Action") }

Flash

Flash("Saved", variant: .default|.success|.warning|.danger, full: true)

role alert · arguments title

Source
Flash("Title")

FormControl

FormControl { FormControlLabel("Name"); TextInput(…); FormControlCaption("…") }

role vstack · defaults alignment: "stretch", spacing: 4

ContentAction
Source
FormControl() { Text("Content"); Button("Action") }

FormControlCaption

FormControl.Caption (12px muted)

role text · arguments content

Content
Source
FormControlCaption("Content")

FormControlLabel

FormControl.Label (14px semibold)

role text · arguments content

Content
Source
FormControlLabel("Content")

FormControlValidation

FormControl.Validation("…", variant: .error|.success)

role text · arguments content

Content
Source
FormControlValidation("Content")

Global header: Header("acme / rocket", logo: "cube", search: "Type / to search", avatar: "Mona") { actions }

role appbar · arguments title

Source
Header("Title") { Text("Content"); Button("Action") }

HeaderItem

Header.Item

role hstack · defaults spacing: 8

ContentAction
Source
HeaderItem() { Text("Content"); Button("Action") }

Header.Link

role link · arguments label

Label
Source
HeaderLink("Label")

Heading

Heading("Title", variant: .large | .medium | .small)

role text · arguments content · defaults style: "titleMedium" · variants large, medium, small

Contentlarge
Contentmedium
Contentsmall
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { Heading("Content").variant("large"); Text("large").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Heading("Content").variant("medium"); Text("medium").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Heading("Content").variant("small"); Text("small").font(.caption).foregroundStyle(.secondary) }
}

IconButton

IconButton("kebab-horizontal", variant: .invisible, "aria-label" via label:)

role button · arguments icon · defaults iconOnly: True, variant: "default" · variants default, primary, danger, invisible, link

default
primary
danger
invisible
link
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { IconButton("star").variant("default"); Text("default").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { IconButton("star").variant("primary"); Text("primary").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { IconButton("star").variant("danger"); Text("danger").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { IconButton("star").variant("invisible"); Text("invisible").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { IconButton("star").variant("link"); Text("link").font(.caption).foregroundStyle(.secondary) }
}

InlineMessage

InlineMessage("Check your token", variant: .critical|.warning|.success|.unavailable)

role text · arguments content

Content
Source
InlineMessage("Content")

IssueLabel

Repository label: IssueLabel("bug", color: .red) — tinted pill (named colours)

role badge · arguments text · defaults color: "gray", variant: "issue"

Text
Source
IssueLabel("Text")

IssueLabelToken

role badge · arguments text · defaults color: "gray", variant: "issue"

Text
Source
IssueLabelToken("Text")

Kbd

Keyboard key: Kbd("/")

role kbd · arguments keys

⌘K
Source
Kbd(["⌘", "K"])

Label

Label("Public", variant: .success, size: .small|.large)

role badge · arguments text · defaults variant: "default" · variants default, primary, secondary, accent, success, attention, severe, danger, done, sponsors

Textdefault
Textprimary
Textsecondary
Textaccent
Textsuccess
Textattention
Textsevere
Textdanger
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { Label("Text").variant("default"); Text("default").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Label("Text").variant("primary"); Text("primary").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Label("Text").variant("secondary"); Text("secondary").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Label("Text").variant("accent"); Text("accent").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Label("Text").variant("success"); Text("success").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Label("Text").variant("attention"); Text("attention").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Label("Text").variant("severe"); Text("severe").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Label("Text").variant("danger"); Text("danger").font(.caption).foregroundStyle(.secondary) }
}

Link("Docs", muted: true) or variant: .muted

role link · arguments label, destination · variants default, muted

Labeldefault
Labelmuted
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { Link("Label").variant("default"); Text("default").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { Link("Label").variant("muted"); Text("muted").font(.caption).foregroundStyle(.secondary) }
}

LinkButton

A link styled as a Button

role button · arguments label · defaults variant: "default" · variants default, primary, danger, invisible, link

Labeldefault
Labelprimary
Labeldanger
Labelinvisible
Labellink
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { LinkButton("Label").variant("default"); Text("default").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { LinkButton("Label").variant("primary"); Text("primary").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { LinkButton("Label").variant("danger"); Text("danger").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { LinkButton("Label").variant("invisible"); Text("invisible").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { LinkButton("Label").variant("link"); Text("link").font(.caption).foregroundStyle(.secondary) }
}

Markdown

Rendered Markdown body (markdown-body): spacing 16, headings with rules

role vstack · defaults alignment: "leading", spacing: 16

ContentAction
Source
Markdown() { Text("Content"); Button("Action") }

NavList { NavListItem("General", leadingVisual: "gear").selected(); NavListGroup("Access") { … } }

role vstack · defaults alignment: "stretch", spacing: 2

ContentAction
Source
NavList() { Text("Content"); Button("Action") }

role divider

Source
NavListDivider()

NavList.Group("Code and automation") { items }

role section · arguments title

Title
First itemSecond item
Source
NavListGroup("Title") { Text("First item"); Text("Second item") }

role text · arguments content

Content
Source
NavListGroupHeading("Content")

NavList.Item(label, leadingVisual:, trailingVisual: count, selected:) — nested items = SubNav

role navitem · arguments label

Label
Source
NavListItem("Label")

Octicon

Octicon("git-branch", size: 16) — Octicon names are aliased

role icon · arguments name

Source
Octicon("star")

Overlay

Floating overlay surface

role card · arguments title · defaults variant: "overlay"

Title
ContentAction
Source
Overlay("Title") { Text("Content"); Button("Action") }

PageHeader { PageHeaderContextArea; PageHeaderTitleArea { PageHeaderTitle; PageHeaderActions }; PageHeaderDescription }

role vstack · defaults alignment: "stretch", spacing: 8

ContentAction
Source
PageHeader() { Text("Content"); Button("Action") }

PageHeaderActions

Right-aligned actions of the title row

role hstack · defaults spacing: 8

ContentAction
Source
PageHeaderActions() { Text("Content"); Button("Action") }

PageHeaderContextArea

Parent link / breadcrumbs above the title

role hstack · defaults spacing: 8

ContentAction
Source
PageHeaderContextArea() { Text("Content"); Button("Action") }

PageHeaderDescription

Muted metadata row under the title

role hstack · defaults spacing: 8

ContentAction
Source
PageHeaderDescription() { Text("Content"); Button("Action") }

PageHeaderLeadingAction

role hstack · defaults spacing: 4

ContentAction
Source
PageHeaderLeadingAction() { Text("Content"); Button("Action") }

PageHeaderLeadingVisual

role hstack · defaults spacing: 4

ContentAction
Source
PageHeaderLeadingVisual() { Text("Content"); Button("Action") }

PageHeaderNavigation

Holds an UnderlineNav under the header

role vstack · defaults alignment: "stretch", spacing: 0

ContentAction
Source
PageHeaderNavigation() { Text("Content"); Button("Action") }

Back link in the context area

role link · arguments label · defaults systemImage: "arrow-left"

Label
Source
PageHeaderParentLink("Label")

PageHeaderTitle

PageHeader.Title (variant: .large | .medium | .subtitle)

role text · arguments content · defaults style: "titleMedium" · variants large, medium, subtitle

Contentlarge
Contentmedium
Contentsubtitle
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { PageHeaderTitle("Content").variant("large"); Text("large").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { PageHeaderTitle("Content").variant("medium"); Text("medium").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { PageHeaderTitle("Content").variant("subtitle"); Text("subtitle").font(.caption).foregroundStyle(.secondary) }
}

PageHeaderTitleArea

Title row: leading visual, title, trailing visual, actions

role hstack · defaults spacing: 8

ContentAction
Source
PageHeaderTitleArea() { Text("Content"); Button("Action") }

PageHeaderTrailingAction

role hstack · defaults spacing: 4

ContentAction
Source
PageHeaderTrailingAction() { Text("Content"); Button("Action") }

PageHeaderTrailingVisual

role hstack · defaults spacing: 4

ContentAction
Source
PageHeaderTrailingVisual() { Text("Content"); Button("Action") }

PageLayout

PageLayout { PageLayoutHeader; PageLayoutContentRow { PageLayoutPane; PageLayoutContent } }

role vstack · defaults alignment: "stretch", spacing: 0

ContentAction
Source
PageLayout() { Text("Content"); Button("Action") }

PageLayoutContent

PageLayout.Content

role vstack · defaults alignment: "stretch", spacing: 16

ContentAction
Source
PageLayoutContent() { Text("Content"); Button("Action") }

PageLayoutContentRow

Row holding the pane and the content (pane on either side)

role hstack · defaults alignment: "top", spacing: 0

ContentAction
Source
PageLayoutContentRow() { Text("Content"); Button("Action") }

PageLayoutFooter

PageLayout.Footer

role vstack · defaults alignment: "stretch", spacing: 8

ContentAction
Source
PageLayoutFooter() { Text("Content"); Button("Action") }

PageLayoutHeader

PageLayout.Header

role vstack · defaults alignment: "stretch", spacing: 8

ContentAction
Source
PageLayoutHeader() { Text("Content"); Button("Action") }

PageLayoutPane

PageLayout.Pane (296px side column); divider: true draws the line

role vstack · defaults alignment: "stretch", spacing: 8

ContentAction
Source
PageLayoutPane() { Text("Content"); Button("Action") }

Pagination

Pagination(pageCount: 12, currentPage: 3) — Previous / pages / Next

role pagination

Source
Pagination()

Popover

Popover with caret

role card · arguments title · defaults variant: "popover"

Title
ContentAction
Source
Popover("Title") { Text("Content"); Button("Action") }

ProgressBar

ProgressBar(progress: 60) of 100

role progress · arguments value

Source
ProgressBar(60)

Radio

role radio · arguments label

Label
Source
Radio("Label")

RadioGroup

role radiogroup · arguments label

Label
FirstSecond
Source
RadioGroup("Label") { Radio("First", selected: true); Radio("Second") }

RelativeTime

RelativeTime("3 days ago") — muted, dotted hover underline

role text · arguments content

Content
Source
RelativeTime("Content")

SegmentedControl

SegmentedControl { SegmentedControlButton("Preview").selected(); … } or items:, selection:

role segmented · arguments items

OneTwoThree
Source
SegmentedControl(["One", "Two", "Three"])

SegmentedControlButton

SegmentedControl.Button("Raw", leadingIcon:, selected:)

role label · arguments title

Title
Source
SegmentedControlButton("Title")

SegmentedControlIconButton

SegmentedControl.IconButton(icon: "eye", ariaLabel via title:)

role label · arguments icon · defaults labelStyle: "iconOnly"

Source
SegmentedControlIconButton("star")

Select

Native select: Select(selection: "main") { SelectOption("main") }

role select · arguments placeholder

Placeholder
Source
Select("Placeholder")

SelectOption

role text · arguments content

Content
Source
SelectOption("Content")

SelectPanel

Filterable selection overlay: SelectPanel("Labels", open: true) { TextInput; ActionMenuItem(checked:) }

role menu · arguments label · defaults variant: "default"

Label
Source
SelectPanel("Label") { Button("Open"); Button("Save"); Divider(); Button("Close") }

SkeletonAvatar

role skeleton · defaults shape: "circle"

Source
SkeletonAvatar().frame(width: 160, height: 96)

SkeletonBox

role skeleton · defaults shape: "rectangle"

Source
SkeletonBox().frame(width: 160, height: 96)

SkeletonText

role skeleton · defaults lines: 1

Source
SkeletonText().frame(width: 160, height: 96)

Snippet

Clipboard-copy snippet (markdown code block)

role code · arguments code · defaults lineNumbers: False

let total = items.count
Source
Snippet("let total = items.count")

Spinner

Spinner(size: .small|.medium|.large)

role progress · defaults variant: "spinner"

Source
Spinner()

SplitPageLayout

SplitPageLayout { SplitPageLayoutPane; SplitPageLayoutContent } (settings pages)

role hstack · defaults alignment: "top", spacing: 0

ContentAction
Source
SplitPageLayout() { Text("Content"); Button("Action") }

SplitPageLayoutContent

SplitPageLayout.Content

role vstack · defaults alignment: "stretch", spacing: 16

ContentAction
Source
SplitPageLayoutContent() { Text("Content"); Button("Action") }

SplitPageLayoutPane

SplitPageLayout.Pane

role vstack · defaults alignment: "stretch", spacing: 8

ContentAction
Source
SplitPageLayoutPane() { Text("Content"); Button("Action") }

Stack

Stack (vertical, gap normal); use StackHorizontal or HStack for a row

role vstack · defaults alignment: "stretch", spacing: 16

ContentAction
Source
Stack() { Text("Content"); Button("Action") }

StackHorizontal

Stack with direction="horizontal"

role hstack · defaults spacing: 8

ContentAction
Source
StackHorizontal() { Text("Content"); Button("Action") }

StackItem

Stack.Item

role vstack

ContentAction
Source
StackItem() { Text("Content"); Button("Action") }

StateLabel

StateLabel("Open", status: .issueOpened | .issueClosed | .pullOpened | .pullMerged | .pullClosed | .draft, size: .small)

role badge · arguments text · defaults variant: "open" · variants issueOpened, issueClosed, issueClosedNotPlanned, issueDraft, pullOpened, pullClosed, pullMerged, pullQueued, draft, open, closed, merged, unavailable

TextissueOpened
TextissueClosed
TextissueClosedNotPlanned
TextissueDraft
TextpullOpened
TextpullClosed
TextpullMerged
TextpullQueued
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { StateLabel("Text").variant("issueOpened"); Text("issueOpened").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { StateLabel("Text").variant("issueClosed"); Text("issueClosed").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { StateLabel("Text").variant("issueClosedNotPlanned"); Text("issueClosedNotPlanned").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { StateLabel("Text").variant("issueDraft"); Text("issueDraft").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { StateLabel("Text").variant("pullOpened"); Text("pullOpened").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { StateLabel("Text").variant("pullClosed"); Text("pullClosed").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { StateLabel("Text").variant("pullMerged"); Text("pullMerged").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { StateLabel("Text").variant("pullQueued"); Text("pullQueued").font(.caption).foregroundStyle(.secondary) }
}

Joined pill links: SubNav { SubNavLink("Labels").selected() }

role toolbar · defaults variant: "subnav"

Source
SubNav() { Button("Save"); Button("Share") }

role button · arguments label · defaults variant: "subnav"

Label
Source
SubNavLink("Label")

TabNav

Boxed tabs (TabNav): TabNav(items: ["Write", "Preview"], selection: "Write")

role tabs · arguments items · defaults placement: "top", variant: "tabnav"

OneTwo
First tab
Source
TabNav(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }

role tab · arguments label

Source
TabNavLink("Label")

Table

role table

NameStatus
Ana LimaActive
Ben OkaforAway
Source
Table(columns: ["Name", "Status"], rows: [["Ana Lima", "Active"], ["Ben Okafor", "Away"]])

TableContainer

role vstack · defaults alignment: "stretch", spacing: 8

ContentAction
Source
TableContainer() { Text("Content"); Button("Action") }

TableSubtitle

role text · arguments content

Content
Source
TableSubtitle("Content")

TableTitle

role text · arguments content

Content
Source
TableTitle("Content")

Terminal

role code · arguments code · defaults variant: "terminal"

Terminal
let total = items.count
Source
Terminal("let total = items.count")

Text

Text("…", size: .small|.medium|.large, weight: .light|.normal|.medium|.semibold) · .foregroundStyle(.secondary)

role text · arguments content

Content
Source
Text("Content")

TextInput

TextInput("Find a file…", value:, leadingVisual: "search", size: .small|.medium|.large)

role textfield · arguments placeholder

Placeholder
Source
TextInput("Placeholder")

TextInputWithTokens

TextInputWithTokens("Add topics", selection: ["react", "css"])

role select · arguments placeholder

Placeholder
Source
TextInputWithTokens("Placeholder")

Textarea

Textarea("Leave a comment", value:, rows: 5)

role textfield · arguments placeholder · defaults kind: "multiline"

Placeholder
Source
Textarea("Placeholder")

Timeline

Timeline { TimelineItem("…", systemImage: "git-commit", time:) }

role timeline

Created
Shipped
Source
Timeline() { TimelineItem("Created"); TimelineItem("Shipped") }

TimelineBreak

role divider

Source
TimelineBreak()

TimelineComment

Issue/PR comment box: TimelineComment("mona commented 2 days ago", avatar: "Mona") { body } action: { … }

role card · arguments title · defaults variant: "comment"

Title
ContentAction
Source
TimelineComment("Title") { Text("Content"); Button("Action") }

TimelineItem

Timeline.Item(title, systemImage: octicon, time:, description:, status: .open|.closed|.merged|.done, variant: .condensed)

role timelineitem · arguments title · variants default, condensed

Title
default
Title
condensed
Source
HStack(alignment: .top, spacing: 16) {
  VStack(alignment: .leading, spacing: 4) { TimelineItem("Title").variant("default"); Text("default").font(.caption).foregroundStyle(.secondary) }
  VStack(alignment: .leading, spacing: 4) { TimelineItem("Title").variant("condensed"); Text("condensed").font(.caption).foregroundStyle(.secondary) }
}

ToggleSwitch

ToggleSwitch("Notifications", checked: true) — On/Off text, size: .small

role toggle · arguments label · defaults offText: "Off", onText: "On"

LabelOff
Source
ToggleSwitch("Label")

Token

Token("design", onRemove: true, size: .small|.medium|.large|.xlarge)

role chip · arguments text

Text
Source
Token("Text")

Tooltip

Tooltip("Copy", direction: .s) { IconButton }

role tooltip · arguments text · defaults placement: "top"

ContentActionText
Source
Tooltip("Text") { Text("Content"); Button("Action") }

TreeView

TreeView { TreeViewItem("src", folder: true) { TreeViewItem("index.ts", systemImage: "file") } }

role tree

Folder
File
Source
TreeView() { TreeItem("Folder") { TreeItem("File") } }

TreeViewItem

TreeView.Item(label, folder:, expanded:, leadingVisual:, current: true)

role treeitem · arguments label

Label
Source
TreeViewItem("Label")

TreeViewSubTree

role group

ContentAction
Source
TreeViewSubTree() { Text("Content"); Button("Action") }

Truncate

Single-line text cut with an ellipsis (maxWidth via .frame)

role text · arguments content

Content
Source
Truncate("Content")

UnderlineNav

UnderlineNav { UnderlineNavItem("Code", leadingVisual: "code", counter: 3).selected() }

role tabs · arguments items · defaults placement: "top", variant: "underline"

OneTwo
First tab
Source
UnderlineNav(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }

UnderlineNavItem

UnderlineNav.Item(label, leadingVisual:, counter:, selected:)

role tab · arguments label

Source
UnderlineNavItem("Label")

UnderlinePanels

Tabs with panels: UnderlinePanels { UnderlinePanelsTab("Code") { panel } }

role tabs · arguments items · defaults placement: "top", variant: "underline"

OneTwo
First tab
Source
UnderlinePanels(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }

UnderlinePanelsTab

role tab · arguments label

Source
UnderlinePanelsTab("Label")

Core vocabulary in this style

Accordion

role accordion · arguments title

Title
Source
Accordion("Title") { Text("Content"); Button("Action") }

Alert

role dialog · arguments title · defaults variant: "alert"

Source
Alert("Title") { Text("Content"); Button("Action") }

AppBar

role appbar · arguments title

Source
AppBar("Title") { Text("Content"); Button("Action") }

AreaChart

role chart · defaults kind: "area"

Source
AreaChart(values: [3, 5, 2, 6, 4])

AsyncImage

role image · arguments url

Source
AsyncImage().frame(width: 160, height: 96)

Badge

role badge · arguments text

Text
Source
Badge("Text")

BarChart

role chart · defaults kind: "bar"

Source
BarChart(values: [3, 5, 2, 6, 4])

Board

Kanban board of BoardColumn children

role board

To do1
Write copy
Add card
Source
Board() { BoardColumn("To do") { KanbanCard("Write copy") } }

BoardColumn

BoardColumn("To do", count:, color:) { KanbanCard(…) }

role boardcolumn · arguments title

Title2
Write copy
Review
Add card
Source
BoardColumn("Title") { KanbanCard("Write copy"); KanbanCard("Review") }

role breadcrumb · arguments items

Source
Breadcrumb(["One", "Two", "Three"])

BubbleChart

role chart · defaults kind: "bubble"

Source
BubbleChart(values: [3, 5, 2, 6, 4])

Calendar

role calendar

November 2026
SuMoTuWeThFrSa12345678910111213141516171819202122232425262728293012345
Source
Calendar()

Callout

a numbered annotation; place with .position(x:y:)

role callout · arguments number, text

1Text
Source
Callout(1, "Text")

CandlestickChart

role chart · defaults kind: "candlestick"

Source
CandlestickChart(values: [3, 5, 2, 6, 4])

Canvas

free-form area; place children with .position(x:y:); grid: .dots|.lines

role canvas

ContentAction
Source
Canvas() { Text("Content"); Button("Action") }.frame(width: 160, height: 96)

Capsule

role shape · defaults shape: "capsule"

Source
Capsule().frame(width: 160, height: 96)

Card

role card · arguments title

Title
ContentAction
Source
Card("Title") { Text("Content"); Button("Action") }

Chart

kind: .bar|.line|.area|.pie|.donut|.scatter|.bubble|.radar|.heatmap|.funnel|.treemap|.gauge|.candlestick|.combo|.sparkline; values:/series:/labels:/points:/matrix:

role chart

Source
Chart(values: [3, 5, 2, 6, 4])

Chip

role chip · arguments label

Label
Source
Chip("Label")

Circle

role shape · defaults shape: "circle"

Source
Circle().frame(width: 160, height: 96)

CodeBlock

role code · arguments code · defaults lineNumbers: False

let total = items.count
Source
CodeBlock("let total = items.count")

CodeEditor

CodeEditor("…", language: "swift", lineNumbers:, highlight: [3], tabs: [..])

role code · arguments code

1let total = items.count
Source
CodeEditor("let total = items.count")

Color

role color · arguments color

Source
Color(.blue).frame(width: 160, height: 96)

ColorSwatches

colors: [.red, "#0af", …], selection:

role swatches

Source
ColorSwatches()

ComboChart

role chart · defaults kind: "combo"

Source
ComboChart(values: [3, 5, 2, 6, 4])

Comment

author:, time:, avatar:

role message · arguments text · defaults variant: "comment"

Text
Source
Comment("Text")

ControlGroup

role toolbar · defaults variant: "group"

Source
ControlGroup() { Button("Save"); Button("Share") }

DatePicker

selection: "2026-11-23"; .datePickerStyle(.graphical)

role datepicker · arguments label

Source
DatePicker("Label")

DisclosureGroup

role accordion · arguments title

Title
Source
DisclosureGroup("Title") { Text("Content"); Button("Action") }

Divider

role divider

Source
Divider()

DonutChart

role chart · defaults kind: "donut"

Source
DonutChart(values: [3, 5, 2, 6, 4])

Dropzone

role dropzone · arguments label

Label
Source
Dropzone("Label")

Ellipse

role shape · defaults shape: "ellipse"

Source
Ellipse().frame(width: 160, height: 96)

EmptyState

title, systemImage:, description: { actions }

role emptystate · arguments title

Title
Source
EmptyState("Title")

FloatingActionButton

role fab · arguments icon

Source
FloatingActionButton("star")

Form

role form

Name
Notifications
Source
Form() { TextField("Name"); Toggle("Notifications", isOn: true) }

FunnelChart

role chart · defaults kind: "funnel"

Source
FunnelChart(values: [3, 5, 2, 6, 4])

Gantt

scale: ["W1",…], tasks: [("Design", 0, 2, 0.6), …], today:

role gantt

1234567
Design
Build
Source
Gantt(tasks: [("Design", 0, 3), ("Build", 2, 5)])

Gauge

role progress · arguments value · defaults variant: "gauge"

Source
Gauge(60)

GaugeChart

role chart · defaults kind: "gauge"

Source
GaugeChart(values: [3, 5, 2, 6, 4])

Grid

Grid of GridRow children, or columns: n

role grid

ContentAction
Source
Grid() { Text("Content"); Button("Action") }

GridRow

role gridrow

ContentAction
Source
GridRow() { Text("Content"); Button("Action") }

Group

role group

ContentAction
Source
Group() { Text("Content"); Button("Action") }

GroupBox

role card · arguments title

Title
ContentAction
Source
GroupBox("Title") { Text("Content"); Button("Action") }

HStack

Horizontal stack. spacing:, alignment: .top|.center|.bottom

role hstack

ContentAction
Source
HStack() { Text("Content"); Button("Action") }

Heatmap

role chart · defaults kind: "heatmap"

Source
Heatmap(values: [3, 5, 2, 6, 4])

Histogram

role chart · defaults kind: "histogram"

Source
Histogram(values: [3, 5, 2, 6, 4])

Icon

role icon · arguments name

Source
Icon("star")

Image

Image("path.png") or Image(systemName: "star")

role image · arguments name

Source
Image().frame(width: 160, height: 96)

KanbanCard

title, description:, tags: [..], assignees: [..], due:, comments:, priority:

role kanbancard · arguments title

Title
Source
KanbanCard("Title")

LabeledContent

role labeled · arguments label, value

LabelContentAction
Source
LabeledContent("Label", "Value") { Text("Content"); Button("Action") }

LazyHGrid

role grid

ContentAction
Source
LazyHGrid() { Text("Content"); Button("Action") }

LazyHStack

role hstack

ContentAction
Source
LazyHStack() { Text("Content"); Button("Action") }

LazyVGrid

columns: [GridItem(.flexible()), …] or a count

role grid

ContentAction
Source
LazyVGrid() { Text("Content"); Button("Action") }

LazyVStack

role vstack

ContentAction
Source
LazyVStack() { Text("Content"); Button("Action") }

LineChart

role chart · defaults kind: "line"

Source
LineChart(values: [3, 5, 2, 6, 4])

List

.listStyle(.insetGrouped|.plain|.sidebar|…)

role list

First item
Second item
Source
List() { Text("First item"); Text("Second item") }

ListItem

role listitem · arguments title

Title
Source
ListItem("Title")

Map

pins: [(x%, y%, "label")], route:, showsUserLocation:, height:

role map

Source
Map().frame(width: 160, height: 96)

role menu · arguments label

Label
Source
Menu("Label") { Button("Open"); Button("Save"); Divider(); Button("Close") }

role menuitem · arguments label

Source
MenuItem("Label")

MessageBubble

MessageBubble("Hi", from: .me|.them, author:, time:, status:, reactions: [..])

role message · arguments text

Text
Source
MessageBubble("Text")

role navitem · arguments label

Label
Source
NavItem("Label")

role listitem · arguments title · defaults chevron: True

Title
Source
NavigationLink("Title")

{ sidebar } content: { … } detail: { … }

role split

Content
Action
Source
NavigationSplitView() { Text("Content"); Button("Action") }

Content's .navigationTitle / .toolbar form the bar

role navstack

ContentAction
Source
NavigationStack() { Text("Content"); Button("Action") }

role navstack

ContentAction
Source
NavigationView() { Text("Content"); Button("Action") }

Picker

Picker("Size", selection: "M") { Text("S") … }

role select · arguments label

Source
Picker("Label")

PieChart

role chart · defaults kind: "pie"

Source
PieChart(values: [3, 5, 2, 6, 4])

Placeholder

A labelled box for maps, charts, media

role placeholder · arguments label

Label
Source
Placeholder("Label").frame(width: 160, height: 96)

Pointer

Pointer(.arrow|.hand|.ibeam|.grab|.crosshair|.touch); place with .position

role pointer · arguments kind

Source
Pointer(.arrow)

ProgressView

value: 0…1 (or total:); none = indeterminate

role progress · arguments label

Label
Source
ProgressView("Label")

RadarChart

role chart · defaults kind: "radar"

Source
RadarChart(values: [3, 5, 2, 6, 4])

RadioButton

role radio · arguments label

Label
Source
RadioButton("Label")

Rating

role rating · arguments value

Source
Rating(60)

Rectangle

role shape · defaults shape: "rectangle"

Source
Rectangle().frame(width: 160, height: 96)

RoundedRectangle

role shape · defaults shape: "rounded"

Source
RoundedRectangle().frame(width: 160, height: 96)

Row

title, subtitle:, detail:, systemImage:, chevron:

role listitem · arguments title

Title
Source
Row("Title")

ScatterChart

role chart · defaults kind: "scatter"

Source
ScatterChart(values: [3, 5, 2, 6, 4])

Schedule

days: [..], startHour:, endHour:, events: [("Standup", "Mon", 9, 9.5, .blue)], now:

role schedule

8:009:0010:0011:0012:0013:0014:0015:0016:0017:00
Mon
Tue
Wed
Thu
Fri
Source
Schedule()

ScrollView

role scroll · arguments axes

ContentAction
Source
ScrollView() { Text("Content"); Button("Action") }

SearchField

role textfield · arguments placeholder · defaults kind: "search"

Placeholder
Source
SearchField("Placeholder")

Section

Section("Header") { … } footer: { … }

role section · arguments title

Title
First itemSecond item
Source
Section("Title") { Text("First item"); Text("Second item") }

SecureField

role textfield · arguments placeholder · defaults kind: "password"

Placeholder
Source
SecureField("Placeholder")

SelectionRect

a drag-selection rectangle; size with .frame, place with .position

role marquee

Source
SelectionRect()

Sheet

role dialog · arguments title · defaults variant: "sheet"

Source
Sheet("Title") { Text("Content"); Button("Action") }

role sidebar · arguments title

Source
Sidebar("Title") { Text("Content"); Button("Action") }

Skeleton

lines:, avatar:, image:, shape: .circle|.rectangle|.text

role skeleton

Source
Skeleton().frame(width: 160, height: 96)

Slider

Slider(value: 0.4) or Slider(value: 30, in: 0...100)

role slider

Source
Slider()

Spacer

role spacer

Source
Spacer()

Sparkline

role chart · arguments values · defaults kind: "sparkline"

Source
Sparkline([3, 5, 2, 6, 4], values: [3, 5, 2, 6, 4])

Spreadsheet

rows: [[…]], selection: "B2:C4", active:, formula:, sheets: [..], highlight: ["B3": .yellow]

role spreadsheet

AB
1AB
212
334
Source
Spreadsheet(columns: ["A", "B"], rows: [[1, 2], [3, 4]])

Stat

Stat("Revenue", "$48k", change: "+12%", trend: [..], systemImage:)

role stat · arguments label, value

Label
60
Source
Stat("Label", 60)

Stepper

role stepper · arguments label

Label
Source
Stepper("Label")

Steps

role steps · arguments steps

1Cart
2Shipping
3Payment
Source
Steps(["Cart", "Shipping", "Payment"])

StickyNote

StickyNote("Call Ana", color: .yellow, rotation: -2, author:)

role stickynote · arguments text

Text
Source
StickyNote("Text")

Tab

Tab("Home", systemImage: "house") { … }

role tab · arguments label

Source
Tab("Label")

TabView

Children with .tabItem { Label } or Tab(…)

role tabs · defaults placement: "bottom"

OneTwo
First tab
Source
TabView() { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }

TableColumn

role tablecolumn · arguments title

Source
TableColumn("Title")

TableRow

role tablerow

Source
TableRow()

Tabs

role tabs · arguments items · defaults placement: "top"

OneTwo
First tab
Source
Tabs(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }

Tag

role chip · arguments label

Label
Source
Tag("Label")

TextEditor

role textfield · arguments text · defaults kind: "multiline"

Text
Source
TextEditor("Text")

TextField

TextField("Placeholder", text: "value")

role textfield · arguments placeholder

Placeholder
Source
TextField("Placeholder")

Toast

role toast · arguments message

Message
Source
Toast("Message")

Toggle

Toggle("Wi-Fi", isOn: true)

role toggle · arguments label

Label
Source
Toggle("Label")

Toolbar

role toolbar

Source
Toolbar() { Button("Save"); Button("Share") }

ToolbarItem

ToolbarItem(placement: .topBarTrailing) { … }

role toolbaritem

ContentAction
Source
ToolbarItem() { Text("Content"); Button("Action") }

ToolbarItemGroup

role toolbaritem

ContentAction
Source
ToolbarItemGroup() { Text("Content"); Button("Action") }

Tree

Tree { TreeItem("src") { TreeItem("main.swift") } }

role tree

Folder
File
Source
Tree() { TreeItem("Folder") { TreeItem("File") } }

TreeItem

label, systemImage:, folder:, expanded:, selected:, detail:

role treeitem · arguments label

Label
Source
TreeItem("Label")

Treemap

role chart · defaults kind: "treemap"

Source
Treemap(values: [3, 5, 2, 6, 4])

VStack

Vertical stack. spacing:, alignment: .leading|.center|.trailing

role vstack

ContentAction
Source
VStack() { Text("Content"); Button("Action") }

VideoPlayer

poster image, progress: 0…1, time:, duration:, playing:

role media · arguments image

Source
VideoPlayer().frame(width: 160, height: 96)

Whiteboard

role canvas · defaults grid: "dots"

ContentAction
Source
Whiteboard() { Text("Content"); Button("Action") }.frame(width: 160, height: 96)

ZStack

Overlapping layers. alignment:

role zstack

ContentAction
Source
ZStack() { Text("Content"); Button("Action") }