--- title: Bubble description: "`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`は、会話の内容をメッセージの吹き出しで表示するコンポーネントです。 ```tsx 何者だ、お前は 趣味でヒーローをやっている者だ 👍 … なんだ、その適当な設定は… ``` ## 使い方 ```tsx import { Bubble } from "@yamada-ui/react" ``` ```tsx import { Bubble } from "@/components/ui" ``` ```tsx import { Bubble } from "@workspaces/ui" ``` ```tsx ``` :::note `Bubble.Content`は省略することができます。 ::: ### itemsを使う ```tsx const items = useMemo( () => [ { children: "何者だ、お前は" }, { children: "趣味でヒーローをやっている者だ", direction: "end", reactions: "👍", reactionsProps: { "aria-label": "Reactions: thumbs up", role: "img" }, }, { items: [{ children: "…" }, { children: "なんだ、その適当な設定は…" }] }, ], [], ) return ``` ### バリアントを変更する ```tsx {(variant, index) => ( ヒーローが逃げたら誰が戦うんだよ )} ``` ### サイズを変更する ```tsx {(size, index) => ( 退屈な人生に刺激がほしくて他の星を襲うなんてOLでも考えねえぞ 👍 🔥 +2 )} ``` ### カラースキームを変更する ```tsx {(colorScheme, index) => ( 地球がヤバい!!! )} ``` ### グループ化する グループ化する場合は、`Bubble.Group`を使用します。 ```tsx ここに住んでもいいですか? うん 絶対ダメ ドサッ 部屋代払います ちゃんと歯ブラシ持ってきたか? ``` ### リアクションを表示する リアクションを表示する場合は、`Bubble.Reactions`を使用します。配置を変更する場合は、`placement`を設定します。デフォルトは、`"end-end"`が設定されています。 ```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. | ## アクセシビリティ 操作を伴わない絵文字のリアクションを表示する場合は、`Bubble.Reactions`に`role="img"`とリアクションの内容を説明する`aria-label`を設定します。 ```tsx ここで俺はお前に立ち向かわなくちゃいけないんだ! 👍 🔥 +2 ``` ## 類似のコンポーネント - [DataList](https://yamada-ui.com/docs/components/data-list.md): `DataList`は、データ項目のリストを表示するために使用されます。 - [List](https://yamada-ui.com/docs/components/list.md): `List`は、リストを表示するコンポーネントです。デフォルトでは、`ul`要素をレンダリングします。 - [Timeline](https://yamada-ui.com/docs/components/timeline.md): `Timeline`は、イベントのリストを時系列に表示するために使用されるコンポーネントです。 - [Tree](https://yamada-ui.com/docs/components/tree.md): `Tree`は、階層データを展開可能なツリー形式で表示するコンポーネントです。 - [NativeTable](https://yamada-ui.com/docs/components/native-table.md): `NativeTable`は、データを効率的に整理して表示するコンポーネントです。 - [Stat](https://yamada-ui.com/docs/components/stat.md): `Stat`は、数値やデータをボックス内に表示するために使用されます。 - [Table](https://yamada-ui.com/docs/components/table.md): `Table`は、列のソートや行の選択やクリックイベント機能を備えたテーブルのコンポーネントです。 - [AreaChart](https://yamada-ui.com/docs/components/area-chart.md): `AreaChart`は、複数のデータを比較するためのエリアチャートを描画するコンポーネントです。