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
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) }
}ActionListGroup¶
ActionList.Group("Assignees") { items }
role section · arguments title
Source
ActionListGroup("Title") { Text("First item"); Text("Second item") }ActionListGroupHeading¶
role text · arguments content
Source
ActionListGroupHeading("Content")ActionListItem¶
ActionList.Item(label, leadingVisual:, trailingVisual: text, description:, selected:, variant: .danger)
role listitem · arguments title · variants default, 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) }
}ActionMenu¶
ActionMenu("Sort", open: true) { ActionMenuItem("Newest", checked: true) … } — anchor + overlay
role menu · arguments label · defaults variant: "default"
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"
Source
ActionMenuButton("Label")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"
Source
Autocomplete("Placeholder")Avatar¶
Avatar("Mona Lin", image:, size: 20…64, square: true for orgs/bots)
role avatar · arguments name
Source
Avatar("Ana Lima")AvatarPair¶
Large avatar with a small one at the bottom right
role zstack
Source
AvatarPair() { Text("Content"); Button("Action") }AvatarStack¶
Overlapping avatars: AvatarStack { Avatar … }
role hstack · defaults spacing: 0
Source
AvatarStack() { Text("Content"); Button("Action") }AvatarToken¶
AvatarToken("mona", avatar: "Mona Lin")
role chip · arguments text
Source
AvatarToken("Text")Banner¶
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
Source
Blankslate("Title")BlobView¶
role code · arguments code
Source
BlobView("let total = items.count")BorderBox¶
Box with border and rounded corners; header: title; children are rows (Box-row)
role card · arguments title · defaults variant: "borderbox"
Source
BorderBox("Title") { Text("Content"); Button("Action") }Box¶
Generic container (Box): style it with modifiers; children stack vertically
role vstack
Source
Box() { Text("Content"); Button("Action") }BoxRow¶
A Box-row inside a BorderBox (bordered row)
role hstack · defaults spacing: 8
Source
BoxRow() { Text("Content"); Button("Action") }BranchName¶
BranchName("feature/login") — monospace accent chip
role text · arguments content
Source
BranchName("Content")Breadcrumbs¶
Breadcrumbs(items: ["acme", "rocket", "src"])
role breadcrumb · arguments items
Source
Breadcrumbs(["One", "Two", "Three"])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
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
Source
Checkbox("Label")CheckboxGroup¶
role vstack · defaults alignment: "leading", spacing: 8
Source
CheckboxGroup() { Text("Content"); Button("Action") }CircleBadge¶
Round badge with an icon (systemImage:)
role avatar · arguments name
Source
CircleBadge("Ana Lima")CodeView¶
Blob view: CodeView("…", language: "ts", highlight: [4], title: "src/app.ts")
role code · arguments code
Source
CodeView("let total = items.count")CommentBox¶
role card · arguments title · defaults variant: "comment"
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
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
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
| Name | Status |
|---|---|
| Ana Lima | Active |
| Ben Okafor | Away |
Source
DataTable(columns: ["Name", "Status"], rows: [["Ana Lima", "Active"], ["Ben Okafor", "Away"]])Details¶
Details/summary disclosure
role accordion · arguments 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
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"
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"
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
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
Source
DiffNumber("Content")Disclosure¶
role accordion · arguments 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
Source
FormControl() { Text("Content"); Button("Action") }FormControlCaption¶
FormControl.Caption (12px muted)
role text · arguments content
Source
FormControlCaption("Content")FormControlLabel¶
FormControl.Label (14px semibold)
role text · arguments content
Source
FormControlLabel("Content")FormControlValidation¶
FormControl.Validation("…", variant: .error|.success)
role text · arguments content
Source
FormControlValidation("Content")Header¶
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
Source
HeaderItem() { Text("Content"); Button("Action") }Heading¶
Heading("Title", variant: .large | .medium | .small)
role text · arguments content · defaults style: "titleMedium" · variants large, medium, small
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
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
Source
InlineMessage("Content")IssueLabel¶
Repository label: IssueLabel("bug", color: .red) — tinted pill (named colours)
role badge · arguments text · defaults color: "gray", variant: "issue"
Source
IssueLabel("Text")IssueLabelToken¶
role badge · arguments text · defaults color: "gray", variant: "issue"
Source
IssueLabelToken("Text")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
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¶
Link("Docs", muted: true) or variant: .muted
role link · arguments label, destination · variants default, muted
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
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
Source
Markdown() { Text("Content"); Button("Action") }NavList¶
NavList { NavListItem("General", leadingVisual: "gear").selected(); NavListGroup("Access") { … } }
role vstack · defaults alignment: "stretch", spacing: 2
Source
NavList() { Text("Content"); Button("Action") }NavListGroup¶
NavList.Group("Code and automation") { items }
role section · arguments title
Source
NavListGroup("Title") { Text("First item"); Text("Second item") }NavListItem¶
NavList.Item(label, leadingVisual:, trailingVisual: count, selected:) — nested items = SubNav
role navitem · arguments 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"
Source
Overlay("Title") { Text("Content"); Button("Action") }PageHeader¶
PageHeader { PageHeaderContextArea; PageHeaderTitleArea { PageHeaderTitle; PageHeaderActions }; PageHeaderDescription }
role vstack · defaults alignment: "stretch", spacing: 8
Source
PageHeader() { Text("Content"); Button("Action") }PageHeaderActions¶
Right-aligned actions of the title row
role hstack · defaults spacing: 8
Source
PageHeaderActions() { Text("Content"); Button("Action") }PageHeaderContextArea¶
Parent link / breadcrumbs above the title
role hstack · defaults spacing: 8
Source
PageHeaderContextArea() { Text("Content"); Button("Action") }PageHeaderDescription¶
Muted metadata row under the title
role hstack · defaults spacing: 8
Source
PageHeaderDescription() { Text("Content"); Button("Action") }PageHeaderLeadingAction¶
role hstack · defaults spacing: 4
Source
PageHeaderLeadingAction() { Text("Content"); Button("Action") }PageHeaderLeadingVisual¶
role hstack · defaults spacing: 4
Source
PageHeaderLeadingVisual() { Text("Content"); Button("Action") }PageHeaderNavigation¶
Holds an UnderlineNav under the header
role vstack · defaults alignment: "stretch", spacing: 0
Source
PageHeaderNavigation() { Text("Content"); Button("Action") }PageHeaderParentLink¶
Back link in the context area
role link · arguments label · defaults systemImage: "arrow-left"
Source
PageHeaderParentLink("Label")PageHeaderTitle¶
PageHeader.Title (variant: .large | .medium | .subtitle)
role text · arguments content · defaults style: "titleMedium" · variants large, medium, subtitle
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
Source
PageHeaderTitleArea() { Text("Content"); Button("Action") }PageHeaderTrailingAction¶
role hstack · defaults spacing: 4
Source
PageHeaderTrailingAction() { Text("Content"); Button("Action") }PageHeaderTrailingVisual¶
role hstack · defaults spacing: 4
Source
PageHeaderTrailingVisual() { Text("Content"); Button("Action") }PageLayout¶
PageLayout { PageLayoutHeader; PageLayoutContentRow { PageLayoutPane; PageLayoutContent } }
role vstack · defaults alignment: "stretch", spacing: 0
Source
PageLayout() { Text("Content"); Button("Action") }PageLayoutContent¶
PageLayout.Content
role vstack · defaults alignment: "stretch", spacing: 16
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
Source
PageLayoutContentRow() { Text("Content"); Button("Action") }PageLayoutFooter¶
PageLayout.Footer
role vstack · defaults alignment: "stretch", spacing: 8
Source
PageLayoutFooter() { Text("Content"); Button("Action") }PageLayoutHeader¶
PageLayout.Header
role vstack · defaults alignment: "stretch", spacing: 8
Source
PageLayoutHeader() { Text("Content"); Button("Action") }PageLayoutPane¶
PageLayout.Pane (296px side column); divider: true draws the line
role vstack · defaults alignment: "stretch", spacing: 8
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"
Source
Popover("Title") { Text("Content"); Button("Action") }RadioGroup¶
role radiogroup · arguments label
Source
RadioGroup("Label") { Radio("First", selected: true); Radio("Second") }RelativeTime¶
RelativeTime("3 days ago") — muted, dotted hover underline
role text · arguments content
Source
RelativeTime("Content")SegmentedControl¶
SegmentedControl { SegmentedControlButton("Preview").selected(); … } or items:, selection:
role segmented · arguments items
Source
SegmentedControl(["One", "Two", "Three"])SegmentedControlButton¶
SegmentedControl.Button("Raw", leadingIcon:, selected:)
role label · arguments 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
Source
Select("Placeholder")SelectPanel¶
Filterable selection overlay: SelectPanel("Labels", open: true) { TextInput; ActionMenuItem(checked:) }
role menu · arguments label · defaults variant: "default"
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)Snippet¶
Clipboard-copy snippet (markdown code block)
role code · arguments code · defaults lineNumbers: False
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
Source
SplitPageLayout() { Text("Content"); Button("Action") }SplitPageLayoutContent¶
SplitPageLayout.Content
role vstack · defaults alignment: "stretch", spacing: 16
Source
SplitPageLayoutContent() { Text("Content"); Button("Action") }SplitPageLayoutPane¶
SplitPageLayout.Pane
role vstack · defaults alignment: "stretch", spacing: 8
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
Source
Stack() { Text("Content"); Button("Action") }StackHorizontal¶
Stack with direction="horizontal"
role hstack · defaults spacing: 8
Source
StackHorizontal() { 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
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) }
}SubNav¶
Joined pill links: SubNav { SubNavLink("Labels").selected() }
role toolbar · defaults variant: "subnav"
Source
SubNav() { Button("Save"); Button("Share") }TabNav¶
Boxed tabs (TabNav): TabNav(items: ["Write", "Preview"], selection: "Write")
role tabs · arguments items · defaults placement: "top", variant: "tabnav"
Source
TabNav(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }Table¶
role table
| Name | Status |
|---|---|
| Ana Lima | Active |
| Ben Okafor | Away |
Source
Table(columns: ["Name", "Status"], rows: [["Ana Lima", "Active"], ["Ben Okafor", "Away"]])TableContainer¶
role vstack · defaults alignment: "stretch", spacing: 8
Source
TableContainer() { Text("Content"); Button("Action") }Terminal¶
role code · arguments code · defaults variant: "terminal"
Source
Terminal("let total = items.count")Text¶
Text("…", size: .small|.medium|.large, weight: .light|.normal|.medium|.semibold) · .foregroundStyle(.secondary)
role text · arguments content
Source
Text("Content")TextInput¶
TextInput("Find a file…", value:, leadingVisual: "search", size: .small|.medium|.large)
role textfield · arguments placeholder
Source
TextInput("Placeholder")TextInputWithTokens¶
TextInputWithTokens("Add topics", selection: ["react", "css"])
role select · arguments placeholder
Source
TextInputWithTokens("Placeholder")Textarea¶
Textarea("Leave a comment", value:, rows: 5)
role textfield · arguments placeholder · defaults kind: "multiline"
Source
Textarea("Placeholder")Timeline¶
Timeline { TimelineItem("…", systemImage: "git-commit", time:) }
role timeline
Source
Timeline() { TimelineItem("Created"); TimelineItem("Shipped") }TimelineComment¶
Issue/PR comment box: TimelineComment("mona commented 2 days ago", avatar: "Mona") { body } action: { … }
role card · arguments title · defaults variant: "comment"
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
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"
Source
ToggleSwitch("Label")Token¶
Token("design", onRemove: true, size: .small|.medium|.large|.xlarge)
role chip · arguments text
Source
Token("Text")Tooltip¶
Tooltip("Copy", direction: .s) { IconButton }
role tooltip · arguments text · defaults placement: "top"
Source
Tooltip("Text") { Text("Content"); Button("Action") }TreeView¶
TreeView { TreeViewItem("src", folder: true) { TreeViewItem("index.ts", systemImage: "file") } }
role tree
Source
TreeView() { TreeItem("Folder") { TreeItem("File") } }TreeViewItem¶
TreeView.Item(label, folder:, expanded:, leadingVisual:, current: true)
role treeitem · arguments label
Source
TreeViewItem("Label")Truncate¶
Single-line text cut with an ellipsis (maxWidth via .frame)
role text · arguments content
Source
Truncate("Content")UnderlineNav¶
UnderlineNav { UnderlineNavItem("Code", leadingVisual: "code", counter: 3).selected() }
role tabs · arguments items · defaults placement: "top", variant: "underline"
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"
Source
UnderlinePanels(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }Core vocabulary in this style¶
Accordion¶
role accordion · arguments title
Source
Accordion("Title") { Text("Content"); Button("Action") }Alert¶
role dialog · arguments title · defaults variant: "alert"
Source
Alert("Title") { Text("Content"); Button("Action") }Board¶
Kanban board of BoardColumn children
role board
Source
Board() { BoardColumn("To do") { KanbanCard("Write copy") } }BoardColumn¶
BoardColumn("To do", count:, color:) { KanbanCard(…) }
role boardcolumn · arguments title
Source
BoardColumn("Title") { KanbanCard("Write copy"); KanbanCard("Review") }Calendar¶
role calendar
Source
Calendar()Callout¶
a numbered annotation; place with .position(x:y:)
role callout · arguments number, text
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
Source
Canvas() { Text("Content"); Button("Action") }.frame(width: 160, height: 96)Card¶
role card · arguments title
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])CodeBlock¶
role code · arguments code · defaults lineNumbers: False
Source
CodeBlock("let total = items.count")CodeEditor¶
CodeEditor("…", language: "swift", lineNumbers:, highlight: [3], tabs: [..])
role code · arguments code
Source
CodeEditor("let total = items.count")Comment¶
author:, time:, avatar:
role message · arguments text · defaults variant: "comment"
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
Source
DisclosureGroup("Title") { Text("Content"); Button("Action") }EmptyState¶
title, systemImage:, description: { actions }
role emptystate · arguments title
Source
EmptyState("Title")Form¶
role form
Source
Form() { TextField("Name"); Toggle("Notifications", isOn: true) }Gantt¶
scale: ["W1",…], tasks: [("Design", 0, 2, 0.6), …], today:
role gantt
Source
Gantt(tasks: [("Design", 0, 3), ("Build", 2, 5)])Grid¶
Grid of GridRow children, or columns: n
role grid
Source
Grid() { Text("Content"); Button("Action") }GroupBox¶
role card · arguments title
Source
GroupBox("Title") { Text("Content"); Button("Action") }HStack¶
Horizontal stack. spacing:, alignment: .top|.center|.bottom
role hstack
Source
HStack() { Text("Content"); Button("Action") }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
Source
KanbanCard("Title")LabeledContent¶
role labeled · arguments label, value
Source
LabeledContent("Label", "Value") { Text("Content"); Button("Action") }LazyVGrid¶
columns: [GridItem(.flexible()), …] or a count
role grid
Source
LazyVGrid() { Text("Content"); Button("Action") }List¶
.listStyle(.insetGrouped|.plain|.sidebar|…)
role list
Source
List() { Text("First item"); Text("Second item") }Map¶
pins: [(x%, y%, "label")], route:, showsUserLocation:, height:
role map
Source
Map().frame(width: 160, height: 96)Menu¶
role menu · arguments label
Source
Menu("Label") { Button("Open"); Button("Save"); Divider(); Button("Close") }MessageBubble¶
MessageBubble("Hi", from: .me|.them, author:, time:, status:, reactions: [..])
role message · arguments text
Source
MessageBubble("Text")NavigationLink¶
role listitem · arguments title · defaults chevron: True
Source
NavigationLink("Title")NavigationSplitView¶
{ sidebar } content: { … } detail: { … }
role split
Source
NavigationSplitView() { Text("Content"); Button("Action") }NavigationStack¶
Content's .navigationTitle / .toolbar form the bar
role navstack
Source
NavigationStack() { Text("Content"); Button("Action") }Picker¶
Picker("Size", selection: "M") { Text("S") … }
role select · arguments label
Source
Picker("Label")Placeholder¶
A labelled box for maps, charts, media
role placeholder · arguments 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
Source
ProgressView("Label")RoundedRectangle¶
role shape · defaults shape: "rounded"
Source
RoundedRectangle().frame(width: 160, height: 96)Row¶
title, subtitle:, detail:, systemImage:, chevron:
role listitem · arguments title
Source
Row("Title")Schedule¶
days: [..], startHour:, endHour:, events: [("Standup", "Mon", 9, 9.5, .blue)], now:
role schedule
Source
Schedule()ScrollView¶
role scroll · arguments axes
Source
ScrollView() { Text("Content"); Button("Action") }SearchField¶
role textfield · arguments placeholder · defaults kind: "search"
Source
SearchField("Placeholder")Section¶
Section("Header") { … } footer: { … }
role section · arguments title
Source
Section("Title") { Text("First item"); Text("Second item") }SecureField¶
role textfield · arguments placeholder · defaults kind: "password"
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") }Sidebar¶
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)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
| A | B | |
|---|---|---|
| 1 | A | B |
| 2 | 1 | 2 |
| 3 | 3 | 4 |
Source
Spreadsheet(columns: ["A", "B"], rows: [[1, 2], [3, 4]])Stat¶
Stat("Revenue", "$48k", change: "+12%", trend: [..], systemImage:)
role stat · arguments label, value
Source
Stat("Label", 60)Steps¶
role steps · arguments steps
Source
Steps(["Cart", "Shipping", "Payment"])StickyNote¶
StickyNote("Call Ana", color: .yellow, rotation: -2, author:)
role stickynote · arguments text
Source
StickyNote("Text")TabView¶
Children with .tabItem { Label } or Tab(…)
role tabs · defaults placement: "bottom"
Source
TabView() { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }Tabs¶
role tabs · arguments items · defaults placement: "top"
Source
Tabs(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }TextEditor¶
role textfield · arguments text · defaults kind: "multiline"
Source
TextEditor("Text")TextField¶
TextField("Placeholder", text: "value")
role textfield · arguments placeholder
Source
TextField("Placeholder")ToolbarItem¶
ToolbarItem(placement: .topBarTrailing) { … }
role toolbaritem
Source
ToolbarItem() { Text("Content"); Button("Action") }ToolbarItemGroup¶
role toolbaritem
Source
ToolbarItemGroup() { Text("Content"); Button("Action") }Tree¶
Tree { TreeItem("src") { TreeItem("main.swift") } }
role tree
Source
Tree() { TreeItem("Folder") { TreeItem("File") } }TreeItem¶
label, systemImage:, folder:, expanded:, selected:, detail:
role treeitem · arguments label
Source
TreeItem("Label")VStack¶
Vertical stack. spacing:, alignment: .leading|.center|.trailing
role vstack
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"
Source
Whiteboard() { Text("Content"); Button("Action") }.frame(width: 160, height: 96)ZStack¶
Overlapping layers. alignment:
role zstack
Source
ZStack() { Text("Content"); Button("Action") }