Skip to content

refactor(ui): migrate Tooltip from HeroUI to shadcn/Radix UI#13563

Open
DeJeune wants to merge 2 commits intov2from
DeJeune/tooltip-shadcn
Open

refactor(ui): migrate Tooltip from HeroUI to shadcn/Radix UI#13563
DeJeune wants to merge 2 commits intov2from
DeJeune/tooltip-shadcn

Conversation

@DeJeune
Copy link
Collaborator

@DeJeune DeJeune commented Mar 17, 2026

What this PR does

Before this PR:
Tooltip component in @cherrystudio/ui was a wrapper around @heroui/react Tooltip, making it the last HeroUI dependency in the UI package.

After this PR:
Tooltip is fully implemented with @radix-ui/react-tooltip, matching the Figma design specs (background, border, rounded corners, shadow, arrow). The flat API (content, placement, delay, closeDelay, showArrow, classNames, isOpen, onClick) is preserved — zero changes needed in 100+ consumer files.

Why we need it and why it was done in this way

The v2 refactoring requires removing HeroUI from @cherrystudio/ui. Tooltip was the last remaining HeroUI component. A backward-compatible wrapper approach was chosen to avoid touching 100+ consumer files while still fully replacing the underlying implementation.

The following tradeoffs were made:

  • Kept the HeroUI-style flat API instead of switching consumers to Radix compound components, to minimize migration scope
  • closeDelay > 0 is handled via controlled state with setTimeout (only 1 consumer uses non-zero closeDelay)

The following alternatives were considered:

  • Migrating all 100+ consumers to Radix compound component API — rejected due to excessive scope
  • A pre-existing tooltip_new.tsx with compound API was consolidated into the main tooltip.tsx

Breaking changes

None. The exported TooltipProps interface is narrower than the previous HeroUI-derived type, but all props actually used by consumers are preserved. New compound component exports (TooltipProvider, TooltipRoot, TooltipTrigger, TooltipContent, NormalTooltip) are added for advanced usage.

Special notes for your reviewer

  • @heroui/react fully removed from packages/ui (peerDeps, devDeps, tsdown externals, source imports)
  • Figma design: bg-background border-border rounded-lg px-4 py-3 shadow-[0px_6px_12px_0px_rgba(0,0,0,0.2)]
  • 14 unit tests added covering fallback rendering, classNames, onClick, and controlled mode
  • parsePlacement() maps all HeroUI placement values to Radix side+align

Checklist

  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: You have left the code cleaner than you found it (Boy Scout Rule)
  • Upgrade: Impact of this change on upgrade flows was considered and addressed if required
  • Documentation: A user-guide update was considered and is present (link) or not required.
  • Self-review: I have reviewed my own code before requesting review from others

Release note

NONE

Replace the HeroUI Tooltip wrapper with a Radix UI implementation
matching the Figma design specs. The flat API (content, placement,
delay, closeDelay, showArrow, classNames, isOpen, onClick) is fully
preserved so 100+ consumer files require zero changes.

- Rewrite tooltip.tsx with @radix-ui/react-tooltip primitives
- Add placement mapping (HeroUI placement -> Radix side+align)
- Add controlled mode support (isOpen, onOpenChange, closeDelay)
- Export compound components (TooltipProvider, TooltipRoot, etc.)
- Delete redundant tooltip_new.tsx (consolidated into tooltip.tsx)
- Remove @heroui/react from packages/ui peerDeps and devDeps
- Remove @heroui/react and @heroui/theme from tsdown externals
- Add 14 unit tests for tooltip component

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
@DeJeune DeJeune requested a review from a team March 17, 2026 15:13
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
@DeJeune DeJeune added the v2 label Mar 17, 2026
@DeJeune DeJeune added this to the v2.0.0 milestone Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant