Übersicht FarbenTypografieAbstände & RasterIcons ButtonButton GroupIcon ButtonLink CheckboxCheckbox GroupChipChip GroupComboboxDate PickerFieldField LabelFieldsFile UploadFormForm SectionInputInput GroupOTP InputPasswordRadioRadio GroupRange SliderReset ButtonSave ButtonSearchSegmented ControlSelectSliderSwitchTextareaTime Picker AvatarAvatar GroupBadgeChartCode BlockCopy ValueData TableInline StatKey ValueList GroupList RowsMeta ItemQR CodeStatStat StripTableTag AlertEmpty StateGuideLive StatusMessagesProgressSkeletonToast DialogDrawerDropdownMenuMenu ItemPopoverTooltip BreadcrumbContent NavigationDate NavigationPaginationSidebarStepperTabsTheme SwitchTopbar AccordionAccordion ItemApp ShellCardDividerFooterPage HeaderSection HeaderSplit Panel DashboardListeFormularDetailansichtEinstellungenMehrschritt-AssistentLeerer StartLoginFehlerseite IconsMusterAdmin

Segmented Control

Varianten

Segmented Control mit zwei, drei und vier Segmenten sowie mit Icons.

Code<div class="tc-stack" style="--tc-gap: 20px; align-items: flex-start"> {% tc_segmented_control# label="Ansicht" name="view" options="list=Liste|board=Board" value="list" %} {% tc_segmented_control# label="Farbschema" name="scheme" options="light=Hell|dark=Dunkel|auto=Auto" value="auto" %} {% tc_segmented_control# label="Zeitraum" name="period" options="day=Tag|week=Woche|month=Monat|year=Jahr" value="week" %} {% tc_segmented_control# label="Zeitraum" name="period_disabled" options="day=Tag|week=Woche|month=Monat" value="day" disabled=True %} </div>

Mit Label und volle Breite

sichtbares Gruppenlabel und gleich breite Segmente.

Code<div class="tc-stack" style="--tc-gap: 20px; max-width: 360px"> {% tc_segmented_control# label="Farbschema" show_label=True name="scheme_label" options="light=Hell|dark=Dunkel|auto=Auto" value="light" %} {% tc_segmented_control# label="Ansicht" name="view_block" block=True options="list=Liste|board=Board|calendar=Kalender" value="board" get_url="/beispiel/ansicht/" trigger="change" target="view-content" %} </div>

Rohes HTML und Ereignis

Segmente sind button-Kinder; change/tc-change melden den neuen Wert.

value: list

Code<div class="tc-stack" style="--tc-gap: 12px; align-items: flex-start"> <tc-segmented-control name="api_view" label="Ansicht" value="list"> <button type="button" value="list">Liste</button> <button type="button" value="board">Board</button> <button type="button" value="calendar">Kalender</button> </tc-segmented-control> <p class="tc-text-body-sm tc-text-secondary">value: <span class="tc-mono">list</span></p> <script> (function (root) { const control = root.querySelector('tc-segmented-control'); control.addEventListener('tc-change', event => { root.querySelector('.tc-mono').textContent = event.detail.value; }); })(document.currentScript.parentElement); </script> </div>

API

OptionStandardWerteBeschreibung
name''–Form field name.
options'()'–Segments: dictionaries (value, label, icon, disabled), Django choices or "value=Label|value=Label".
value'None'–Selected value (defaults to the first segment).
label''–Group label; hidden unless show_label is set (always announced).
show_labelFalse–Show the label above the control.
disabledFalse–Disable all segments.
blockFalse–Stretch to the container width with equal segments.

Verwendung

{% load components tomcom_theme %} {% tc_segmented_control name="…" options="…" %}…{% endtc_segmented_control %} {% tc_segmented_control# %} {# inline form without content #}

Zusätzliche Attribute (z. B. class, aria-*, data-*) und HTMX-Kurzformen (get, post, get_url, post_url, target, swap, trigger, confirm) werden an das Element „root“ durchgereicht.