shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Tooltip

A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.

package examples import (

Installation

shadcn-templ add tooltip

Usage

import "github.com/axadrn/shadcn-templ/v2/components/tooltip"
@tooltip.Tooltip() {	<button { tooltip.Trigger(ctx)... }>Hover</button>	@tooltip.Content() {		<p>Add to library</p>	}}

Composition

Use the following composition to build a Tooltip:

tooltip.Tooltip├── tooltip.Trigger└── tooltip.Content

Side

Use the Side prop to change the position of the tooltip.

package examples import (

With Keyboard Shortcut

package examples import (

Disabled Button

Show a tooltip on a disabled button by wrapping it with a span.

package examples import (

API Reference

Tooltip

The tooltip.Tooltip component is the root, it generates the id that links trigger and content.

TooltipTrigger

tooltip.Trigger(ctx) returns the attributes that turn any element into the tooltip trigger.

TooltipContent

The tooltip.Content component is the popup.

Prop Type Default
Side SideTop | SideRight | SideBottom | SideLeft SideTop
SideOffset int 4
Class string -