refactor(ui): replace Tooltip iconClassName with iconProps

Replace the string-only iconClassName prop on the Tooltip component
with a full iconProps object, allowing consumers to pass any Icon
prop (color, size, etc.) instead of relying on Tailwind class names.
This commit is contained in:
melvinchia3636
2026-06-26 15:24:42 +08:00
parent 9fb4bee10d
commit 7d5560cb4d
2 changed files with 7 additions and 5 deletions

View File

@@ -143,7 +143,9 @@ export const ErrorTooltip: Story = {
</>
),
icon: 'tabler:alert-circle',
iconClassName: 'text-red-500',
iconProps: {
color: 'red-500'
},
id: 'error-tooltip'
},
render: args => (

View File

@@ -2,7 +2,7 @@ import _ from 'lodash'
import { Tooltip as ReactTooltip } from 'react-tooltip'
import tinycolor from 'tinycolor2'
import { Box, Icon, Text } from '@/components/primitives'
import { Box, Icon, type IconProps, Text } from '@/components/primitives'
import { usePersonalization } from '@/providers'
/**
@@ -12,7 +12,7 @@ import { usePersonalization } from '@/providers'
export function Tooltip({
id,
icon,
iconClassName,
iconProps,
children,
...tooltipProps
}: {
@@ -21,7 +21,7 @@ export function Tooltip({
/** The icon to display as the tooltip trigger. Should be a valid icon name from Iconify. */
icon: string
/** Optional additional class name(s) to apply to the icon element. */
iconClassName?: string
iconProps?: Omit<IconProps, 'icon'>
/** The content to display inside the tooltip when triggered. */
children: React.ReactNode
/** Additional properties to pass to the underlying ReactTooltip component. */
@@ -31,7 +31,7 @@ export function Tooltip({
return (
<>
<span data-tooltip-id={`tooltip-${_.kebabCase(id)}`}>
<Icon className={iconClassName ?? ''} color="muted" icon={icon} />
<Icon color="muted" icon={icon} {...iconProps} />
</span>
<Box
asChild