--- title: Bubble description: "`Bubble` is a component that displays conversational content in a message bubble." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/bubble/bubble.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/bubble - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-bubble--basic --- # Bubble `Bubble` is a component that displays conversational content in a message bubble. ```tsx 何者だ、お前は 趣味でヒーローをやっている者だ 👍 … なんだ、その適当な設定は… ``` ## Usage ```tsx import { Bubble } from "@yamada-ui/react" ``` ```tsx import { Bubble } from "@/components/ui" ``` ```tsx import { Bubble } from "@workspaces/ui" ``` ```tsx ``` :::note `Bubble.Content` can be omitted. ::: ### Use items ```tsx const items = useMemo( () => [ { children: "何者だ、お前は" }, { children: "趣味でヒーローをやっている者だ", direction: "end", reactions: "👍", reactionsProps: { "aria-label": "Reactions: thumbs up", role: "img" }, }, { items: [{ children: "…" }, { children: "なんだ、その適当な設定は…" }] }, ], [], ) return ``` ### Change Variant ```tsx {(variant, index) => ( ヒーローが逃げたら誰が戦うんだよ )} ``` ### Change Size ```tsx {(size, index) => ( 退屈な人生に刺激がほしくて他の星を襲うなんてOLでも考えねえぞ 👍 🔥 +2 )} ``` ### Change Color Scheme ```tsx {(colorScheme, index) => ( 地球がヤバい!!! )} ``` ### Grouping To group, use `Bubble.Group`. ```tsx ここに住んでもいいですか? うん 絶対ダメ ドサッ 部屋代払います ちゃんと歯ブラシ持ってきたか? ``` ### Display Reactions To display reactions, use `Bubble.Reactions`. To change the display position, set `placement`. The default is `"end-end"` is set. ```tsx {(placement, index) => ( ここで俺はお前に立ち向かわなくちゃいけないんだ! 👍 🔥 +2 )} ``` ## Props ### Bubble.Root | Prop | Default | Type | Description | | ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | - | `"lg" \| "md" \| "sm"` | The size of the component. | | `variant` | - | `"ghost" \| "outline" \| "panel" \| "solid" \| "subtle" \| "surface" ...` | The variant of the component. | | `contentProps` | - | `Omit` | The props for content component. | | `endGroupProps` | - | `Omit` | The theme props for group component in end direction. | | `endItemProps` | - | `Omit` | The theme props for item component in end direction. | | `groupProps` | - | `Omit` | The props for group component. | | `itemProps` | - | `Omit` | The props for item component. | | `items` | - | `BubbleItem[]` | If provided, generate elements based on items. | | `reactionsProps` | - | `Omit` | The props for reactions component. | | `startGroupProps` | - | `Omit` | The theme props for group component in start direction. | | `startItemProps` | - | `Omit` | The theme props for item component in start direction. | ### Bubble.Content | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ### Bubble.Group | Prop | Default | Type | Description | | ------------- | --------- | ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | `"md"` | `"lg" \| "md" \| "sm"` | The size of the component. | | `variant` | `"panel"` | `"ghost" \| "outline" \| "panel" \| "solid" \| "subtle" \| "surface" ...` | The variant of the component. | | `direction` | `"start"` | `SimpleDirection` | The inline direction of the bubble. | | `items` | - | `BubbleItemWithContent[]` | If provided, generate elements based on items. | ### Bubble.Item | Prop | Default | Type | Description | | -------------- | --------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | `"md"` | `"lg" \| "md" \| "sm"` | The size of the component. | | `variant` | `"panel"` | `"ghost" \| "outline" \| "panel" \| "solid" \| "subtle" \| "surface" ...` | The variant of the component. | | `contentProps` | - | `Omit` | The props for content component. | | `direction` | `"start"` | `SimpleDirection` | The inline direction of the bubble. | ### Bubble.Reactions | Prop | Default | Type | Description | | ------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `placement` | `"end-end"` | `Exclude` | The placement of the reactions. | ## Accessibility When displaying non-interactive emoji reactions, set `role="img"` and `aria-label` on `Bubble.Reactions` to describe the reactions. ```tsx ここで俺はお前に立ち向かわなくちゃいけないんだ! 👍 🔥 +2 ``` ## Similar Components - [DataList](https://yamada-ui.com/docs/components/data-list.md): `DataList` is used to display a list of data items. - [List](https://yamada-ui.com/docs/components/list.md): `List` is a component for displaying lists. By default, it renders a `ul` element. - [Timeline](https://yamada-ui.com/docs/components/timeline.md): `Timeline` is a component that is used to display a list of events in chronological order. - [Tree](https://yamada-ui.com/docs/components/tree.md): `Tree` is a component used to display hierarchical data structures in an expandable tree format. - [NativeTable](https://yamada-ui.com/docs/components/native-table.md): `NativeTable` is a component for efficiently organizing and displaying data. - [Stat](https://yamada-ui.com/docs/components/stat.md): `Stat` is used to display numbers or data within a box. - [Table](https://yamada-ui.com/docs/components/table.md): `Table` is a table component equipped with column sorting, row selection, and click event features. - [AreaChart](https://yamada-ui.com/docs/components/area-chart.md): `AreaChart` is a component for drawing area charts to compare multiple sets of data.