Skip to content

Swatch Group

Swatch Group provides consistent spacing, accessible keyboard navigation, and selection modes to multiple Swatches.

Overview

Swatch Group supports workflows and patterns using more than one Swatch. Use Swatch Group to facilitate selection, filtering, and toggling workflows.

Usage

  • Facilitate selection of colors or patterns
  • Filtering patterns
  • Toggling of categorical data

Sample

Best practices

Use Swatch Groups to enable users to select from multiple swatches. For display-only scenarios, use individual Swatches. When enabling selection, choose the selectionMode that best matches your workflow requirements.

Accessibility

Keyboard navigation

KeyFunction
TabMoves focus to the next calcite-swatch. If the current focus is the last calcite-swatch, focus will leave the component.
Tab and ShiftMoves focus to the previous calcite-swatch. If the current focus is the first calcite-swatch, focus will leave the component.
Arrow leftMoves focus to the previous calcite-swatch. If the current focus is the first calcite-swatch, focus will return to the last calcite-swatch.
Arrow rightMoves focus to the next calcite-swatch. If the current focus is the last calcite-swatch, focus will return to the first calcite-swatch.
SpaceWhen selectionMode is not "none", selects the focused calcite-swatch.
EnterWhen selectionMode is not "none", selects the focused calcite-swatch.
HomeMoves focus to the component's first calcite-swatch.
EndMoves focus to the component's last calcite-swatch.

API reference

Properties

PropertyAttributeDescriptionTypeDefault
disableddisabledWhen present, interaction is prevented and the component is displayed with lower opacity.booleanfalse
labelrequiredlabelAccessible name for the component.string
scalescaleSpecifies the size of the component. Child calcite-swatchs inherit the component's value."l" | "m" | "s""m"
selectedItemsread-onlySpecifies the component's selected items.Array<HTMLCalciteSwatchElement>
selectionModeselection-modeSpecifies the selection mode of the component, where: "multiple" allows any number of selections, "single" allows only one selection, "single-persist" allows one selection and prevents de-selection, and "none" does not allow any selections."multiple" | "none" | "single" | "single-persist""none"

Slots

NameDescription
default (unnamed)A slot for adding one or more calcite-swatchs.

Events

NameDescriptionBehavior
calciteSwatchGroupSelectFires when the component's selection changes.bubblescomposed

Methods

NameDescriptionSignature
componentOnReadyCreate a promise that resolves once component is fully loaded.componentOnReady(): Promise<void>
setFocusSets focus on the component's first focusable element.setFocus(options?: FocusOptions): Promise<void>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.