
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
headless-tooltip
Advanced tools
A lightweight, customizable tooltip component for React with zero styling opinions. Built with accessibility in mind.
If you find Headless-Tooltip useful, please consider giving it a ⭐
npm install headless-tooltip
yarn add headless-tooltip
pnpm add headless-tooltip
import Tooltip from 'headless-tooltip';
function Example() {
return (
<Tooltip content="This is a tooltip message">
<button>Hover me</button>
</Tooltip>
);
}
import Tooltip from 'headless-tooltip';
function StyledExample() {
return (
<Tooltip
content={<span>This is a tooltip message</span>}
placement="bottom"
arrow={true}
className="max-w-80 rounded-lg bg-gray-900 px-3 py-2 text-xs font-normal text-white"
arrowClassName="bg-gray-900"
>
<button className="px-4 py-2 bg-blue-500 text-white rounded">
Hover me
</button>
</Tooltip>
);
}
Prop | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | (required) | The element that triggers the tooltip |
content | React.ReactNode | (required) | The content to be displayed in the tooltip |
placement | PositionType | 'top' | Tooltip placement relative to the trigger element |
className | string | '' | Additional CSS classes to apply to the tooltip |
offset | number | 4 | Distance between tooltip and trigger element in pixels |
zIndex | number | undefined | Z-index value for the tooltip |
open | boolean | undefined | Control tooltip visibility (makes it a controlled component) |
openDelay | number | 300 | Delay in ms before showing the tooltip |
closeDelay | number | 200 | Delay in ms before hiding the tooltip |
disableInteractive | boolean | false | If true, tooltip will close when mouse leaves trigger |
onOpenChange | (open: boolean) => void | undefined | Callback when tooltip visibility changes |
portalContainer | HTMLElement | document.body | DOM element where tooltip portal will be rendered |
arrow | boolean | false | Whether to show an arrow pointing to the trigger |
arrowSize | number | 12 | Size of the arrow in pixels |
arrowClassName | string | undefined | Additional CSS classes to apply to the arrow |
The placement
prop accepts the following values:
'top'
'right'
'bottom'
'left'
'top-start'
'top-end'
'right-start'
'right-end'
'bottom-start'
'bottom-end'
'left-start'
'left-end'
This tooltip implementation follows the WAI-ARIA Tooltip Pattern to ensure accessibility compliance:
role="tooltip"
, aria-describedby
)The component is compatible with all modern browsers:
import { useState } from 'react';
import Tooltip from 'headless-tooltip';
function ControlledExample() {
const [isOpen, setIsOpen] = useState(false);
return (
<div>
<button onClick={() => setIsOpen(!isOpen)}>Toggle Tooltip</button>
<Tooltip
content="This is a controlled tooltip"
open={isOpen}
onOpenChange={setIsOpen}
>
<button>Hover me too</button>
</Tooltip>
</div>
);
}
import Tooltip from 'headless-tooltip';
function InteractiveExample() {
return (
<Tooltip
content={
<div>
<p>Interactive tooltip with a button:</p>
<button onClick={() => alert('Clicked!')}>Click me</button>
</div>
}
disableInteractive={false}
>
<button>Hover for interactive tooltip</button>
</Tooltip>
);
}
Contributions are always welcome! Please feel free to submit a Pull Request.
FAQs
A minimal, accessible, and unstyled tooltip component for React
The npm package headless-tooltip receives a total of 365 weekly downloads. As such, headless-tooltip popularity was classified as not popular.
We found that headless-tooltip demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.