Skip to content

Add Label and labelStyle#62

Merged
colemancda merged 5 commits into
masterfrom
feature/label
Jul 24, 2026
Merged

Add Label and labelStyle#62
colemancda merged 5 commits into
masterfrom
feature/label

Conversation

@colemancda

Copy link
Copy Markdown
Member

Label("title", systemImage:) (and the custom title:/icon: builder), plus .labelStyle(.automatic / .titleAndIcon / .titleOnly / .iconOnly).

Shape

Emitted as its own Label node with children [icon, title] rather than desugared to an HStack — that fixed order is what lets labelStyle drop either half. The style rides the same inherited-CompositionLocal mechanism the control styles use (#55): .labelStyle on a container styles every label beneath it, and each label reads LocalLabelStyle to decide whether to show its icon, its title, or both.

Verification

  • swift test — 3 new tests, 110 passing: icon-then-title order (the interpreter depends on it), the custom title/icon builder, and — the load-bearing one — that a container carries the style while the labels beneath it carry none of their own, which is what makes inheritance real rather than per-node.
  • Emulator (new "Label" screen), screenshot-checked: three icon+title labels (star/trash/envelope) render; .titleOnly shows only the text, .iconOnly shows only the star; and both hearts under one container-level .labelStyle(.iconOnly) drop their titles — inheritance working end to end. The dropped titles are also absent from the accessibility tree, not just hidden.

Scope

Built-in style spellings only — the LabelStyle protocol for custom layouts isn't modeled. .automatic and .titleAndIcon both show both halves.

@colemancda
colemancda merged commit d350cb7 into master Jul 24, 2026
6 checks passed
@colemancda
colemancda deleted the feature/label branch July 24, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant