Segmented Control

A macOS segmented control (NSSegmentedControl). Segments share the container width equally — the AppKit default distribution. In single mode the accent selection slides between segments; a selected segment cannot be deselected by clicking it again, matching AppKit. Tahoe has a single visual style, so there is no variant; momentary (button-like) segments are not modeled — use MacButtons for that. Arrow keys move focus between segments; Space or Enter selects the focused segment.

Usage

vue
<script setup lang="ts">
import { MacSegment, MacSegmentedControl } from 'macvue'
import { ref } from 'vue'

const view = ref('list')
</script>

<template>
  <MacSegmentedControl
    v-model="view"
    aria-label="View"
  >
    <MacSegment value="list">
      List
    </MacSegment>
    <MacSegment value="icons">
      Icons
    </MacSegment>
  </MacSegmentedControl>
</template>

Multiple

type="multiple" switches the model to an array (selectAny in AppKit). Selected segments can be toggled off; there is no sliding pill.

Sizes

All five macOS control sizes; regular is the default. Large and extra-large are capsules.

Disabled

Disable the whole group or individual segments.

API

MacSegmentedControl Props

PropTypeDefault
modelValue (v-model)string | string[]
defaultValuestring | string[]
type'single' | 'multiple''single'
size'extra-large' | 'large' | 'regular' | 'small' | 'mini''regular'
disabledbooleanfalse
namestring

With name set, hidden inputs carry the selection in native form submission.

MacSegmentedControl Events

EventPayload
update:modelValuestring | string[]

MacSegmentedControl Exposed

NameTypeDescription
elRef<HTMLElement | null>The group element.
focus() => voidFocuses the current segment.
blur() => voidRemoves focus from the group.

MacSegment Props

PropTypeDefault
valuestring— (required)
disabledbooleanfalse

MacSegment Slots

SlotDescription
defaultSegment label content.

MacSegment Exposed

NameTypeDescription
elRef<HTMLButtonElement | null>The underlying segment button.
focus() => voidFocuses the segment.
blur() => voidRemoves focus from the segment.