# Bubble

A composable conversation surface for messages, suggestions, and reactions.

Bubble presents short conversational content without owning the surrounding chat model. Keep avatars, sender names, timestamps, delivery state, and message-level actions in the parent interface.

```tsx
import { Bubble } from "@zentara-co/zenos-ui";

function BubbleExample() {
  return (
    <div
      role="log"
      aria-label="Deployment conversation"
      className="flex w-full max-w-lg flex-col gap-4"
    >
      <Bubble.Group className="w-full">
        <Bubble variant="secondary">
          <Bubble.Content>The deployment is ready for review.</Bubble.Content>
        </Bubble>
        <Bubble variant="secondary">
          <Bubble.Content>I also attached the accessibility report.</Bubble.Content>
        </Bubble>
      </Bubble.Group>
      <Bubble.Group className="w-full gap-3">
        <Bubble align="end">
          <Bubble.Content>Looks good. Ship it.</Bubble.Content>
          <Bubble.Reactions role="img" aria-label="Reactions: thumbs up, fire, eyes, and 2 more">
            <span>👍</span>
            <span>🔥</span>
            <span>👀</span>
            <span>+2</span>
          </Bubble.Reactions>
        </Bubble>
      </Bubble.Group>
    </div>
  );
}
```

## Import

```tsx
import { Bubble } from "@zentara-co/zenos-ui";
```

## Composition

Compose `Bubble.Content` inside a root Bubble. Use `Bubble.Group` for consecutive messages from the same sender and `Bubble.Reactions` for a compact reaction or quick-action row.

```tsx
<Bubble variant="secondary">
  <Bubble.Content>The report is ready.</Bubble.Content>
  <Bubble.Reactions role="img" aria-label="One thumbs up reaction">
    <span>👍</span>
  </Bubble.Reactions>
</Bubble>
```

Reactions overlap the selected bubble edge. Leave enough space between conversation rows when reactions are present.

## Actions

Place any custom control inside `Bubble.Actions` to attach it to the logical end of the bubble. Actions default to `visibility="hover"`: they appear on hover or keyboard focus on pointer devices and remain available on devices without hover. Use `visibility="always"` for persistent controls. The slot accepts dropdown menus, emoji-picker triggers, buttons, or any other element without owning its behavior.

```tsx
import { DotsThreeVerticalIcon, PlusIcon } from "@phosphor-icons/react";
import { Bubble, DropdownMenu, IconButton, Stack } from "@zentara-co/zenos-ui";

function BubbleActionsExample() {
  return (
    <Stack gap="6" className="w-full max-w-lg pe-12">
      <Bubble variant="secondary">
        <Bubble.Actions>
          <DropdownMenu.Root>
            <DropdownMenu.Trigger
              render={<IconButton aria-label="Message actions" size="sm" variant="secondary" />}
            >
              <DotsThreeVerticalIcon />
            </DropdownMenu.Trigger>
            <DropdownMenu.Content align="start">
              <DropdownMenu.Item>Reply</DropdownMenu.Item>
              <DropdownMenu.Item>Copy message</DropdownMenu.Item>
              <DropdownMenu.Item>Delete</DropdownMenu.Item>
            </DropdownMenu.Content>
          </DropdownMenu.Root>
        </Bubble.Actions>
        <Bubble.Content>Hover or focus this message to reveal its menu.</Bubble.Content>
      </Bubble>
      <Bubble variant="secondary">
        <Bubble.Actions visibility="always">
          <IconButton aria-label="Add reaction" size="sm" variant="secondary">
            <PlusIcon />
          </IconButton>
        </Bubble.Actions>
        <Bubble.Content>This reaction action always stays visible.</Bubble.Content>
      </Bubble>
    </Stack>
  );
}
```

## Variants

Use `default` for a strong current-user message, `secondary` for standard conversation content, `muted` for supporting information, `tinted` for quiet brand emphasis, `outline` for bordered rich content, `ghost` for unframed assistant output, and `destructive` for failed or unsafe results.

