mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-27 05:20:36 +03:00
32 lines
768 B
TypeScript
32 lines
768 B
TypeScript
![]() |
interface SwitchButtonProps<ValueType> {
|
||
|
id?: string
|
||
|
value: ValueType
|
||
|
label?: string
|
||
|
icon?: React.ReactNode
|
||
|
tooltip?: string
|
||
|
dimensions?: string
|
||
|
|
||
|
isSelected?: boolean
|
||
|
onSelect: (value: ValueType) => void
|
||
|
}
|
||
|
|
||
|
function SwitchButton<ValueType>({
|
||
|
value, icon, label, tooltip,
|
||
|
dimensions='w-fit h-fit',
|
||
|
isSelected, onSelect, ...props
|
||
|
}: SwitchButtonProps<ValueType>) {
|
||
|
return (
|
||
|
<button type='button' tabIndex={-1}
|
||
|
title={tooltip}
|
||
|
onClick={() => onSelect(value)}
|
||
|
className={`px-2 py-1 border font-semibold small-caps rounded-none cursor-pointer clr-btn-clear clr-hover ${dimensions} ${isSelected ? 'clr-selected': ''}`}
|
||
|
{...props}
|
||
|
>
|
||
|
{icon && icon}
|
||
|
{label}
|
||
|
</button>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
export default SwitchButton;
|