@carbon/react
Version:
React components for the Carbon Design System
56 lines (55 loc) • 1.78 kB
TypeScript
/**
* Copyright IBM Corp. 2016, 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, { MouseEvent } from 'react';
import { PolymorphicProps } from '../../types/common';
import { SIZES } from './Tag';
export interface SelectableTagBaseProps {
/**
* Provide a custom className that is applied to the containing <span>
*/
className?: string;
/**
* Specify if the `SelectableTag` is disabled
*/
disabled?: boolean;
/**
* Specify the id for the selectable tag.
*/
id?: string;
/**
* A component used to render an icon.
*/
renderIcon?: React.ElementType;
/**
* Provide an optional hook that is called when selected is changed
*/
onChange?: (selected: boolean) => void;
/**
* Provide an optional function to be called when the tag is clicked.
*/
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
/**
* Specify the state of the selectable tag.
*/
selected?: boolean;
/**
* Specify the default state of the selectable tag.
*/
defaultSelected?: boolean;
/**
* Specify the size of the Tag. Currently supports either `sm`,
* `md` (default) or `lg` sizes.
*/
size?: keyof typeof SIZES;
/**
* Provide text to be rendered inside of a the tag.
*/
text?: string;
}
export type SelectableTagProps<T extends React.ElementType> = PolymorphicProps<T, SelectableTagBaseProps>;
declare const SelectableTag: React.ForwardRefExoticComponent<Omit<SelectableTagProps<React.ElementType<any, keyof React.JSX.IntrinsicElements>>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
export default SelectableTag;