UNPKG

@carbon/react

Version:

React components for the Carbon Design System

72 lines (71 loc) 1.96 kB
/** * Copyright IBM Corp. 2023, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import React, { HTMLAttributeAnchorTarget, KeyboardEvent, MouseEvent } from 'react'; export interface BaseSwitcherItemProps { /** * Specify the text content for the link */ children: React.ReactNode; /** * Optionally provide a custom class to apply to the underlying `<li>` node */ className?: string; /** * event handlers */ handleSwitcherItemFocus?: (event: { currentIndex: number; direction: number; }) => void; /** * Specify the index of the SwitcherItem */ index?: number; /** * event handlers */ onKeyDown?: (event: KeyboardEvent) => void; /** * event handlers */ onClick?: (event: MouseEvent<HTMLAnchorElement>) => void; /** * Specify the tab index of the Link */ tabIndex?: number; /** * Specify whether the panel is expanded */ expanded?: boolean; /** * Specify whether the panel is selected */ isSelected?: boolean; /** * Optionally provide an href for the underlying li` */ href?: string; /** * Specify where to open the link. */ target?: HTMLAttributeAnchorTarget; /** * The rel property for the link. */ rel?: string; } export interface SwitcherItemWithAriaLabel extends BaseSwitcherItemProps { 'aria-label': string; 'aria-labelledby'?: never; } export interface SwitcherItemWithAriaLabelledBy extends BaseSwitcherItemProps { 'aria-label'?: never; 'aria-labelledby': string; } export type SwitcherItemProps = SwitcherItemWithAriaLabel | SwitcherItemWithAriaLabelledBy; declare const SwitcherItem: React.ForwardRefExoticComponent<SwitcherItemProps & React.RefAttributes<React.ElementType>>; export default SwitcherItem;