Founding sponsorYour name here

One connected control, one selected segment — a segmented control

Segmented Control

/ NSSegmentedControl · PickerStyle.segmented /

also called segment control, segmented picker, button group

A segmented control groups a small set of related choices into one horizontal row of connected buttons. The selected segment receives a pressed or filled appearance, making the current mode immediately visible. NSSegmentedControl can also be configured for multiple or momentary tracking, but a segmented Picker normally represents one persistent selection.

If you called it…

the connected row of buttons where one stays selectedpill split into several clickable choicessmall tabs that switch between viewsgroup of joined icon buttons in a toolbarhorizontal selector with one pressed section

…you meant a segmented control.

Anatomy — every part, named

  1. 1
    Selected segmentNSSegmentedControl.selectedSegment

    “The section that stays pressed” is the selected segment.

  2. 2
    Segment dividerNSSegmentedControl

    “The little line separating two choices in the pill” is a segment divider.

Prompt — paste into your agent

Use a Segmented Control with NSSegmentedControl (SwiftUI: a Picker with PickerStyle.segmented), showing the active segment with the native selected treatment. Keep the buttons connected as one control and bind selection so exactly one segment remains selected for this view switcher.

Debug prompt — when it misbehaves

Paste this, then describe what you’re seeing — it hands your agent the classic failure modes to rule out first.

Debug my macOS segmented control (NSSegmentedControl). Rule out: trackingMode wrong — momentary segments fire and deselect, selectOne keeps a selection; selectedSegment being -1 in the action for momentary mode; segment images not template so dark mode breaks; auto segment widths jumping when labels change. The symptom:

In code

The exact names this thing goes by in code — each row is one framework’s word for it. Use the row that matches your project (or paste it into your prompt).

AppKitNSSegmentedControl
SwiftUIPickerStyle.segmented
AppKitNSSegmentedControl.trackingModesingle, multiple, or momentary selection behavior
SwiftUIView.pickerStyle(_:)

See also

Search

Describe the UI element you're thinking of