Lynx

Help Bubble

A speech bubble that provides users with additional information about a component's state or specific features.

Available since@seed-design/lynx-react@0.8.0, @seed-design/lynx-css@0.12.0
Loading Lynx example…

Installation

npx @seed-design/cli@latest add ui:help-bubble

Usage

The installed snippet assembles the positioning anchor, speech bubble content, arrow, and optional close button together with HelpBubbleTrigger and HelpBubbleAnchor.

import IconILowercaseSerifCircleFill from "@karrotmarket/lynx-monochrome-icon/IconILowercaseSerifCircleFill";
import { ActionButton, Icon } from "@seed-design/lynx-react";

import { HelpBubbleTrigger } from "@/components/ui/help-bubble";

export function App() {
  return (
    <HelpBubbleTrigger defaultOpen title="Check additional information.">
      <ActionButton variant="ghost" size="small" layout="iconOnly" accessibility-label="Help">
        <Icon icon={<IconILowercaseSerifCircleFill />} />
      </ActionButton>
    </HelpBubbleTrigger>
  );
}
  • HelpBubbleTrigger opens and closes the speech bubble when a child is tapped.
  • HelpBubbleAnchor creates only the positioning anchor. You can set the initial open state with defaultOpen, or directly control the open state with open and onOpenChange.
  • The default placement is "top". You can adjust the position with placement, flip, gutter, overflowPadding, arrowPadding.
  • Specifying showCloseButton adds a close button with a default close icon.
  • The default value of contentProps.maxWidth is 280px, and you can remove the maximum width limit with "none". When contentProps.style.width is also specified, if maxWidth is narrower, maxWidth is applied.
  • zIndexOffset adds to the Positioner's default z-index 99.

Props

HelpBubbleTrigger

Prop

Type

titleReact.ReactNode
description?React.ReactNode
showCloseButton?boolean | undefined
children?React.ReactNode
contentProps?SeedHelpBubble.ContentProps | undefined
zIndexOffset?number | undefined
open?boolean | undefined
defaultOpen?boolean | undefined
onOpenChange?((open: boolean) => void) | undefined
style?CSSProperties | undefined
className?string | undefined

HelpBubbleAnchor

Prop

Type

titleReact.ReactNode
description?React.ReactNode
showCloseButton?boolean | undefined
children?React.ReactNode
contentProps?SeedHelpBubble.ContentProps | undefined
zIndexOffset?number | undefined
style?CSSProperties | undefined
className?string | undefined
open?boolean | undefined
defaultOpen?boolean | undefined
onOpenChange?((open: boolean) => void) | undefined

Examples

Trigger

Tapping HelpBubbleTrigger opens and closes the speech bubble. This example shows both an uncontrolled Trigger that is initially open and a Trigger that controls state with open and onOpenChange. In both cases, you can close with the close button.

Loading Lynx example…

Anchor

HelpBubbleAnchor is an element like an avatar that only positions the speech bubble and does not open/close by tapping. The open state of uncontrolled Anchor using defaultOpen and controlled Anchor using open and onOpenChange are changed by the close button and open Switch respectively.

Loading Lynx example…

Close On Interact Outside

The default value of closeOnInteractOutside is true. On native, when true, the first tap outside the speech bubble closes only the bubble and is not passed to elements below. When false, the speech bubble remains open and outside taps are passed directly to elements below.

Loading Lynx example…

Placement

Use placement to position the speech bubble in 12 directions around the reference element. This example shows each placement in open state and maintains the direction specified with flip={false}.

Loading Lynx example…

Flip

Specifying flip={false} prevents the speech bubble from changing direction even if there is insufficient space at screen boundaries.

Loading Lynx example…

Close Button

You can add a close button to the speech bubble with showCloseButton. Tapping the close button closes the bubble, and tapping Trigger again reopens it.

Loading Lynx example…

Description

You can add a description below title by using description.

Loading Lynx example…

Title Only

You can pass only title without description.

Loading Lynx example…

Setting Width Manually

Content has a default maximum width. You can override this value with contentProps.maxWidth, and remove the maximum width limit with "none". When contentProps.style.width is also specified, if maxWidth is narrower, maxWidth takes precedence.

Loading Lynx example…

Line Breaks

React's <br /> is converted to native <text> children and "\n" in Lynx title. You can also pass line break characters in strings to title.

Loading Lynx example…

z-index Offset

Use zIndexOffset to add a value to the Positioner's default z-index 99. This example changes the offset with SegmentedControl and checks the current z-index of the speech bubble.

Loading Lynx example…

Web Version Differences

  • Lynx's Trigger and Anchor wrap children in native view. They do not provide DOM asChild, HTML ARIA attributes, keyboard focus, ESC closing, or portal. Required accessibility is ensured through Lynx's accessibility-* props and the host's native accessibility flow.
  • When closeOnInteractOutside is true, the first outside tap closes only the speech bubble and is not passed to elements below. When false, the speech bubble remains open and outside taps are passed to elements below.
  • Positioner is a fixed native view, not a portal or fullscreen overlay. Use zIndexOffset to adjust the z-index order with sibling elements on the same screen.

Table of contents