npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@choice-ui/hint

v0.0.4

Published

A hint component that displays helpful information or tips in a floating tooltip

Readme

Hint Component

A contextual information tooltip component that displays helpful information on hover or focus. The Hint component provides a clean, accessible way to show additional information without cluttering the interface.

Overview

The Hint component creates a floating tooltip that appears when users hover over or focus on the trigger element. It uses Floating UI for precise positioning and supports customizable placement, content, and styling options.

Usage

Basic Usage

import { Hint } from "~/components/hint"

export function Example() {
  return (
    <div className="flex items-center gap-2">
      <span className="font-strong">Reason</span>
      <Hint content="Optional reason" />
    </div>
  )
}

Custom Icon

import { CircleInfoLargeSolid } from "@choiceform/icons-react"
import { Hint } from "~/components/hint"

export function CustomIconExample() {
  return (
    <Hint
      icon={<CircleInfoLargeSolid />}
      content="Custom icon tooltip"
    />
  )
}

Different Placements

import { Hint } from "~/components/hint"

export function PlacementExample() {
  return (
    <div className="flex flex-col gap-4">
      <div className="flex items-center gap-2">
        <Hint
          content="Left-positioned tooltip"
          placement="left-start"
        />
        <span>Left placement</span>
      </div>

      <div className="flex items-center gap-2">
        <span>Right placement</span>
        <Hint
          content="Right-positioned tooltip"
          placement="right-start"
        />
      </div>
    </div>
  )
}

Props

| Prop | Type | Default | Description | | -------------- | ------------------------------- | ------------------------- | --------------------------------------------------- | | content | ReactNode | - | Required. The content to display in the tooltip | | placement | "left-start" \| "right-start" | "right-start" | Position of the tooltip relative to the trigger | | icon | ReactNode | <InfoCircle /> | The icon to display in the trigger button | | disabled | boolean | false | Whether the tooltip is disabled | | open | boolean | - | Controlled open state of the tooltip | | onOpenChange | (open: boolean) => void | - | Callback when the open state changes | | variant | "default" \| "dark" | "default" | Visual variant of the tooltip | | className | string | - | Additional CSS classes for the trigger | | children | ReactNode | - | Custom trigger content (overrides default icon) | | portalId | string | "floating-tooltip-root" | ID of the portal container |

Features

Placement Options

  • left-start: Tooltip appears to the left, aligned to the start
  • right-start: Tooltip appears to the right, aligned to the start (default)

Content Handling

  • Supports both text and JSX content
  • Automatically wraps long content for optimal readability
  • Maintains consistent spacing and typography

Accessibility

  • Keyboard navigation support
  • Proper ARIA attributes
  • Focus management
  • Screen reader compatible

Interaction States

  • Default: Normal interactive state with hover/focus triggers
  • Disabled: Prevents interaction and tooltip display
  • Controlled: Can be controlled externally via open prop

Visual Variants

  • Default: Light background with dark text
  • Dark: Dark background with light text

Examples

Long Content

<Hint
  content="This is a very long information tooltip that demonstrates automatic text wrapping and maintains appropriate width for optimal readability."
  placement="right-start"
/>

Disabled State

<Hint
  content="This tooltip is disabled"
  disabled={true}
/>

Dark Variant

<Hint
  content="Dark themed tooltip"
  variant="dark"
/>

Controlled State

import { useState } from "react"
import { Hint } from "~/components/hint"

export function ControlledExample() {
  const [open, setOpen] = useState(false)

  return (
    <Hint
      content="Controlled tooltip"
      open={open}
      onOpenChange={setOpen}
    />
  )
}

Architecture

The Hint component uses a compound component pattern with the following structure:

  • Hint: Main component that provides context and manages state
  • HintTrigger: The clickable/hoverable element that triggers the tooltip
  • HintContent: The floating content that appears on interaction

Styling

The component uses Tailwind CSS for styling with support for:

  • Responsive design
  • Dark mode compatibility
  • Custom theming through CSS variables
  • Consistent spacing and typography

Best Practices

  1. Content: Keep tooltip content concise but informative
  2. Placement: Choose placement based on available space and content flow
  3. Accessibility: Ensure tooltips enhance rather than hinder user experience
  4. Performance: Use controlled state sparingly for better performance
  5. Context: Place hints near relevant form fields or complex interface elements