The content switcher component allows users to toggle between two or more content sections within the same space. It provides a segmented control interface that functions as either a radio group (single selection) or checkbox group (multiple selections). The component is fully accessible with keyboard navigation, form integration, and comprehensive validation support.
✅ Use content switchers when:
- Switching between different views of the same content (e.g., list/grid views)
- Toggling between related content sections (e.g., tabs, panels)
- Filtering content with mutually exclusive options
- Creating navigation between related pages or sections
- Building multi-step forms with section selection
❌ Don't use content switchers for:
- Binary on/off toggles (use switch components)
- Single option selection from many choices (use radio buttons)
- Multiple selections from many options (use checkboxes)
- Primary navigation between unrelated pages
- Actions that trigger immediate changes (use buttons)
The default content switcher acts as a radio group where only one option can be selected at a time:
Set a default selection using the value attribute:
Enable multiple selections by setting the multiSelect attribute. The value should be a comma-separated list:
import { DapDSContentSwitcher } from 'dap-design-system'
import { DapDSContentSwitcherReact } from 'dap-design-system/react'
For optimal bundle sizes, use the tree-shakeable import syntax:
import { DapDSContentSwitcher } from 'dap-design-system/components'
| Property | Type | Default | Description |
|---|---|---|---|
multiSelect | boolean | false | Whether the content switcher allows multiple selections. |
value | string | The value of the content switcher. A comma-separated list if multiSelect is true. |
| Name | Description |
|---|---|
(default) | The content switcher items. |
| Event Name | Description | Type |
|---|---|---|
dds-change | Fired when the content switcher is changed. | {value: string, selected: boolean } |
| Part Name | Description |
|---|---|
base | The main content switcher container. |
You can style CSS parts using the ::part() pseudo-element selector:
/* Target a specific part */
.my-custom-dap-ds-content-switcher::part(base) {
/* Your custom styles */
}
Example usage:
<dap-ds-content-switcher class="my-custom-dap-ds-content-switcher">
Content switcher
</dap-ds-content-switcher>
.my-custom-dap-ds-content-switcher::part(base) {
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.
| Property Name | Description |
|---|---|
--dds-content-switcher-min-width | The minimum width of the content switcher (default: var(--dds-spacing-4000, 160px)) |
--dds-content-switcher-padding | The padding of the content switcher (default: var(--dds-spacing-100, 4px)) |
--dds-content-switcher-border-width | The border width of the content switcher (default: var(--dds-border-width-base)) |
--dds-content-switcher-border-color | The border color of the content switcher (default: var(--dds-border-neutral-transparent)) |
--dds-content-switcher-border-radius | The border radius of the content switcher (default: var(--dds-radius-rounded, 1000px)) |
--dds-content-switcher-background | The background color of the content switcher (default: var(--dds-transparent-black-subtle, rgb(0 0 0 / 5%))) |
--dds-content-switcher-gap | The gap between content switcher items (default: var(--dds-spacing-100, 4px)) |
CSS custom properties (CSS variables) can be set directly on the component or in your stylesheet:
Method 1: Inline styles (Quick customization)
<dap-ds-content-switcher
style="--dds-content-switcher-min-width: value; --dds-content-switcher-padding: value;">
Content switcher
</dap-ds-content-switcher>
Method 2: CSS classes (Reusable styles)
.my-custom-dap-ds-content-switcher {
--dds-content-switcher-min-width: value;
--dds-content-switcher-padding: value;
--dds-content-switcher-border-width: value;
}
<dap-ds-content-switcher class="my-custom-dap-ds-content-switcher">
Content switcher
</dap-ds-content-switcher>
Method 3: Global theme customization
/* Apply to all instances */
dap-ds-content-switcher {
--dds-content-switcher-min-width: value;
--dds-content-switcher-padding: value;
}
CSS custom properties inherit through the Shadow DOM, making them perfect for theming. Changes apply immediately without rebuilding.
| Property | Type | Default | Description |
|---|---|---|---|
value | string | The value of the segmented control item. | |
checked | boolean | false | The checked state of the segmented control item. |
disabled | boolean | false | The disabled state of the segmented control item. |
name | string | The name of the segmented control item. |
| Name | Description |
|---|---|
iconcontent | The icon content of the segmented control item. |
No custom events available.
| Part Name | Description |
|---|---|
input | The input of the segmented control item. |
| Property Name | Description |
|---|---|
--dds-content-switcher-item-height | The height of the content switcher item (default: var(--dds-spacing-800, 32px)) |
--dds-content-switcher-item-padding | The padding of the content switcher item (default: var(--dds-spacing-200, 8px) var(--dds-spacing-400, 16px)) |
--dds-content-switcher-item-font-size | The font size of the content switcher item (default: var(--dds-size-sm, 14px)) |
--dds-content-switcher-item-font-weight | The font weight of the content switcher item (default: var(--dds-weight-bold, 700)) |
--dds-content-switcher-item-border-radius | The border radius of the content switcher item (default: var(--dds-radius-large, 16px)) |
--dds-content-switcher-item-background | The background color of the content switcher item (default: transparent) |
--dds-content-switcher-item-color | The text color of the content switcher item (default: var(--dds-text-neutral-base)) |
--dds-content-switcher-item-border-color | The border color of the content switcher item (default: transparent) |
--dds-content-switcher-item-checked-background | The background color of the checked content switcher item (default: var(--dds-button-primary-background-enabled)) |
--dds-content-switcher-item-checked-color | The text color of the checked content switcher item (default: var(--dds-text-neutral-on-inverted)) |
--dds-content-switcher-item-checked-border-color | The border color of the checked content switcher item (default: var(--dds-border-neutral-transparent-interactive)) |