```tsx
import { Bubble, Stack } from "@zentara-co/zenos-ui";

function BubbleVariantsExample() {
  return (
    <Stack gap="3" className="w-full max-w-lg">
      <Bubble variant="default" align="end">
        <Bubble.Content>Default — strong current-user emphasis.</Bubble.Content>
      </Bubble>
      <Bubble variant="secondary">
        <Bubble.Content>Secondary — standard conversation content.</Bubble.Content>
      </Bubble>
      <Bubble variant="muted">
        <Bubble.Content>Muted — quiet supporting information.</Bubble.Content>
      </Bubble>
      <Bubble variant="tinted">
        <Bubble.Content>Tinted — subtle brand emphasis.</Bubble.Content>
      </Bubble>
      <Bubble variant="outline">
        <Bubble.Content>Outline — bordered rich content.</Bubble.Content>
      </Bubble>
      <Bubble variant="ghost">
        <Bubble.Content>Ghost — unframed assistant text that can use the full row.</Bubble.Content>
      </Bubble>
      <Bubble variant="destructive">
        <Bubble.Content>Destructive — the deployment failed validation.</Bubble.Content>
      </Bubble>
    </Stack>
  );
}
```

### Custom variant

Use any stable custom `variant` name with `variantClassName` to define a consumer-owned content treatment. The name is exposed through `data-variant`, while Zenos preserves Bubble layout, alignment, reactions, and native content behavior.

```tsx
import { Bubble } from "@zentara-co/zenos-ui";

function BubbleCustomVariantExample() {
  return (
    <Bubble
      variant="campaign"
      variantClassName="border-border-accent-purple-default bg-background-accent-purple-subtlest-default text-text-accent-purple-bolder"
    >
      <Bubble.Content>Campaign launch is ready for review.</Bubble.Content>
    </Bubble>
  );
}
```

## Alignment and RTL

Set `align="start"` or `align="end"` on each Bubble. Alignment and reaction placement use logical CSS edges, so the same composition mirrors automatically inside `DirectionProvider direction="rtl"` or an RTL document.

## Interactive content

`Bubble.Content` defaults to a `div`. Use `as="button"` or `as="a"` when the complete surface performs an action or navigates. Native props and refs follow the selected element, and Zenos supplies a visible keyboard focus ring.

```tsx
import { Bubble, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function BubbleInteractiveExample() {
  const [choice, setChoice] = useState("No option selected.");

  return (
    <Stack gap="3" className="w-full max-w-lg">
      <Bubble variant="ghost">
        <Bubble.Content>How should I handle the failed deployment?</Bubble.Content>
      </Bubble>
      <Bubble.Group className="w-full gap-2">
        {["Retry the deployment", "Open the build log", "Notify the release owner"].map(
          (option) => (
            <Bubble key={option} variant="muted">
              <Bubble.Content as="button" type="button" onClick={() => setChoice(option)}>
                {option}
              </Bubble.Content>
            </Bubble>
          ),
        )}
      </Bubble.Group>
      <Text size="s" color="subtle" aria-live="polite">
        {choice}
      </Text>
    </Stack>
  );
}
```

## Variants

default, secondary, muted, tinted, outline, ghost, destructive

## Anatomy

```text
Bubble.Root
Bubble.Group
Bubble.Actions
Bubble.Content
Bubble.Reactions
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| variant | BubbleVariant \| custom string | default | Semantic surface treatment for the bubble content. |
| variantClassName | string | — | Consumer-owned classes applied to Bubble.Content for a custom variant. |
| align | start \| end | start | Logical inline alignment of the bubble within its conversation row. |
| Actions.visibility | hover \| always | hover | Reveals custom end actions on hover and focus or keeps them visible. |
| Content.as | ElementType | div | Renders content as a semantic element such as a button or link. |
| Reactions.side | top \| bottom | bottom | Bubble edge overlapped by the reaction row. |
| Reactions.align | start \| end | start | Logical position of reactions along the selected edge. |
| native props | React.HTMLAttributes<HTMLElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Bubble is a presentational surface rather than a complete chat transcript. Put conversation semantics such as `role="log"`, sender context, and live-region behavior on the surrounding interface. Give every interactive control inside `Bubble.Actions` an accessible name; hover-only actions are also revealed by keyboard focus. When reactions are decorative summaries, group them with `role="img"` and a descriptive `aria-label`; when they are actions, render labeled buttons instead. Destructive meaning must also be stated in text rather than communicated by color alone.

Source: https://zenos-ui.pages.dev/components/bubble/