GooseUI

Components

Responsive Hint

New

A help icon. With a mouse it shows a tooltip on hover and keyboard focus, on touch devices and narrow screens it opens a bottom sheet with the same content and title. It ships no JavaScript: the tooltip is shown by CSS, the sheet is a native popover, and the (hover: hover) and (pointer: fine) media query plus a width breakpoint pick the mode. It works with JavaScript turned off.

Browser Support

Popover

Opens and closes the popup

Your browser:
@starting-style

Animates the initial appearance

Your browser:
:has()

Styles elements based on their contents

Your browser:
Anchor positioning

Positions the popup near its trigger

Your browser:
::backdrop

Styles the mobile popover backdrop

Your browser:
transition-behavior

Animates the popover closing

Your browser:

Preview

Hover the icons. On a phone or in a narrow window they open a sheet instead.

ShippingHow shipping is calculatedThe price depends on parcel weight and distance. Orders over 50 units ship free.How shipping is calculatedThe price depends on parcel weight and distance. Orders over 50 units ship free.4.90
Service feeCovers card processing and support.More informationCovers card processing and support.0.99

Installation

npx shadcn@latest add @gooseui/responsive-hint
pnpm dlx shadcn@latest add @gooseui/responsive-hint
yarn dlx shadcn@latest add @gooseui/responsive-hint
bunx --bun shadcn@latest add @gooseui/responsive-hint

Usage

import { ResponsiveHint } from "@/components/ui/responsive-hint"

export default function Price() {
  return (
    <span className="flex items-center gap-1.5">
      Shipping
      <ResponsiveHint title="How shipping is calculated">
        The price depends on parcel weight and distance.
      </ResponsiveHint>
    </span>
  )
}

Examples

Always a sheet

mode="sheet" or mode="tooltip" turns the media query off.

Press the iconReturnsYou can return the item within 30 days. Keep the box and the receipt.ReturnsYou can return the item within 30 days. Keep the box and the receipt.
<ResponsiveHint mode="sheet" title="Returns">
  You can return the item within 30 days.
</ResponsiveHint>

Custom icon and breakpoint

Any icon works as the trigger. breakpoint sets the width below which the sheet is used even with a mouse.

Hint on the rightBelow 1024px this becomes a sheet.More informationBelow 1024px this becomes a sheet.
import { Info } from "lucide-react"

<ResponsiveHint side="right" icon={<Info />} breakpoint={1024}>
  Below 1024px this becomes a sheet.
</ResponsiveHint>

Props

PropTypeDefaultDescription
childrenReactNode-Hint content, the same in both modes
titleReactNode-Heading. In the sheet it becomes the dialog title
iconReactNodehelp iconTrigger icon
breakpointnumber768Width in px below which the sheet is used
mode"auto" | "tooltip" | "sheet""auto"Force a mode instead of the media query
side"top" | "right" | "bottom" | "left""top"Tooltip side
align"start" | "center" | "end""center"Tooltip alignment
delayDurationnumber150Hover delay before the tooltip shows, ms (transition-delay)
labels{ trigger?: string; close?: string; title?: string }-Texts: trigger (aria-label), close, title (hidden dialog title)
contentClassNamestring-Classes for the tooltip or the sheet
classNamestring-Classes for the trigger

Features

  • Two modes: a CSS tooltip for mouse users, a popover bottom sheet for touch. Media queries pick the mode, so nothing jumps after hydration
  • Accessible: the trigger is a button with aria-label and aria-describedby pointing to the tooltip. The sheet has a title, Escape and a tap outside close it, focus returns to the button
  • Limits: Escape does not hide a tooltip opened by keyboard focus, move focus away instead. The content is rendered twice, so avoid ids inside children
  • Reduced motion: the sheet appears without sliding