# Help Bubble URL: /react/components/help-bubble Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/help-bubble.mdx A component that provides users with additional information about a component's state or specific features. 사용 가능 버전: @seed-design/react@0.0.1, @seed-design/css@0.0.1 ## Preview ```tsx import { IconILowercaseSerifCircleFill } from "@karrotmarket/react-monochrome-icon"; import { HelpBubbleTrigger } from "seed-design/ui/help-bubble"; import { ActionButton } from "seed-design/ui/action-button"; import { Icon } from "@seed-design/react"; export default function HelpBubblePreview() { 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 ## Props ### `HelpBubbleTrigger` ### `HelpBubbleAnchor` ## Examples Most of the examples below have `closeOnInteractOutside={false}` set so they do not close even when a pointerdown occurs. ### Trigger Clicking the `children` of `HelpBubbleTrigger` opens and closes the Help Bubble. The `children` should contain a focusable element like a `button`. `` sets the `aria-haspopup="dialog"` attribute and automatically sets the `aria-expanded` attribute based on the Help Bubble's `open` state. This attribute is useful for assistive technologies like screen readers. ```tsx import { VStack } from "@seed-design/react"; import { useState } from "react"; import { HelpBubbleTrigger } from "seed-design/ui/help-bubble"; import { Switch } from "seed-design/ui/switch"; import { ActionButton } from "seed-design/ui/action-button"; export default function () { const [isControlledHelpBubbleOpen, setIsControlledHelpBubbleOpen] = useState(true); return ( 토글 토글 ); } ``` ### Anchor The `children` of `HelpBubbleAnchor` are used only for positioning the Help Bubble and do not include click to open/close behavior. You can use `defaultOpen` and `showCloseButton` to control when it opens and closes appropriately, or you can use the `open` prop in a controlled manner to directly manage the open/closed state. ```tsx import { VStack } from "@seed-design/react"; import { useState } from "react"; import { Avatar } from "seed-design/ui/avatar"; import { HelpBubbleAnchor } from "seed-design/ui/help-bubble"; import { Switch } from "seed-design/ui/switch"; export default function () { const [isControlledHelpBubbleOpen, setIsControlledHelpBubbleOpen] = useState(true); return ( ); } ``` ### Close On Interact Outside When the `closeOnInteractOutside` prop is set to `false`, clicking outside the Help Bubble, `HelpBubbleTrigger`, and `HelpBubbleAnchor` does not close the Help Bubble. The default is `true`. ```tsx import { VStack } from "@seed-design/react"; import { HelpBubbleTrigger } from "seed-design/ui/help-bubble"; import { ActionButton } from "seed-design/ui/action-button"; export default function () { return ( 토글 토글 ); } ``` ### Placement ```tsx import { IconSparkle2 } from "@karrotmarket/react-multicolor-icon"; import { Box, Icon } from "@seed-design/react"; import { HelpBubbleAnchor } from "seed-design/ui/help-bubble"; export default function HelpBubblePreview() { return (
} /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } />
); } ``` ### Flip ```tsx import { IconSparkle2 } from "@karrotmarket/react-multicolor-icon"; import { Icon } from "@seed-design/react"; import { HelpBubbleAnchor } from "seed-design/ui/help-bubble"; export default function HelpBubbleFlip() { return ( } /> ); } ``` ### Close Button ```tsx import { ActionButton } from "seed-design/ui/action-button"; import { HelpBubbleTrigger } from "seed-design/ui/help-bubble"; export default function HelpBubbleCloseButton() { return ( 토글 ); } ``` ### Description You can add a description below `title` using `description`. ```tsx import { IconSparkle2 } from "@karrotmarket/react-multicolor-icon"; import { Icon } from "@seed-design/react"; import { HelpBubbleAnchor } from "seed-design/ui/help-bubble"; export default function HelpBubbleDescription() { return ( } /> ); } ``` ### Title Only ```tsx import { IconSparkle2 } from "@karrotmarket/react-multicolor-icon"; import { Icon } from "@seed-design/react"; import { HelpBubbleAnchor } from "seed-design/ui/help-bubble"; export default function HelpBubbleTitleOnly() { return ( } /> ); } ``` ### Setting Width Manually `content` has a default maximum width. Specifying `maxWidth` in `contentProps` overrides this default, and specifying `none` removes the maximum width limit. You can also specify `width` as an inline style, and if `maxWidth` is narrower than `width`, `maxWidth` will be applied. ```tsx import { HelpBubbleAnchor } from "seed-design/ui/help-bubble"; import { SegmentedControl, SegmentedControlItem } from "seed-design/ui/segmented-control"; import { Text, VStack } from "@seed-design/react"; import { useState } from "react"; const WIDTH_OPTIONS = ["200px", "300px", "unset"] as const; const MAX_WIDTH_OPTIONS = ["200px", "400px", "none"] as const; export default function HelpBubbleWidth() { const [width, setWidth] = useState<(typeof WIDTH_OPTIONS)[number]>("unset"); const [maxWidth, setMaxWidth] = useState<(typeof MAX_WIDTH_OPTIONS)[number]>("400px"); return ( width setWidth(value as (typeof WIDTH_OPTIONS)[number])} > {WIDTH_OPTIONS.map((option) => ( {option} ))} maxWidth setMaxWidth(value as (typeof MAX_WIDTH_OPTIONS)[number])} > {MAX_WIDTH_OPTIONS.map((option) => ( {option} ))} ); } ``` ### Line Breaks ```tsx import { IconSparkle2 } from "@karrotmarket/react-multicolor-icon"; import { Icon } from "@seed-design/react"; import { HelpBubbleAnchor } from "seed-design/ui/help-bubble"; import { HStack } from "@seed-design/react"; export default function HelpBubbleLineBreaks() { return ( Breaking
lines
using
`<br />`s } > } />
} />
); } ``` ### `z-index` Offset ```tsx import { Flex, HStack, VStack } from "@seed-design/react"; import { useState } from "react"; import { HelpBubbleAnchor } from "seed-design/ui/help-bubble"; import { Slider } from "seed-design/ui/slider"; import { Avatar } from "seed-design/ui/avatar"; export default function HelpBubbleZIndexOffset() { const [zIndexOffset, setZIndexOffset] = useState(5); return ( {Array.from({ length: 5 }, (_, i) => ( {i + 100} ))} setZIndexOffset(value)} markers={[0, 5]} getAriaLabel={() => "zIndexOffset"} hideValueIndicator /> ); } ```