Design System

Segmented reference ​

Every prop, event and rendered attribute, with what it resolves to. For how to apply it, see Usage. Measured values are taken at the default 14px interface root.

Props ​

PropTypeRequiredDefaultMeaning
modelValueTyesnoneThe selected value, bound with v-model. A call site without it raises a missing prop warning
labelstringyesnoneThe accessible name of the group. Rendered into a span that the group references
optionsunknown[]yesnoneOne button per entry, in array order. An empty array renders the group box with no buttons
hideLabelbooleannofalseSwaps the label span class from text-caption to sr-only. The text stays in the DOM
optionLabelstringnoundefinedThe field of an option holding its text. Unset uses the option itself, which stringifies an object
optionValuestringnoundefinedThe field of an option holding its value. Unset emits the option object and compares it deeply
fluidbooleannofalseMakes the wrapper full width and gives each button an equal share of the row
disabledbooleannofalseDisables the buttons in the group. There is no per option equivalent

The generic parameter defaults to string. It is inferred from the bound model rather than from options, which is instantiated as unknown[].

Events ​

EventPayloadDeclared
update:modelValueT, the resolved option valueYes, through the model definition
change{ event: Event, value: T }No. A listener passes the forwarded attribute filter and reaches the control underneath, which declares the emit

Clicking the option that is already selected returns before either event, because the underlying empty behaviour is fixed off.

Slots ​

SlotContent
noneThe template holds no slot element, and the control underneath is rendered self closing, so its own option slot stays empty. Children passed to the component render nothing

Sizes and severities ​

AxisAccepted
size, severity, variantNot props. Neither of the two shared unions is imported
fluidfalse, true
hideLabelfalse, true

Geometry ​

PartValue
WrapperColumn flex container, 4px gap, full width when fluid
Label spanCaption role: 12px text on a 16px line box at a 14px root, weight 400, colour inherited from the call site
Group box1px transparent border, 6px radius, 31px tall, no padding, no background
Group widthContent width plus 2px in a flex parent, and the parent width in a block parent
Button box29px tall, from 6px of vertical padding and a 17px line box. 16px of horizontal padding
Button borderWidth 0. The group sets the border style to none
Button radii6px on the outer corners of the first and last buttons, 0 on the inner ones
Button label14px inherited, weight 500, line height normal, centred
Selection pill4px from the left and top, 3px from the right and bottom, 4px radius, behind the label
TransitionAll properties, 200ms
Component height51px with a visible label, 31px with a hidden one, because the hidden label leaves the flow and takes the 4px gap with it

The pill offsets come from the 4px spacing step, while its size subtracts half a rem, which is 7px at a 14px root. That leaves the pill 22px tall in a 29px button and 94px wide in the 101px Markdown button.

States ​

StatePropertyToken
Button surface, any statebackground-colorsurface-page
Selectedcolor and the pill fillfg-strong over surface-raised
Unselectedcolor, transparent pillfg-subtle
Hover, unselected and enabledcolor, leaving the background alonefg-strong
Focus visibleoutline, 2px at 2px offsetline-focus, from the interface wide focus rule
Disabled, whole groupopacity, pointer events, cursoropacity-disabled, resolving to 0.6
InvalidUnreachable. The preset branch exists, and neither a prop nor an attribute reaches it

Rendered DOM ​

html
<div class="flex flex-col gap-1">
  <span id="{id}-label" class="text-caption">Description view</span>
  <div id="{id}" role="group" aria-labelledby="{id}-label">
    <button type="button" aria-pressed="true" data-p-checked="true">
      <span><span>Markdown</span></span>
    </button>
    <button type="button" aria-pressed="false" data-p-checked="false">
      <span><span>Raw</span></span>
    </button>
  </div>
</div>

ARIA ​

AttributeElementValue
role="group"Group divFixed by the control underneath
aria-labelledbyGroup divThe id of the label span
idGroup divThe caller's id attribute when it is a string, otherwise a generated id
idLabel spanThe group id followed by -label
aria-pressedEach buttonWhether that option equals the model
disabledEach buttonThe disabled prop
data-p-checked, data-p-disabled, data-pc-name, data-pc-sectionButtons, group and inner spansStamped by the component library from the state and the section

Absent from the output: role="radiogroup", role="radio", aria-checked, a managed tabindex, and aria-disabled on the group. Each button is a native tab stop and the arrow keys are unhandled.

Attributes ​

AttributeOutcome
data-*, aria-*, name, formForwarded to the group div
aria-labelledbyForwarded, then overwritten by the component's own binding
on[A-Z] listenersForwarded to the control underneath
idTaken by the component and used as the group id and the stem of the label id
class, style, pt, unstyledDropped. Attribute inheritance is off and the filter admits none of them
invalid, multiple, dataKey, optionDisabledDropped. None is a prop of this component

The filter is the shared allow-list described in component reference.