Skip to content

Commit

Permalink
add iconTitle to ToggleGroupItem
Browse files Browse the repository at this point in the history
  • Loading branch information
Magnusrm committed Oct 5, 2023
1 parent 50f4eee commit add8b17
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cn from 'classnames';

import { Button } from '../../Button';
import { RovingTabindexItem } from '../../../utility-components/RovingTabIndex';
import utilityClasses from '../../../utils/utility.module.css';

import classes from './ToggleGroupItem.module.css';
import { useToggleGroupItem } from './useToggleGroupitem';
Expand All @@ -13,6 +14,8 @@ export type ToggleGroupItemProps = {
value?: string;
/** Icon to be displayed on the ToggleGroupItem */
icon?: React.ReactNode;
/** Title for icon when only icons are used */
iconTitle?: string;
/** The text to be displayed on the ToggleGroupItem */
children?: string;
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'children'>;
Expand All @@ -21,7 +24,7 @@ export const ToggleGroupItem = forwardRef<
HTMLButtonElement,
ToggleGroupItemProps
>((props, ref) => {
const { children, icon, ...rest } = props;
const { children, icon, iconTitle, ...rest } = props;
const { active, size = 'medium', buttonProps } = useToggleGroupItem(props);
return (
<RovingTabindexItem
Expand All @@ -41,6 +44,9 @@ export const ToggleGroupItem = forwardRef<
iconPlacement='left'
ref={ref}
>
{iconTitle && (
<span className={utilityClasses.visuallyHidden}>{iconTitle}</span>
)}
{children}
</RovingTabindexItem>
);
Expand Down

0 comments on commit add8b17

Please sign in to comment.