pesde goatsoft / lucy

Tooltip

A floating label or small card attached to a screen control or to a part in the world.

Tooltip exampleTooltip example
local buy = Lucy.Button.new({
    text = "Moonwalk",
    icon = "lucide-extended:sparkles-filled",
    Parent = shopRow,
})

local tip = Lucy.Tooltip.new({
    target = buy,
    text = "<b>100</b> coins in the Emote Shop",
    textProps = { richText = true },
    side = "top",
})

On mouse, hovering the button waits a short delay and opens the tooltip; moving off closes it. On gamepad and keyboard, selecting the button opens it. On touch, a long press opens it. Only one hover tooltip opens at a time, and moving onto another button opens the next one right away while the tip group is warm.

Triggers

Choose how the tooltip opens with trigger (a single name or a list, such as { "hover", "focus" }):

TriggerShowsHides
"hover"Pointer rests on target (plus gamepad focus and touch long press)Pointer leaves (after closeDelay)
"focus"Gamepad or keyboard selection lands on targetSelection leaves
"press" / "hold"Press down on targetRelease
"click" / "toggle"Click or tap on targetNext click, press outside, or Back
"proximity"Character enters distance studs of a world targetCharacter leaves distance + hysteresis studs
"always"Starts openOnly if hidden in code or open is set to false
"manual"Only via :show() or openOnly via :hide() or open

A hold-to-peek tooltip on a locked emote:

Tooltip exampleTooltip example
local locked = Lucy.Button.new({ text = "Moonwalk", variant = "outline", Parent = shopRow })

local lockedTip = Lucy.Tooltip.new({
    target = locked,
    trigger = "press",
    text = "Reach level 15 in Club Lucy to unlock",
})

An interactive card on a track's info button that stays open while the pointer crosses onto it and includes a button:

Tooltip exampleTooltip example
local info = Lucy.Button.new({
    icon = "lucide-extended:disc-3-filled",
    size = "icon",
    variant = "ghost",
    Parent = shopRow,
})

local infoTip = Lucy.Tooltip.new({
    target = info,
    trigger = "click",
    interactive = true,
    content = function(tip)
        return Lucy.Stack.new({
            gap = "Space2",
            children = {
                Lucy.Text.new({ text = "Neon Nights by DJ Lucy (124 BPM)", autoWidth = true }),
                Lucy.Button.new({
                    text = "Queue track",
                    size = "sm",
                    onClick = function()
                        queueTrack("neon-nights")
                        tip:hide()
                    end,
                }),
            },
        })
    end,
})

Placement and arrow

  • side: "top", "bottom", "left", "right" or "auto".
  • align: "start", "center" or "end".
  • placement: shorthand such as "top-start" or "bottom-end".
  • sideOffset / offset: gap in pixels from a screen target (default 8), or studsOffset in studs for a world target.
  • alignOffset: offset in pixels along the alignment edge (default 0).
  • avoidCollisions: flips or shifts the tooltip to keep it inside the screen (default true; set false to keep its placement fixed).
  • collisionPadding: screen edge margin in pixels (default 8).
  • flip: flips to the opposite side when there is not enough room on screen (default true).
  • arrow: draws the directional notch centred on target (default true). Read tip.arrowDirection() for "down", "up", "left" or "right".
  • arrowPadding: minimum room in pixels kept between the arrow and rounded corners (default 6).

Variants, border, fill and transparency

variant picks a look from the theme: default, inverse, primary, secondary, outline, destructive or overlay.

Tooltip exampleTooltip example
Lucy.Stack.new({
    direction = "horizontal",
    gap = "Space2",
    wrap = true,
    children = {
        Lucy.Tooltip.new({ text = "default", variant = "default" }),
        Lucy.Tooltip.new({ text = "inverse", variant = "inverse" }),
        Lucy.Tooltip.new({ text = "primary", variant = "primary" }),
        Lucy.Tooltip.new({ text = "secondary", variant = "secondary" }),
        Lucy.Tooltip.new({ text = "outline", variant = "outline" }),
        Lucy.Tooltip.new({ text = "destructive", variant = "destructive" }),
        Lucy.Tooltip.new({ text = "overlay", variant = "overlay" }),
    },
    Parent = parent,
})
  • size: "sm", "md" or "lg".
  • border: true or false to force or remove the border, or a token/colour such as "$Ring".
  • fill: override the body and arrow fill with a token ("$Card") or Color3.
  • transparency: background transparency (0 to 1) for both body and arrow.
  • radius: corner radius override (token, UDim, or pixels).

