SegmentedControlItem

OverviewExamplesPropertiesSlotsMethodsEventsCSS PropertiesUsageIntegration

Segmented control items populate a segmented control with options. Every item should be placed inside a segmented control.

Loading...

Properties

PropertyAttribute Description TypeDefault
checkedcheckedControls whether the segmented control item is checked or not.booleanfalse
sizesizeThe size of the segmented control item. This affects font-size and padding.'s' | 'm' | 'l''m'
labellabelLabel for the segmented control item.string''
disableddisabledMakes the component disabled. This prevents users from being able to interact with the component, and conveys its inactive state to assistive technologies.booleanfalse
namenameThe name of the form component.string | undefined
valuevalueThe value of the form component.string''
formformGets the form, if any, associated with the form element. The setter accepts a string, which is the id of the form.HTMLFormElement | null

Slots

Slot name Description
labelUse when a label requires more than plain text.

Methods

Method nameParameters Description
focus(options?: FocusOptions) => voidoptions: An object which controls aspects of the focusing process.Programmatically move focus to the component.
blur() => voidN/AProgrammatically remove focus from the component.
click() => voidN/AProgrammatically simulates a click on the component.
EventDetail TypeDescription
changeNordEventFired whenever the segmented control item has been checked.
inputNordEventFired as the user types into the input.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-segmented-control-item-border-radiusControls the rounded corners of the item, using border radius tokens.var(--n-border-radius-s)
--n-segmented-control-item-gapControls the spacing between elements within the item, using our spacing tokens.var(--n-space-xs)
--n-segmented-control-item-gradientControls the overlayed gradient background on the item.linear-gradient(to bottom, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.013) 100%))
--n-segmented-control-item-background-colorControls the background color of the item, using our color tokens.var(--n-color-nav-hover)
--n-segmented-control-item-colorControls the color of the text within the item, using our color tokens.var(--n-color-text-weaker)
--n-segmented-control-item-padding-inlineControls the inline, or left and right, padding of the item.calc(var(--n-space-m) / 1.2)
--n-segmented-control-item-box-shadowControls the surrounding shadow, using our box shadow tokens.none
--n-segmented-control-item-font-sizeControls the size of the text within the item, using our font tokens.var(--n-font-size-m)
--n-segmented-control-item-font-weightControls the weight of the text within the item, using our font tokens.var(--n-font-weight)
--n-segmented-control-item-min-block-sizeControls the minimum block size, or height, of the item using our spacing tokens.calc(var(--n-space-xl) - 2px)
--n-segmented-control-item-inline-sizeControls the inline size of the item.auto

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Use segmented control to allow users to pick one choice from a set of closely related choices, and immediately apply that selection.
  • Favor segmented control or radio component over a select component when there are a small number of options. This reduces the number of clicks a user has to make, increasing efficiency.
  • Segmented control items are grouped by their name attribute. Therefore, it is crucial that the same name is used for a group of segmented control items.
  • Give each segmented control item within a group a unique value.
  • Segmented control items must be used in combination with a segmented control component.

Don’t

  • Don’t place interactive content (buttons, links etc) inside the label.
  • Don’t use when a user can select more than one option. In this case, use a checkbox or selectable tag instead.
  • Don’t use for “accepting terms of service” and similar functionality. Use a checkbox instead.
  • When you have more than 5 options to choose from. Consider using a select instead.

Content guidelines

Segmented control labels should be clear, accurate and predictable. It should be possible for the user to understand what they are enabling or disabling:

User settings
Option 1

When writing segmented control labels, always write them in sentence case, not title case. The first word should be capitalized and the rest lowercase (unless a proper noun):

My tasks
My Tasks

Avoid ending in punctuation if it’s a single sentence, word, or a fragment:

Blue
Blue.

Do not use commas or semicolons at the end of each line

Patient
Patient;

Additional considerations

  • Once a segmented control item has been selected, users cannot return to having no items selected without refreshing their browser window. Therefore, you should always make sure one of the items is pre-selected.

Integration

For integration guidelines, please see Web Components documentation .

Was this page helpful?

Yes No

We use this feedback to improve our documentation.