Tooltip

Hover/focus tooltip that positions above, below, left, or right of the trigger.

Overview

The Tooltip component is a core building block of the Byteion design system, providing a robust, accessibility-compliant interface for its specific UI capabilities.

Why this exists

Tooltips provide supplementary information on hover or focus without cluttering the interface. They are the"what is this?" layer of UI.

Mental model

A tooltip appears when the user hovers or focuses on an element. It provides a brief explanation. It should never contain critical information or interactive elements.

When to use

• Explaining icon-only buttons • Clarifying abbreviations or metrics • Keyboard shortcut hints • Supplementary context (last updated, source)

When not to use

• Do not use tooltips for critical information — some users cannot hover • Avoid for interactive content (links, buttons) — use a popover • Do not use on every element — it creates noise • Avoid on mobile — hover does not exist

Basic example

The following example demonstrates standard usage, fully compliant with Byteion's token-first approach.

Variants

Each variant communicates a different meaning. Choose based on priority, not aesthetics.

Single default variant.

Sizes

Size should match the importance and context of the component.

  • md — md size.

States

This component reacts seamlessly to the following interaction and data states:

  • hidden — Not rendered in the DOM.
  • visible — Rendered and interactive.
  • default — Resting appearance before interaction.
  • hover — Pointer is over the element — visual feedback via color or shadow.
  • focus — Keyboard or tab focus — shows ring indicator for accessibility.
  • active — Currently selected or in use.
  • disabled — Non-interactive — grayed out, cursor not-allowed.
  • open — Component is expanded or visible.
  • closed — Component is collapsed or hidden.

Anatomy

• Trigger element — the element being explained • Tooltip bubble — small floating panel with text • Arrow — optional, points to trigger

Usage guidelines

  • Keep text under 60 characters.
  • Show after 500ms delay (not instant).
  • Never put interactive elements inside a tooltip.

Do and Don't

Do

  • Keep text short.
  • Add a delay before showing.
  • Show on focus for keyboard users.

Don't

  • Do not put links or buttons inside.
  • Do not show instantly — add delay.
  • Do not use for critical information.

Accessibility

Tooltip uses role="tooltip" with aria-describedby on the trigger. Also appears on focus, not just hover.

Role:tooltip

ARIA Attributes

  • aria-describedby

Keyboard Navigation

  • Escape: Closes the overlay or cancels the action

Customization

Background and text color follow popover tokens. Z-index uses --z-tooltip.

Compose with React cva()

Use the exportedcva() +cn() utilities to compose your own variant on top of the Byteion tokens.

import { cva, cn, type VariantProps } from '@byteion/react';

const myTooltip = cva('base classes…', {
 variants: {
  accent: { soft:'border-primary-200', loud:'border-primary-500' },
 },
 defaultVariants: { accent:'soft' },
});

type Props = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof myTooltip>;

Compose with Vue cva()

Use the exportedcva() +cn() utilities inside standard Vue setup blocks.

<script setup lang="ts">
import { computed, useAttrs } from 'vue';
import { cva, type VariantProps } from '@byteion/vue';

interface Props { accent?:'soft' |'loud' }
const props = withDefaults(defineProps<Props>(), { accent:'soft' });
const attrs = useAttrs();

const myTooltip = cva('base classes…', {
  variants: { accent: { soft:'border-primary-200', loud:'border-primary-500' } },
});

const cls = computed(() => myTooltip({ accent: props.accent, class: attrs.class as string | undefined }));
</script>

Runtime events

Byteion keeps framework APIs idiomatic: HTML uses DOM custom events, React uses callback props, and Vue uses emitted events / v-model updates.

HTML / JS events

  • bi:tooltip:hide
  • bi:tooltip:show

React callbacks

  • onOpenChange(open: boolean) => void

Vue emits

  • update:open[v: boolean]

Remote / AJAX

This component does not implement Byteion JS remote loading. Use normal HTML form submission, framework state, or your application data layer around it.

API Reference

Requires data-bi-component="tooltip" with data-bi-tooltip="content".

HTML Data Attributes

  • data-bi-tooltip
  • data-bi-tooltip-placement

React Props · TooltipProps

Extracted directly fromreact/src/components/Tooltip.tsx.

export interface TooltipProps {
  content: ReactNode;
  /** The triggering element (must accept ref + aria props). */
  children: ReactElement<any>;
  side?: 'top' | 'right' | 'bottom' | 'left';
  /** Delay before showing on hover, in ms. */
  delay?: number;
  /** Controlled open state. */
  open?: boolean;
  onOpenChange?: (open: boolean) => void;
  className?: string;
}

Vue Props · TooltipProps

Extracted directly fromvue/src/components/Tooltip.vue.

export interface TooltipProps {
  content?: string;
  side?: 'top' | 'right' | 'bottom' | 'left';
  /** Delay before showing on hover, in ms. */
  delay?: number;
  /** Controlled open state. */
  open?: boolean;
}

Developer tips

• Keep copy short: tooltip text should be action-oriented and under 60 characters. If you need more space, use Popover. • Don't fix unclear UI with tooltips: if a label needs explanation, improve the label first. • Mobile fallback: for mobile, provide visible helper text or a Popover for important guidance — hover does not exist on touch. • Overflow clipping: tooltips can get clipped inside overflow-hidden parents. Verify the tooltip renders outside the clipped container. • Always pair icon-only buttons with aria-label: the tooltip is not an accessible name replacement. • Viewport edges: near edges, tooltip should flip to stay visible (check your positioning library support).

Common mistakes

Avoid hardcoded neutral colors, placeholder-only labels, duplicated primary actions, and missing keyboard states. Keep this component on Byteion tokens so dashboard, admin, POS, ERP, ecommerce back-office, Laravel, React, and Vue starter-kit screens can be rebranded without rewriting markup.

Production usage tips

  • Test hover and keyboard focus on every trigger — tooltips must be focus-triggered.
  • Test Escape dismissal — supported via useEscapeKey in both React and Vue.
  • Test dark mode and branded themes — tooltip uses bg-foreground/text-background which invert automatically.
  • Test viewport edges — near edges the tooltip should flip to stay visible (check your positioning library's collision detection).
  • Test icon-only buttons with screen readers — aria-label must be present; the tooltip is additional, not primary.
  • Test on touch devices — provide visible fallback text for important guidance that cannot live in tooltips alone.
  • Keep React and Vue APIs aligned with the core HTML schema — content/side props map to data-bi-tooltip/data-bi-tooltip-placement.

Premium examples

Advanced patterns available in Byteion Pro:

• Keyboard shortcut tooltip — shows shortcut badge inside the tooltip bubble ("Save (Ctrl+S)") • Metric explanation tooltip — two-line tooltip with label and description in compact form • Table header help tooltip — question-mark icon next to column name explains the metric • Compact icon action tooltip pack — toolbar with multiple icon buttons, each with a tooltip • Delayed tooltip with reduced motion — respects prefers-reduced-motion via motion-safe:animate-fade-in

Unlock Premium Patterns

Get access to copy-paste ready Pro blocks, SaaS templates, and advanced data-tables built with this component.

Explore Pro Components