The Dynamic Content Switch component is a navigation control that allows users to switch between different views or states in your application. It displays a series of clickable buttons arranged horizontally, where each button can trigger specific actions when clicked. This component is ideal for implementing tabbed interfaces, wizard-style navigation, or toggle functionality between different content sections.
contentSwitchButtons - Defines the collection of buttons displayed in the content switch. Each button has properties including text translations, events, and a unique ID. For example, [{textTranslations: {"en-US": "Details", "fr-FR": "Détails"}, id: "details", events: [...]}, {textTranslations: {"en-US": "History", "fr-FR": "Historique"}, id: "history", events: [...]}] creates a two-button content switch with localized labels.
activeButtonIndicator - Specifies a context key to determine which button should be active by default. For example, setting this to "activeTab" will make the component look for a value with this key in the component's context and activate the button with the matching ID. This enables dynamic activation of specific tabs based on application state.
paddingClass - Configures the padding around the component using CSS classes. For example, "p-4" adds medium padding on all sides of the component, while "px-3 py-2" adds different horizontal and vertical padding.
id - Specifies a unique identifier for the component used for programmatic access. For example, "navigationContentSwitch" enables targeted manipulation of this specific component in scripts or for automated testing.
dataTestId - Sets the testing hook ID for automated testing. For example, setting it to "main-navigation-tabs" allows test scripts to reliably locate this component during test execution.
enableAsHotspot - Enables the component as a guided tour hotspot. When enabled, this component can be highlighted in guided tours to help users understand its navigation functionality.
guidedTourHotSpotTitle - Sets the title for the guided tour hotspot with support for multiple languages. For example, {"en-US": "Navigation Options", "fr-FR": "Options de Navigation"} ensures proper localization of the hotspot title.
guidedTourHotSpotDescription - Sets the description for the guided tour hotspot with language support. For example, {"en-US": "Use these tabs to navigate between different sections of the application", "fr-FR": "Utilisez ces onglets pour naviguer entre différentes sections de l'application"} provides localized guidance about how to use the component.
Each button in the Content Switch component can trigger the following event type:
Tab Navigation: Create a set of tabs to switch between different views in a single page application.
Form Wizard: Implement step indicators for multi-step forms, showing the current step and allowing navigation between completed steps.
View Toggles: Create buttons to switch between different visualization modes, such as "Grid View" vs "List View".
Language Selector: Implement a language selection interface with buttons for each supported language.
When a button is clicked, the component:
The component can also automatically select a button on initialization if the activeButtonIndicator property is set and a matching value is found in the context.