shadcn.io is an independent project built on shadcn/ui
On this page9 sections
A hint is a one-line note with an arrow that appears beside a control on hover or focus. It is positioned with CSS inside its own wrapper, with no portal or delay, for a toolbar or form with space around it.
Inside a parent that hides its overflow, such as a scrolling table, use a Tooltip, which renders in a portal. Content people click belongs in a Popover.
Installation
Anatomy

Usage
import { Button } from "@/components/ui/button";
import { Hint, HintContent, HintTrigger } from "@/components/ui/hint";The note is placed against the Hint wrapper, a block element as wide as its parent, so keep the wrapper as narrow as its trigger, as the width class here does.
<Hint class="w-fit">
<HintTrigger
asChild={(props) => (
<Button {...props()} variant="outline">Archive</Button>
)}
/>
<HintContent>Moves the project out of your list</HintContent>
</Hint>Accessibility
HintTrigger renders a button, or the element you pass it with asChild, and points aria-describedby at HintContent, which has role="tooltip". The note is the control's description, not its name, so an icon button still needs an aria-label. Focus opens the hint and blur closes it. Escape closes it without moving focus or the pointer, and the pointer can cross from the trigger onto the note and back without closing it. The content is only in the DOM while it shows. Set lazyMount and unmountOnExit to false on HintContent to keep it there, hidden, so the description exists before the first focus.
- Tab
- Moves focus to the trigger, which opens the hint, or on from it, which closes the hint.
- Shift+Tab
- Moves focus back to the trigger, which opens the hint, or away from it, which closes the hint.
- EscEscape
- Closes an open hint, whether focus or the pointer opened it. Focus stays where it is.
Demos
Controlled
A secondary button with a hint, and below it an outline button that shows or hides that hint by flipping the same open state. Hover and focus still work, because onOpenChange writes back to that state. Control the hint when something besides the pointer should show it, such as a failed check on a field or a step in an onboarding tour.
Positions
Four buttons, each with positioning set to a different placement: left, top, bottom and right. Top is the default. Nothing flips the note when it runs out of room, so pick the side that has space, such as bottom for a button at the top of a panel, or right for the first button in a row.
Long note
An Archive project button whose note runs to two sentences, about what archiving does and where to undo it. HintContent gets w-60 and min-w-0, so the note wraps at 240 pixels instead of running on in one line. Use it when a control needs a sentence about its consequences, and move anything people click into a Popover.
FAQ
Should I use a Hint or a Tooltip?
Use a Tooltip unless you have a reason not to. It renders in a portal, so no parent can clip it, and it moves to another side when it would leave the screen.
A Hint is a few lines of state and CSS with no positioning library. It renders next to its trigger rather than at the end of the page, opens with no delay and always sits on the side you set, which suits a toolbar or a settings row with open space around it. For a preview people move the pointer into, use a Hover Card.
How do I open a Hint from code in Solid?
Keep a boolean in state, pass it as open and set it in onOpenChange, which receives the next boolean. Once open is set, hover, focus and Escape only call onOpenChange, so the hint shows what your state says, as in the Controlled demo.
To have it start open and then follow hover and focus on its own, use defaultOpen instead, which sets only the first state.
How do I show a Hint below or beside its trigger?
Set positioning on Hint to an object with placement set to top, bottom, left or right, as the Positions demo does. Top is the default.
The same object takes gutter, the gap between the trigger and the note, as a CSS length such as 6px. It defaults to 10px and is written to the --gutter variable on the wrapper. The hint never changes side by itself, so choose one with room.
Why is my Hint cut off or hidden behind other content?
Because it renders where it is. HintContent is absolutely positioned inside the Hint wrapper with a z-index of 50, so any ancestor that hides or scrolls its overflow cuts it off at its edge, and an ancestor with its own stacking context, such as one with a transform, can put it under content that comes later.
Move the hint out of that ancestor, or use a Tooltip, which renders in a portal at the end of the page and can't be clipped this way.
Why isn't my Hint centered over its trigger?
The note is placed against the Hint wrapper, not the trigger, and the wrapper is a div that fills the width of its parent in normal flow. Give the wrapper a width class that shrinks it to its content, as the Usage example does, or place it in a flex row, where it already takes only the trigger's width.
Can keyboard and screen reader users use a Hint?
Keyboard users get it when they tab to the trigger, since focus opens the hint and blur closes it. The trigger has to be focusable for that, so keep it a button or a link rather than an icon or a span.
For screen readers, aria-describedby on the trigger points at the note, which has role="tooltip". The note is only in the DOM while it shows, unless you set lazyMount and unmountOnExit to false on HintContent. Escape closes it without moving focus, and pointer users can move onto the note to read it, as WCAG asks of content that appears on hover or focus.
How do I make a long Hint wrap or change its colors?
The note keeps to one line, however long, because HintContent has a minimum width of its full text. To wrap it, give HintContent a fixed width and a zero minimum width with classes such as w-60 and min-w-0, and they replace the defaults, as in the Long note demo.
The colors are the theme's foreground for the bubble and background for the text, with the same foreground on the arrow. HintContent draws the arrow itself, so change those colors, or remove the arrow, in components/ui/hint, which is your code once installed.
How do I use my own button as the Hint trigger?
Pass asChild a function that returns your button with props() spread on it, as every demo does. The hint's focus and mouse handlers and its aria-describedby land on your button.
Your classes and your own focus or mouse handlers can go on either one. A class on HintTrigger joins the button's own, and a handler on it runs before the one that opens or closes the hint. Without asChild, HintTrigger is a plain button of type button, so it doesn't submit a form around it.
API Reference
Hint
<div>
open?boolean
Controlled open state. When set, defaultOpen is ignored.
defaultOpen?boolean
Initial open state when uncontrolled.
- Default
false
onOpenChange?(open: boolean) → void
Called when the open state should change (hover/focus or programmatic updates).
- Parameters
open– boolean- Returns
void
positioning?{ /** * The gutter from the trigger in pixels. * * @default "10px" */ gutter?: string; /** * The placement of the hint relative to the trigger. * * @default "top" */ placement?: "top" | "bottom" | "left" | "right"; }
Placement and gutter of the hint.
- Type
{ /** * The gutter from the trigger in pixels. * * @default "10px" */ gutter?: string; /** * The placement of the hint relative to the trigger. * * @default "top" */ placement?: "top" | "bottom" | "left" | "right"; }
asChild?(props: ParentProps) => JSX.Element
Render your own element: a function that gets the part's props to spread on it.
- Type
(props: ParentProps) => JSX.Element
class?string
Merged with the part's classes.
HintTrigger
<button> data-slot="hint-trigger"
asChild?(props: ParentProps) => JSX.Element
Render your own element: a function that gets the part's props to spread on it.
- Type
(props: ParentProps) => JSX.Element
class?string
Forwarded to the part.
data-state?string
"open" when isVisible is true, otherwise "closed".
--gutterstringHintContent
<div> data-slot="hint-content"
placement?"bottom" | "left" | "right" | "top"
The side of the trigger it's on.
- Type
"bottom" | "left" | "right" | "top"- Default
"top"
asChild?(props: ParentProps) => JSX.Element
Render your own element: a function that gets the part's props to spread on it.
- Type
(props: ParentProps) => JSX.Element
class?string
Merged with the part's classes.
data-placement?string
Mirrors placement.
data-state?string
"open" when isVisible is true, otherwise "closed".
HintArrow
<div> data-slot="hint-arrow"
asChild?(props: ParentProps) => JSX.Element
Render your own element: a function that gets the part's props to spread on it.
- Type
(props: ParentProps) => JSX.Element
class?string
Merged with the part's classes.
data-placement?string
Mirrors placement.











