Command palette

@yasinsensoy/native

React Native · Components

Tooltip

A short description bubble.

6 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Code

import { Button } from "@yasinsensoy/native";

<Button variant="outline" tooltip="Saves the changes">Kaydet</Button>

Events

  1. Events appear here when you interact with the preview.

The tooltip prop on every component

PaidAK

Monthly quota: 80 / 100

interactive: a tooltip with a link inside

VAT included

Tooltip: for your own elements

Import

import { Tooltip } from "@yasinsensoy/native";

Tooltip

component

A short description bubble. Same API as the web Tooltip; works for touch screens: opens on long press (touch="longPress") or on tap (touch="tap"). The text is also given to screen readers as the trigger's hint (accessibilityHint). Looks the same on iOS and Android.

Tooltip({ children, content, side, longPressDelay, touch, interactive, closeDelay, tone, style, }: TooltipProps): JSX.Element

Examples

<Tooltip content="Copy"><Button icon="copy" accessibilityLabel="Copy" /></Tooltip>
<Tooltip content="Tax included" touch="tap"><Icon icon="info" /></Tooltip>

Position of the tooltip relative to the trigger. See Placement.

type TooltipSide = Placement

How the tooltip opens on touch screens (same as web).

  • "longPress": Opens on long press; a normal tap does the element's own job (buttons, checkboxes). Closes shortly after the finger lifts.
  • "tap": Toggles on tap; closes when tapping elsewhere (for purely informational ⓘ icons).
type TooltipTouch = "longPress" | "tap"

TooltipProps

interface

Props of the Tooltip component.

NameTypeDefaultDescription
childrenReactElementThe single element that triggers the tooltip (Pressable-based: Button, Pressable…).
contentReactNodeTooltip text. Keep it short; no tooltip is shown if empty.
side?TooltipSide"auto"` (above, below if it does not fit, then the sides)Position relative to the trigger.
longPressDelay?number500Long press duration to open (ms).
touch?TooltipTouch"longPress"How it opens on touch screens. See TooltipTouch.
interactive?booleanfalseCan the inside of the tooltip be tapped (if the content has a link or a button)? While on, it does not close when the finger lifts; tapping outside closes it.
closeDelay?number1500Close delay after the finger lifts (ms).
tone?Tone"neutral"Semantic color of the box. See Tone.
style?ViewStyleStyle of the box.

Options given as an object to the tooltip prop.

type TooltipOptions = Omit<TooltipProps, "children">
NameTypeDefaultDescription
contentReactNodeTooltip text. Keep it short; no tooltip is shown if empty.
side?TooltipSide"auto"` (above, below if it does not fit, then the sides)Position relative to the trigger.
longPressDelay?number500Long press duration to open (ms).
touch?TooltipTouch"longPress"How it opens on touch screens. See TooltipTouch.
interactive?booleanfalseCan the inside of the tooltip be tapped (if the content has a link or a button)? While on, it does not close when the finger lifts; tapping outside closes it.
closeDelay?number1500Close delay after the finger lifts (ms).
tone?Tone"neutral"Semantic color of the box. See Tone.
style?ViewStyleStyle of the box.

Type of components' tooltip prop (same as web). It can be given in two forms:

  • Content: tooltip="Copy link" or any content.
  • With options: tooltip={{ content: "Save", side: "bottom", touch: "tap" }}. See TooltipOptions.

On touch screens the tooltip opens on long press (touch="longPress"). false, null or empty text disables the tooltip.

type TooltipProp = ReactNode | TooltipOptions