Skip to content

Segmented Switch

export function SegmentedSwitch<T extends SegmentedSwitchValue = SegmentedSwitchValue>(;

export type SegmentedSwitchRenderable = any;

export type SegmentedSwitchValue = string | number;

export type SegmentedSwitchOption<T extends SegmentedSwitchValue = SegmentedSwitchValue> = {
value: T;
label: SegmentedSwitchRenderable;
count?: number | string;
title?: string;
ariaLabel?: string;
disabled?: boolean;
className?: string;
testId?: string;
};

export type SegmentedSwitchRole = 'tablist' | 'radiogroup' | 'group';

export type SegmentedSwitchProps<T extends SegmentedSwitchValue = SegmentedSwitchValue> = {
value: T;
options: SegmentedSwitchOption<T>[];
onChange: (value: T, option: SegmentedSwitchOption<T>) => void;
ariaLabel?: string;
className?: string;
itemClassName?: string;
countClassName?: string;
activeClassName?: string;
disabled?: boolean;
role?: SegmentedSwitchRole;
testId?: string;
renderOption?: (option: SegmentedSwitchOption<T>, state: { active: boolean; disabled: boolean }) => SegmentedSwitchRenderable;
renderCount?: (option: SegmentedSwitchOption<T>, state: { active: boolean; disabled: boolean }) => SegmentedSwitchRenderable;
};