Material UI¶
Imitates: Material UI (MUI Core + MUI X) · React, default theme v9 · Pack id: mui · Selected by: pack="mui", import MaterialUI, import MUI · Default device: desktop (browser chrome)
116 own elements, plus 96 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¶
Accordion¶
Accordion("General settings", subtitle:, expanded: true) { details }
role accordion · arguments title
Source
Accordion("Title") { Text("Content"); Button("Action") }AccordionDetails¶
role vstack · defaults alignment: "stretch"
Source
AccordionDetails() { Text("Content"); Button("Action") }Alert¶
Alert("Saved", severity: "info", title: "Info", variant: "filled", closable: true)
role alert · arguments message · defaults severity: "success", variant: "standard" · variants standard, filled, outlined
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Alert("Message").variant("standard"); Text("standard").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Alert("Message").variant("filled"); Text("filled").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Alert("Message").variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
}AlertTitle¶
Bold first line inside an Alert
role text · arguments content
Source
AlertTitle("Content")AppBar¶
AppBar(title: "Dashboard", menu: true, avatar: "Ana", search: "Search…") { IconButton(…) } · color: "default"
role appbar · arguments title · variants elevation, outlined, dense
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { AppBar("Title") { Text("Content"); Button("Action") }.variant("elevation"); Text("elevation").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { AppBar("Title") { Text("Content"); Button("Action") }.variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { AppBar("Title") { Text("Content"); Button("Action") }.variant("dense"); Text("dense").font(.caption).foregroundStyle(.secondary) }
}Autocomplete¶
Autocomplete("Movie", value: "Inception") · value: [..] renders chips (multiple)
role select · arguments label · defaults variant: "outlined"
Source
Autocomplete("Label")Avatar¶
Avatar("Remy Sharp", image: "…") · variant: "rounded"
role avatar · arguments name · variants circular, rounded, square
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Avatar("Ana Lima").variant("circular"); Text("circular").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Avatar("Ana Lima").variant("rounded"); Text("rounded").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Avatar("Ana Lima").variant("square"); Text("square").font(.caption).foregroundStyle(.secondary) }
}AvatarGroup¶
AvatarGroup { Avatar(…) … } — overlapped avatars
role hstack
Source
AvatarGroup() { Text("Content"); Button("Action") }Backdrop¶
Backdrop { CircularProgress() }
role dialog · defaults variant: "backdrop"
Source
Backdrop() { Text("Content"); Button("Action") }Badge¶
Badge(4, color: "error") { SvgIcon("mail") } — or .badge(4) on IconButton/Tab/ListItem
role badge · arguments content · variants standard, dot
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Badge("Content").variant("standard"); Text("standard").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Badge("Content").variant("dot"); Text("dot").font(.caption).foregroundStyle(.secondary) }
}BarChart¶
MUI X BarChart(series: [[..], [..]], labels: [..], height: 200)
role chart · defaults kind: "bar"
Source
BarChart(values: [3, 5, 2, 6, 4])BottomNavigation¶
BottomNavigation(value: 0) { BottomNavigationAction("Recents", icon: "restore") … }
role tabs · defaults placement: "bottom"
Source
BottomNavigation() { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }Box¶
Generic container (a column that stretches its children)
role vstack · defaults alignment: "stretch"
Source
Box() { Text("Content"); Button("Action") }Breadcrumbs¶
Breadcrumbs(["Home", "Catalog", "Shoes"]) or Link children
role breadcrumb · arguments items
Source
Breadcrumbs(["One", "Two", "Three"])Button¶
Button("Save", variant: "contained", color: "secondary", size: "small", startIcon: "send")
role button · arguments label · defaults variant: "text" · variants text, outlined, contained
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Button("Label").variant("text"); Text("text").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Button("Label").variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Button("Label").variant("contained"); Text("contained").font(.caption).foregroundStyle(.secondary) }
}ButtonGroup¶
ButtonGroup(variant: "contained") { Button("One") … }
role toolbar · defaults variant: "outlined" · variants contained, outlined, text
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { ButtonGroup() { Button("Save"); Button("Share") }.variant("contained"); Text("contained").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { ButtonGroup() { Button("Save"); Button("Share") }.variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { ButtonGroup() { Button("Save"); Button("Share") }.variant("text"); Text("text").font(.caption).foregroundStyle(.secondary) }
}Card¶
Card(title:, subheader:, avatar:, image:) { content } actions: { Button … } headerAction: { IconButton }
role card · arguments title · defaults elevation: 1 · variants elevation, outlined
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Card("Title") { Text("Content"); Button("Action") }.variant("elevation"); Text("elevation").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Card("Title") { Text("Content"); Button("Action") }.variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
}CardActions¶
Row of small buttons at the bottom of a Card
role hstack
Source
CardActions() { Text("Content"); Button("Action") }CardContent¶
16px-padded body of a Card
role vstack · defaults alignment: "stretch"
Source
CardContent() { Text("Content"); Button("Action") }CardHeader¶
CardHeader(title:, subheader:, avatar:) action: { … }
role card · arguments title
Source
CardHeader("Title") { Text("Content"); Button("Action") }CardMedia¶
CardMedia("photo.svg") — 140px cover image (or Card(image:))
role image · arguments src
Source
CardMedia().frame(width: 160, height: 96)Checkbox¶
Checkbox("Remember me", checked: true, color:)
role checkbox · arguments label
Source
Checkbox("Label")Chip¶
Chip("Active", color: "success", variant: "outlined", onDelete: true, icon:, avatar:)
role chip · arguments label · defaults variant: "filled" · variants filled, outlined
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Chip("Label").variant("filled"); Text("filled").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Chip("Label").variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
}CircularProgress¶
CircularProgress(value: 75, color:)
role progress · defaults kind: "circular"
Source
CircularProgress()Container¶
Centered, max-width 1200 column with 24px gutters
role vstack · defaults alignment: "stretch"
Source
Container() { Text("Content"); Button("Action") }DataGrid¶
MUI X DataGrid(columns:, rows:, checkboxSelection: true, selectedRows: [1], pagination: "…")
role table
| Name | Status |
|---|---|
| Ana Lima | Active |
| Ben Okafor | Away |
Source
DataGrid(columns: ["Name", "Status"], rows: [["Ana Lima", "Active"], ["Ben Okafor", "Away"]])DateCalendar¶
MUI X DateCalendar(value: "2026-11-23", showToday: true)
role calendar
Source
DateCalendar()DatePicker¶
MUI X DatePicker("Start date", value: "2026-11-23")
role datepicker · arguments label · defaults format: "numeric", variant: "outlined"
Source
DatePicker("Label")DateTimePicker¶
role datepicker · arguments label · defaults format: "numeric", kind: "datetime", variant: "outlined"
Source
DateTimePicker("Label")Dialog¶
Dialog(title:, message:) { content } actions: { Button("Cancel") … }
role dialog · arguments title
Source
Dialog("Title") { Text("Content"); Button("Action") }DialogActions¶
Right-aligned row of dialog buttons
role hstack
Source
DialogActions() { Text("Content"); Button("Action") }DialogContent¶
role vstack · defaults alignment: "stretch"
Source
DialogContent() { Text("Content"); Button("Action") }DialogContentText¶
Secondary body text of a Dialog
role text · arguments content
Source
DialogContentText("Content")DialogTitle¶
Dialog heading (or use Dialog(title:))
role text · arguments content
Source
DialogTitle("Content")Divider¶
Divider(variant: "inset") · Divider(label: "OR")
role divider · variants fullWidth, inset, middle
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Divider().variant("fullWidth"); Text("fullWidth").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Divider().variant("inset"); Text("inset").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Divider().variant("middle"); Text("middle").font(.caption).foregroundStyle(.secondary) }
}Drawer¶
Drawer(title: "Acme") { ListItemButton("Inbox", icon: "inbox").selected() … } · variant: "temporary" floats over a backdrop
role sidebar · arguments title · defaults variant: "permanent" · variants permanent, persistent, temporary
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Drawer("Title") { Text("Content"); Button("Action") }.variant("permanent"); Text("permanent").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Drawer("Title") { Text("Content"); Button("Action") }.variant("persistent"); Text("persistent").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Drawer("Title") { Text("Content"); Button("Action") }.variant("temporary"); Text("temporary").font(.caption).foregroundStyle(.secondary) }
}Fab¶
Fab("add", color: "primary") · Fab("navigation", label: "Navigate", variant: "extended") — floats bottom-right; inline: true to place it
role fab · arguments icon · variants circular, extended
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Fab("star").variant("circular"); Text("circular").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Fab("star").variant("extended"); Text("extended").font(.caption).foregroundStyle(.secondary) }
}FilledInput¶
role textfield · arguments placeholder · defaults variant: "filled"
Source
FilledInput("Placeholder")FormControl¶
role vstack · defaults alignment: "stretch"
Source
FormControl() { Text("Content"); Button("Action") }FormControlLabel¶
Checkbox with a label (use Switch(label) for a switch)
role checkbox · arguments label
Source
FormControlLabel("Label")FormGroup¶
Column of Checkbox / Switch controls; orientation: .horizontal for row
role vstack · defaults alignment: "leading"
Source
FormGroup() { Text("Content"); Button("Action") }FormHelperText¶
Caption under a control; error: true
role text · arguments content
Source
FormHelperText("Content")FormLabel¶
Label of a RadioGroup / FormGroup
role text · arguments content
Source
FormLabel("Content")Grid¶
Grid(spacing: 16) { Grid(size: 4) { … } } — 12-column grid, items span size:
role grid · arguments columns
Source
Grid(["Name", "Status"]) { Text("Content"); Button("Action") }IconButton¶
IconButton("delete", color: "primary", size: "small")
role button · arguments icon · defaults iconOnly: True
Source
IconButton("star")ImageList¶
ImageList(columns: 3) { ImageListItem("photo.svg") … }
role grid · arguments columns
Source
ImageList(["Name", "Status"]) { Text("Content"); Button("Action") }Input¶
role textfield · arguments placeholder · defaults variant: "standard"
Source
Input("Placeholder")InputBase¶
role textfield · arguments placeholder · defaults variant: "base"
Source
InputBase("Placeholder")LinearProgress¶
LinearProgress(value: 60) · no value = indeterminate
role progress · variants determinate, indeterminate, buffer, query
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { LinearProgress().variant("determinate"); Text("determinate").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { LinearProgress().variant("indeterminate"); Text("indeterminate").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { LinearProgress().variant("buffer"); Text("buffer").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { LinearProgress().variant("query"); Text("query").font(.caption).foregroundStyle(.secondary) }
}Link¶
role link · arguments label, href · variants always, hover, none
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Link("Label", "#").variant("always"); Text("always").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Link("Label", "#").variant("hover"); Text("hover").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Link("Label", "#").variant("none"); Text("none").font(.caption).foregroundStyle(.secondary) }
}List¶
List { ListItem(…) … } · .dense() · List(header: "Folders")
role list
Source
List() { Text("First item"); Text("Second item") }ListItem¶
ListItem("Inbox", secondary: "…", icon: "inbox", avatar: "Ana") { secondary action }
role listitem · arguments primary
Source
ListItem("Primary")ListItemAvatar¶
Leading avatar of a ListItem
role avatar · arguments name
Source
ListItemAvatar("Ana Lima")ListItemButton¶
Clickable ListItem; .selected() tints it
role listitem · arguments primary
Source
ListItemButton("Primary")ListItemIcon¶
Leading icon of a ListItem (56px column)
role icon · arguments name
Source
ListItemIcon("star")ListItemText¶
ListItemText(primary:, secondary:) inside a ListItem
role listitem · arguments primary
Source
ListItemText("Primary")ListSubheader¶
Section heading inside a List
role text · arguments content
Source
ListSubheader("Content")LoadingButton¶
Button with a progress spinner (Button loading:)
role button · arguments label · defaults loading: True, variant: "contained" · variants text, outlined, contained
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { LoadingButton("Label").variant("text"); Text("text").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { LoadingButton("Label").variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { LoadingButton("Label").variant("contained"); Text("contained").font(.caption).foregroundStyle(.secondary) }
}Masonry¶
role grid · arguments columns
Source
Masonry(["Name", "Status"]) { Text("Content"); Button("Action") }Menu¶
Menu(icon: "more_vert", open: true) { MenuItem("Edit", icon: "edit") … }
role menu · arguments label
Source
Menu("Label") { Button("Open"); Button("Save"); Divider(); Button("Close") }MenuItem¶
MenuItem("Profile", icon:, shortcut: "⌘P").selected()
role menuitem · arguments label
Source
MenuItem("Label")MenuList¶
A standalone menu surface
role menu
Source
MenuList() { Button("Open"); Button("Save"); Divider(); Button("Close") }MobileStepper¶
MobileStepper(count: 4, page: 2) — dots with Back/Next
role pagination · variants dots, text, progress
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { MobileStepper().variant("dots"); Text("dots").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { MobileStepper().variant("text"); Text("text").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { MobileStepper().variant("progress"); Text("progress").font(.caption).foregroundStyle(.secondary) }
}Modal¶
role dialog · arguments title
Source
Modal("Title") { Text("Content"); Button("Action") }NativeSelect¶
role select · arguments label · defaults variant: "standard"
Source
NativeSelect("Label")OutlinedInput¶
role textfield · arguments placeholder · defaults variant: "outlined"
Source
OutlinedInput("Placeholder")Pagination¶
Pagination(count: 10, page: 2, color: "primary", shape: "rounded")
role pagination · variants text, outlined
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Pagination().variant("text"); Text("text").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Pagination().variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
}Paper¶
Paper(elevation: 3) { … } — surface with no padding; variant: "outlined"
role card · defaults elevation: 1 · variants elevation, outlined
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Paper() { Text("Content"); Button("Action") }.variant("elevation"); Text("elevation").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Paper() { Text("Content"); Button("Action") }.variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
}PieChart¶
MUI X PieChart(values: [..], labels: [..])
role chart · defaults kind: "pie"
Source
PieChart(values: [3, 5, 2, 6, 4])Placeholder¶
role placeholder · arguments label
Source
Placeholder("Label").frame(width: 160, height: 96)Popover¶
role menu · arguments label
Source
Popover("Label") { Button("Open"); Button("Save"); Divider(); Button("Close") }RadioGroup¶
RadioGroup("Gender", options: [..], value: "Female") · orientation: .horizontal for row
role radiogroup · arguments label
Source
RadioGroup("Label") { Radio("First", selected: true); Radio("Second") }Select¶
Select("Age", options: ["Ten", "Twenty"], value: "Twenty", open: true)
role select · arguments label · defaults variant: "outlined" · variants outlined, filled, standard
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Select("Label").variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Select("Label").variant("filled"); Text("filled").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Select("Label").variant("standard"); Text("standard").font(.caption).foregroundStyle(.secondary) }
}Skeleton¶
Skeleton(variant: "circular").frame(width: 40, height: 40)
role shape · defaults shape: "rectangle", variant: "text" · variants text, rectangular, rounded, circular
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Skeleton().variant("text").frame(width: 160, height: 96); Text("text").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Skeleton().variant("rectangular").frame(width: 160, height: 96); Text("rectangular").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Skeleton().variant("rounded").frame(width: 160, height: 96); Text("rounded").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Skeleton().variant("circular").frame(width: 160, height: 96); Text("circular").font(.caption).foregroundStyle(.secondary) }
}Slider¶
Slider(value: 30, min: 0, max: 100, color:) · value: [20, 37] for a range
role slider
Source
Slider()Snackbar¶
Snackbar("Note archived", action: "UNDO", closable: true) · position: .bottomCenter
role toast · arguments message
Source
Snackbar("Message")SparkLineChart¶
role chart · defaults kind: "sparkline"
Source
SparkLineChart(values: [3, 5, 2, 6, 4])Stack¶
Stack(spacing: 16) · orientation: .horizontal for direction="row" (spacing in px)
role vstack · defaults alignment: "stretch"
Source
Stack() { Text("Content"); Button("Action") }StaticDatePicker¶
role calendar
Source
StaticDatePicker()Step¶
Stepper { Step("Shipping") … } (or steps: [..])
role text · arguments label
Source
Step("Label")Stepper¶
Stepper(["Shipping", "Payment", "Review"], activeStep: 1) · orientation: .vertical
role steps · arguments steps · variants horizontal, vertical
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Stepper(["Cart", "Shipping", "Payment"]).variant("horizontal"); Text("horizontal").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Stepper(["Cart", "Shipping", "Payment"]).variant("vertical"); Text("vertical").font(.caption).foregroundStyle(.secondary) }
}SwipeableDrawer¶
role sidebar · arguments title · defaults variant: "temporary"
Source
SwipeableDrawer("Title") { Text("Content"); Button("Action") }Switch¶
Switch("Wi-Fi", checked: true) · labelPlacement: .start
role toggle · arguments label
Source
Switch("Label")TabList¶
role tabs · arguments items · defaults placement: "top"
Source
TabList(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }TabPanel¶
role vstack · defaults alignment: "stretch"
Source
TabPanel() { Text("Content"); Button("Action") }Table¶
Table(columns: [..], rows: [[..]], size: "small") or TableRow { TableCell … } children
role table
| Name | Status |
|---|---|
| Ana Lima | Active |
| Ben Okafor | Away |
Source
Table(columns: ["Name", "Status"], rows: [["Ana Lima", "Active"], ["Ben Okafor", "Away"]])TableContainer¶
Paper around a Table
role card · defaults elevation: 1
Source
TableContainer() { Text("Content"); Button("Action") }TablePagination¶
TablePagination("Rows per page: 10 ▾ 1–10 of 100") — the label, then prev/next
role pagination · arguments summary
Source
TablePagination("Summary")Tabs¶
Tabs(["Account", "Security"], value: 0) or Tabs { Tab("One") { panel } }
role tabs · arguments items · defaults placement: "top" · variants standard, scrollable, fullWidth
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Tabs(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }.variant("standard"); Text("standard").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Tabs(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }.variant("scrollable"); Text("scrollable").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Tabs(["One", "Two", "Three"]) { Text("First tab").tabItem { Text("One") }; Text("Second tab").tabItem { Text("Two") } }.variant("fullWidth"); Text("fullWidth").font(.caption).foregroundStyle(.secondary) }
}TextField¶
TextField("Email", value: "…", helperText:, error: true, prefix: "$", size: "small", multiline via kind: .multiline)
role textfield · arguments label · defaults variant: "outlined" · variants outlined, filled, standard
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { TextField("Label").variant("outlined"); Text("outlined").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { TextField("Label").variant("filled"); Text("filled").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { TextField("Label").variant("standard"); Text("standard").font(.caption).foregroundStyle(.secondary) }
}TextareaAutosize¶
role textfield · arguments placeholder · defaults kind: "multiline", variant: "outlined"
Source
TextareaAutosize("Placeholder")TimePicker¶
role datepicker · arguments label · defaults kind: "time", variant: "outlined"
Source
TimePicker("Label")Timeline¶
role steps · arguments steps · defaults orientation: "vertical"
Source
Timeline(["Cart", "Shipping", "Payment"])ToggleButton¶
ToggleButton(icon: "format_bold").selected()
role button · arguments label
Source
ToggleButton("Label")ToggleButtonGroup¶
ToggleButtonGroup(["Web", "Android", "iOS"], value: "Web") — items may be ["icon": …] dicts
role segmented · arguments items
Source
ToggleButtonGroup(["One", "Two", "Three"])Toolbar¶
Toolbar { IconButton; Typography; Spacer(); Button }
role toolbar · variants regular, dense
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Toolbar() { Button("Save"); Button("Share") }.variant("regular"); Text("regular").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Toolbar() { Button("Save"); Button("Share") }.variant("dense"); Text("dense").font(.caption).foregroundStyle(.secondary) }
}Tooltip¶
Tooltip("Delete") { IconButton("delete") } · placement: .bottom
role tooltip · arguments title
Source
Tooltip("Title") { Text("Content"); Button("Action") }Typography¶
Typography("Title", variant: "h5", color: "text.secondary")
role text · arguments content · defaults variant: "body1" · variants h1, h2, h3, h4, h5, h6, subtitle1, subtitle2, body1, body2, button, caption, overline, inherit
Source
HStack(alignment: .top, spacing: 16) {
VStack(alignment: .leading, spacing: 4) { Typography("Content").variant("h1"); Text("h1").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Typography("Content").variant("h2"); Text("h2").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Typography("Content").variant("h3"); Text("h3").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Typography("Content").variant("h4"); Text("h4").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Typography("Content").variant("h5"); Text("h5").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Typography("Content").variant("h6"); Text("h6").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Typography("Content").variant("subtitle1"); Text("subtitle1").font(.caption).foregroundStyle(.secondary) }
VStack(alignment: .leading, spacing: 4) { Typography("Content").variant("subtitle2"); Text("subtitle2").font(.caption).foregroundStyle(.secondary) }
}Core vocabulary in this style¶
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)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") }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)])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") }Map¶
pins: [(x%, y%, "label")], route:, showsUserLocation:, height:
role map
Source
Map().frame(width: 160, height: 96)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")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")SegmentedControl¶
role segmented · arguments items
Source
SegmentedControl(["One", "Two", "Three"])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") }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") } }Terminal¶
lines starting with "$ " are commands
role code · arguments code · defaults variant: "terminal"
Source
Terminal("let total = items.count")Text¶
Text with bold, italic, code Markdown
role text · arguments content
Source
Text("Content")TextEditor¶
role textfield · arguments text · defaults kind: "multiline"
Source
TextEditor("Text")TimelineItem¶
title, time:, description:, systemImage:, status:
role timelineitem · arguments title
Source
TimelineItem("Title")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") }