Skip to content

SegmentedControl

A row of segments where one is selected, rendered as Tabler’s nav-segmented. Each segment is a Bootstrap tab (data-bs-toggle="tab"), so tabler.js moves the selection on click. Segments are <button type="button">, so they never submit an enclosing form.

To show a panel per segment, add data-bs-target="#pane-id" to each item; attributes are forwarded to the <button>. Without a target, the control only switches its selected segment: listen to Bootstrap’s shown.bs.tab event to react to it.

Put an icon before the label with the nav-link-icon class:

fullWidth stretches the control, and its segments, to the width of the container. A segment takes the native disabled attribute:

vertical stacks the segments in a column:

A segmented control that picks a value is a radio group, not a tab list. Use SegmentedControl:Option segments: a radio (or a checkbox with type="checkbox") followed by its <label class="nav-link">, so the checked segment is submitted with the form. Give the control role="radiogroup" and an aria-label, or put it in a <fieldset> with a <legend>. The form theme renders an expanded ChoiceType this way with choice_style: 'segmented'.

Tabler hides the inputs of a segmented control with display: none, which takes them out of the keyboard order. The option adds btn-check d-block to the input: hidden but focusable, so Tab reaches the group and the arrow keys move the selection. Tabler draws no focus ring on the segment itself.

Prop Type Default Description
fullWidth bool false Stretches to the container (w-100)
vertical bool false Stacks the segments (nav-segmented-vertical)
size string 'md' sm md lg (nav-sm, nav-lg)

Other attributes go to the root <nav role="tablist">: give it an aria-label. Pass role="radiogroup" for SegmentedControl:Option radios.

Component Renders
SegmentedControl:Item <button type="button" class="nav-link" role="tab" data-bs-toggle="tab">, with aria-selected
SegmentedControl:Option <input class="nav-link-input btn-check d-block"> and its <label class="nav-link">, for forms

SegmentedControl:Item takes one prop:

Prop Type Default Description
active bool false The selected segment (active, aria-selected="true"); the others get tabindex="-1"

Its type is button unless you pass another one, such as type="submit".

SegmentedControl:Option takes these props:

Prop Type Default Description
id string required The input id, referenced by the label’s for
name string null The input name, shared by the options of a control
value string null The input value
type string 'radio' radio or checkbox
checked bool false The selected segment
disabled bool false An inactive segment
label string null The label text; children replace it
icon string null An icon before the label (nav-link-icon)

class and the attributes prefixed with label: go on the <label>; every other attribute (required, aria-describedby, data-*…) goes on the <input>. The icon and content blocks hold the icon and the label.