# Help Bubble
URL: /lynx/components/help-bubble
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/components/help-bubble.mdx
A speech bubble that provides users with additional information about a component's state or specific features.
사용 가능 버전: @seed-design/lynx-react@0.8.0, @seed-design/lynx-css@0.12.0
## Preview
```tsx
import "./styles";
import IconILowercaseSerifCircleFill from "@karrotmarket/lynx-monochrome-icon/IconILowercaseSerifCircleFill";
import { ActionButton, Icon, VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleTrigger } from "@/components/ui/help-bubble";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
} />
);
}
```
## Installation
- npm: npx @seed-design/cli@latest add ui:help-bubble
- pnpm: pnpm dlx @seed-design/cli@latest add ui:help-bubble
- yarn: yarn dlx @seed-design/cli@latest add ui:help-bubble
- bun: bun x @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`.
```tsx
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` 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`
### `HelpBubbleAnchor`
## 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.
```tsx
import "./styles";
import { useState } from "@lynx-js/react";
import { ActionButton, VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleTrigger } from "@/components/ui/help-bubble";
import { Switch } from "@/components/ui/switch";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [isControlledHelpBubbleOpen, setIsControlledHelpBubbleOpen] = useState(true);
function handleControlledOpenChange(nextOpen: boolean) {
"background only";
setIsControlledHelpBubbleOpen(nextOpen);
}
return (
토글
토글
);
}
```
### 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.
```tsx
import "./styles";
import { useState } from "@lynx-js/react";
import { Box, Text, VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleAnchor } from "@/components/ui/help-bubble";
import { Switch } from "@/components/ui/switch";
const AVATAR_SRC = "https://avatars.githubusercontent.com/u/54893898?v=4";
function Avatar() {
const [hasImageError, setHasImageError] = useState(false);
function handleImageError() {
"background only";
setHasImageError(true);
}
return (
{hasImageError ? (
L
) : (
)}
);
}
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [isControlledHelpBubbleOpen, setIsControlledHelpBubbleOpen] = useState(true);
function handleControlledOpenChange(nextOpen: boolean) {
"background only";
setIsControlledHelpBubbleOpen(nextOpen);
}
return (
);
}
```
### 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.
```tsx
import "./styles";
import { ActionButton, VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleTrigger } from "@/components/ui/help-bubble";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
토글
토글
);
}
```
### 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}`.
```tsx
import "./styles";
import IconSparkle2 from "@karrotmarket/lynx-multicolor-icon/IconSparkle2";
import { Box, HStack, VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleAnchor, type HelpBubbleAnchorProps } from "@/components/ui/help-bubble";
function PlacementAnchor({
placement,
}: {
placement: NonNullable;
}) {
return (
);
}
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
```
### Flip
Specifying `flip={false}` prevents the speech bubble from changing direction even if there is insufficient space at screen boundaries.
```tsx
import "./styles";
import IconSparkle2 from "@karrotmarket/lynx-multicolor-icon/IconSparkle2";
import { VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleAnchor } from "@/components/ui/help-bubble";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
```
### 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.
```tsx
import "./styles";
import { ActionButton, VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleTrigger } from "@/components/ui/help-bubble";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
토글
);
}
```
### Description
You can add a description below `title` by using `description`.
```tsx
import "./styles";
import IconSparkle2 from "@karrotmarket/lynx-multicolor-icon/IconSparkle2";
import { VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleAnchor } from "@/components/ui/help-bubble";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
```
### Title Only
You can pass only `title` without `description`.
```tsx
import "./styles";
import IconSparkle2 from "@karrotmarket/lynx-multicolor-icon/IconSparkle2";
import { VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleAnchor } from "@/components/ui/help-bubble";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
```
### 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.
```tsx
import "./styles";
import { useState } from "@lynx-js/react";
import { Text, VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleAnchor } from "@/components/ui/help-bubble";
import { SegmentedControl, SegmentedControlItem } from "@/components/ui/segmented-control";
const WIDTH_OPTIONS = ["200px", "300px", "unset"] as const;
const MAX_WIDTH_OPTIONS = ["200px", "400px", "none"] as const;
type Width = (typeof WIDTH_OPTIONS)[number];
type MaxWidth = (typeof MAX_WIDTH_OPTIONS)[number];
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [width, setWidth] = useState("unset");
const [maxWidth, setMaxWidth] = useState("400px");
function handleWidthChange(nextWidth: string) {
"background only";
setWidth(nextWidth as Width);
}
function handleMaxWidthChange(nextMaxWidth: string) {
"background only";
setMaxWidth(nextMaxWidth as MaxWidth);
}
return (
width
{WIDTH_OPTIONS.map((option) => (
{option}
))}
maxWidth
{MAX_WIDTH_OPTIONS.map((option) => (
{option}
))}
);
}
```
### Line Breaks
React's `
` is converted to native `` children and `"\n"` in Lynx title. You can also pass line break characters in strings to title.
```tsx
import "./styles";
import IconSparkle2 from "@karrotmarket/lynx-multicolor-icon/IconSparkle2";
import { HStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleAnchor } from "@/components/ui/help-bubble";
const explicitLineBreakTitle = (
{"Breaking"}
{"\n"}
{"lines"}
{"\n"}
{"using"}
{"\n"}
{"`
`s"}
);
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
```
### `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.
```tsx
import "./styles";
import { useState } from "@lynx-js/react";
import { Box, HStack, Text, VStack, useSeedClassName } from "@seed-design/lynx-react";
import { HelpBubbleAnchor } from "@/components/ui/help-bubble";
import { SegmentedControl, SegmentedControlItem } from "@/components/ui/segmented-control";
const AVATAR_SRC = "https://avatars.githubusercontent.com/u/54893898?v=4";
const OFFSET_OPTIONS = ["0", "1", "2", "3", "4", "5"] as const;
function Avatar() {
const [hasImageError, setHasImageError] = useState(false);
function handleImageError() {
"background only";
setHasImageError(true);
}
return (
{hasImageError ? (
L
) : (
)}
);
}
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [zIndexOffset, setZIndexOffset] = useState(5);
function handleOffsetChange(nextOffset: string) {
"background only";
setZIndexOffset(Number(nextOffset));
}
return (
{Array.from({ length: 5 }, (_, index) => (
{index + 100}
))}
{OFFSET_OPTIONS.map((option) => (
{option}
))}
0
5
);
}
```
## 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.