# Speech Bubble

> A rounded box with a tail on any edge. The border runs around the tail unbroken.

- Category: Shapes (Outlines that are not rectangles, with borders that follow them.)
- Registry item: `bubble-frame`
- Live preview with controls: https://fancyborders.vercel.app/docs/components/speech-bubble

## Installation

```bash
npx shadcn@latest add https://fancyborders.vercel.app/r/bubble-frame.json
```

With the registry namespace: `npx shadcn@latest add @fancyborders/bubble-frame`.

The CLI also adds what `bubble-frame` is built on: `frame`, `shape-frame`.

Files it adds: `components/ui/frame.tsx`, `components/ui/shape-frame.tsx`, `components/bubble-frame.tsx`, and its CSS goes into the global stylesheet after the Tailwind import.

## Usage

The code for the preview at its default settings:

```tsx
import { BubbleFrame } from "@/components/bubble-frame";

<BubbleFrame
  fill="var(--background)"
  className="px-5 py-4 drop-shadow-md"
>
  Shipped it.
</BubbleFrame>
```

## Examples

### A conversation

Tails on opposite sides, each a fixed distance from its own end.

```tsx
import { BubbleFrame } from "@/components/bubble-frame";

export default function BubbleChat() {
  return (
    <div className="grid w-full max-w-sm gap-3 text-sm">
      <BubbleFrame
        side="left"
        at={-18}
        fill="var(--background)"
        className="justify-self-start px-4 py-2.5"
      >
        Is the new border live?
      </BubbleFrame>
      <BubbleFrame
        side="right"
        at={-18}
        fill="var(--color-sky-500)"
        color="var(--color-sky-600)"
        className="justify-self-end px-4 py-2.5 text-white"
      >
        Deployed a minute ago.
      </BubbleFrame>
      <BubbleFrame
        side="left"
        at={-18}
        fill="var(--background)"
        className="justify-self-start px-4 py-2.5"
      >
        It goes all the way round the tail!
      </BubbleFrame>
    </div>
  );
}
```

## Good to know

- The tail is drawn inside the frame's box, and the content is kept clear of it, so a bubble takes the room its box says it does.
- A negative at counts from the far end of the edge, which keeps the tail a fixed distance from the right or the bottom.

## API reference

### BubbleFrame

```tsx
import { BubbleFrame } from "@/components/bubble-frame";
```

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `side` | `"top" \| "right" \| "bottom" \| "left"` | `"bottom"` | The edge the tail points out of. |
| `at` | `number \| `${number}%`` | `28` | Where the tail sits along its edge: pixels from the left or top, pixels from the other end when negative, or a percentage. |
| `tailSize` | `number` | `10` | How far the tail sticks out, in pixels. |
| `tailWidth` | `number` | `16` | Width of the tail where it joins the bubble, in pixels. |
| `lean` | `number` | `0` | How far the tip leans along the edge, in pixels. Negative leans back. |
| `radius` | `number` | `14` | Radius of the corners, in pixels. |

Also accepts line, fill, color and every div attribute.