Register custom variants once with Lucy.Tooltip.addVariant:

Lucy.Tooltip.addVariant("vip", {
    { selector = "", properties = { BackgroundColor3 = "$Warning", TextColor3 = "$WarningForeground" } },
    { selector = "::UIStroke", properties = { Color = "$Warning" } },
})

Text options and custom content

text renders with Text (tip.label). Any Text option (richText, variant, align, value, count, reveal, fit, reserve) can be passed through textProps:

Lucy.Tooltip.new({
    target = payoutBadge,
    textProps = {
        value = function() return coins() end,
        count = 0.5,
        format = function(n) return `{Lucy.Format.number(n)} coins` end,
    },
})

Pass children or content to place any Lucy component inside the tooltip. By default a tooltip's variant colours its label and any child Text to match; setting textProps = { variant = ... } or giving a child Text its own colour variant (such as "muted" or "warning") overrides the tooltip's text colour.

In the world

Set target to a BasePart, Attachment or Model to hang the tooltip in a billboard over that object:

Tooltip exampleTooltip example
-- Crew name tag always shown above Kai
Lucy.Tooltip.new({
    target = workspace.Crew.Kai.Head,
    trigger = "always",
    side = "top",
    arrow = false,
    variant = "overlay",
    children = {
        Lucy.Stack.new({
            direction = "horizontal",
            gap = "Space2",
            align = "center",
            children = {
                Lucy.Avatar.new({ name = "Kai", size = "sm" }),
                Lucy.Text.new({ text = "Kai", autoWidth = true }),
                Lucy.Badge.new({ text = "VIP", variant = "secondary" }),
            },
        }),
    },
})

-- Wardrobe mirror hint shown when walking close
Lucy.Tooltip.new({
    target = workspace.Wardrobe.Mirror,
    trigger = "proximity",
    distance = 10,
    text = "Try on outfits in the Wardrobe",
})

Props

PropTypeDefaultState keyWhat it does
targetGuiObject, BasePart, Attachment, Model, handle or idWhat the tooltip attaches to
textstring""yesText rendered with Lucy.Text
textPropstableOptions forwarded to Lucy.Text
childrentableComponents placed inside the body
contentanyBuilder function(tip) or component placed inside
triggerstring or table"hover"hover, focus, press, hold, click, toggle, proximity, always, manual
distancenumber12yesProximity range in studs
hysteresisnumber1Extra studs needed to leave proximity
lineOfSightbooleanfalseRequire an unobstructed raycast for proximity
sidestring"top"yestop, bottom, left, right or auto
alignstring"center"yesstart, center or end
placementstringCombined side-align shorthand such as "top-start"
sideOffset / offsetnumber8yesPixel gap from a screen target
alignOffsetnumber0yesPixel offset along the alignment edge
studsOffsetnumber0.5Stud gap from a world target
avoidCollisionsbooleantrueFlip and shift automatically to stay inside the screen
collisionPaddingnumber8Screen edge margin in pixels
flipbooleantrueFlip side when there is more room opposite
arrowbooleantrueyesShow the directional arrow
arrowPaddingnumber6Room kept between the arrow and rounded corners
variantstring"default"yesdefault, inverse, primary, secondary, outline, destructive, overlay or registered
sizestring"md"yessm, md or lg
borderboolean, string or Color3Force/hide border or set border colour
fillstring or Color3Override background fill
transparencynumberOverride background transparency (0 to 1)
radiusstring, UDim or numberOverride corner radius
interactivebooleanfalseAllow moving pointer onto the tooltip
openbooleanfalseyesWhether it is open (true when trigger = "always")
visiblebooleantrueyesMaster visibility toggle
onOpenChangefunctionCalled with (open, tip) when open changes

It also takes the props every component takes.

Methods and parts

  • tip:show(), tip:hide(), tip:toggle()
  • tip.open(): tracked boolean getter
  • tip.side(): tracked side after flipping
  • tip.arrowDirection(): tracked direction ("down", "up", "left", "right")
  • tip.body, tip.arrow, tip.stroke, tip.arrowStroke, tip.label

Preview

In Studio, from the command bar: Lucy.Preview.show("Tooltip").