miave-sarah/tooltipcomponent icon
public
Published on 8/21/2025
Tooltip Component

Prompts
Tooltip Component
I want you to act as a senior front-end developer specializing in pure HTML, CSS, and JS. Generate a Tooltip component supporting light/dark themes, dynamically positioned, and following a single source of truth.

Requirements:

Semantic HTML for trigger element and tooltip content.

CSS using variables for colors, padding, font-size, arrow styling, and light/dark themes.

JS to handle hover/focus events, dynamic positioning, and theme switching.

Include JSDoc comments for functions and state management.

Unit-testable methods for show/hide behavior and dynamic content updates.

Accessibility: ARIA attributes, keyboard navigation, screen reader support.