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