Tooltip

Displays a message when the user hovers over an element.
Tooltip
Properties
children
Example
Source Code
Installation
"use client";

import React from "react";
import { Tooltip } from "@/subframe/components/Tooltip";
import * as SubframeCore from "@subframe/core";
import { Button } from "@/subframe/components/Button";

function TooltipExample() {
  return (
    <SubframeCore.Tooltip.Provider>
      <SubframeCore.Tooltip.Root>
        <SubframeCore.Tooltip.Trigger asChild={true}>
          <Button onClick={(event: React.MouseEvent<HTMLButtonElement>) => {}}>
            Tooltip Button
          </Button>
        </SubframeCore.Tooltip.Trigger>
        <SubframeCore.Tooltip.Portal>
          <SubframeCore.Tooltip.Content
            side="bottom"
            align="center"
            sideOffset={4}
            asChild={true}
          >
            <Tooltip>Tooltip</Tooltip>
          </SubframeCore.Tooltip.Content>
        </SubframeCore.Tooltip.Portal>
      </SubframeCore.Tooltip.Root>
    </SubframeCore.Tooltip.Provider>
  );
}

export default TooltipExample;

Props

Tooltip
Prop
Type
Default
Additional info
children
string
"Tooltip"

Examples

Basics

Wrap your content with SubframeCore.Tooltip to show the tooltip. It has the same API as Radix UI's Tooltip component.

Offset

Use offset to change the distance between the trigger and the tooltip.

Positioning

Use side and align props to change the position of the tooltip.

Helper component

You can simplify your tooltip usage by creating your own helper component like TooltipHost below.