Tooltip

A short hint on hover or focus: a shortcut or a cut-off name. The first waits; its neighbours show at once.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/tooltip

Usage

import { Tip } from "./ui/uicontext/components/Tip.ts"
const Message = UiSchema.TaggedEnum({ RequestedOpenTip: {}, RequestedCloseTip: {} })export const ArchiveTip = (h: Html.H<typeof Message.Type>, open: boolean) =>	Tip(h, {		open,		text: "Archive  E",		onRequestedOpen: Message.RequestedOpenTip(),		onRequestedClose: Message.RequestedCloseTip(),		trigger: (tooltip) => tooltip.trigger(h.button).attrs({ type: "button" }).children("Archive"),	})

Examples

Full name of a cut-off file

Only the names cut short get a tip. It sits below, and the link's label is the whole name.

API reference

Options

Tip options
NameTypeDefaultDescription
keystring—Names the tooltip among others in the same view; needed for more than one
openrequiredboolean——
textrequiredstring——
onRequestedOpenrequiredMessage——
onRequestedCloserequiredMessage——
describesTriggerbooleanTrueThe tip adds to the trigger's label (a shortcut, a detail), so it's also the trigger's accessible description; leave it off when it repeats the label. True by default.
side"top" | "bottom"——
triggerrequired(tooltip: TipParts<Message>) => View.Input—The trigger: apply tooltip.trigger to a button or link builder

Source