Bubble
A chat message bubble that launches from its tail corner, with seven variants, long-press and drag-to-select emoji reactions, an accessible reaction trigger, and ballistic landing into the reaction tray.
Press & hold a message or hover to click the emoji trigger
variant="default"·reactions=2Customize
Installation
npx shadcn@latest add @kinetic/bubbleUsage
Wrap text in BubbleContent. Use align="end" for outgoing messages.
import { Bubble, BubbleContent, BubbleGroup } from "@/components/kinetic/ui/bubble";
export function Thread() {
return (
<BubbleGroup>
<Bubble variant="muted">
<BubbleContent>Is the build ready?</BubbleContent>
</Bubble>
<Bubble align="end">
<BubbleContent>Yes, it just passed.</BubbleContent>
</Bubble>
</BubbleGroup>
);
}Variants
variant is default, secondary, muted, tinted, outline, ghost or destructive.
<Bubble variant="tinted">...</Bubble>Reaction picker and press-and-hold
Add BubbleReactionPicker inside Bubble to enable hold-only activation on BubbleContent (plus keyboard ContextMenu / Shift+F10, or opt-in right-click via openOnContextMenu). Quick taps under 90 ms do not trigger press compression or open the picker. Optionally pair it with BubbleReactionTrigger when you want an explicit button trigger beside the message.
Holding on BubbleContent for longPressDelay (default 320 ms, clamped 120 to 1200 ms, or 0 to disable long-press) gently compresses the bubble, springs it open, and lets users sweep continuously across emojis with spring-coupled dock magnification before releasing to commit. options defaults to BUBBLE_DEFAULT_REACTIONS (six native emoji options constructed via String.fromCodePoint). Control open state externally via pickerOpen, defaultPickerOpen and onPickerOpenChange on Bubble.
"use client";
import { useState } from "react";
import {
BUBBLE_DEFAULT_REACTIONS,
Bubble,
BubbleContent,
BubbleReactionItem,
type BubbleReactionOption,
BubbleReactionPicker,
BubbleReactions,
BubbleReactionTrigger,
} from "@/components/kinetic/ui/bubble";
export function ReactionBubble() {
const [selectedId, setSelectedId] = useState<string | null>(null);
const [counts, setCounts] = useState<Record<string, number>>({ love: 1 });
const handleSelect = (option: BubbleReactionOption) => {
const removing = selectedId === option.id;
setSelectedId(removing ? null : option.id);
setCounts((prev) => {
const next = { ...prev };
if (selectedId) {
next[selectedId] = Math.max(0, (next[selectedId] ?? 1) - 1);
if (next[selectedId] === 0) delete next[selectedId];
}
if (!removing) {
next[option.id] = (next[option.id] ?? 0) + 1;
}
return next;
});
};
const active = BUBBLE_DEFAULT_REACTIONS.filter((opt) => (counts[opt.id] ?? 0) > 0);
return (
<Bubble align="end" longPressDelay={320}>
<BubbleContent>Hold this message to react.</BubbleContent>
<BubbleReactionTrigger />
<BubbleReactionPicker
options={BUBBLE_DEFAULT_REACTIONS}
selectedId={selectedId}
onSelectReaction={handleSelect}
/>
{active.length > 0 ? (
<BubbleReactions side="bottom" align="end">
{active.map((opt) => (
<BubbleReactionItem
key={opt.id}
reactionId={opt.id}
emoji={opt.emoji}
label={opt.label}
count={counts[opt.id]}
active={selectedId === opt.id}
onClick={() => handleSelect(opt)}
/>
))}
</BubbleReactions>
) : null}
</Bubble>
);
}Ballistic landing and reaction tray
Attach BubbleReactions to a corner with side (top or bottom) and align (start or end), and render chips with BubbleReactionItem. When a newly selected reaction commits from BubbleReactionPicker, the emoji launches along a cubic-bezier arc with velocity-coupled motion blur into the matching BubbleReactionItem glyph (reactionId) and triggers a damped squash-and-stretch bounce on both the glyph and tray. Newly created emoji slots stay hidden until landing, while pre-existing tray emojis stay visible and counts animate with RollingDigits wheels.
import {
type BubbleReactionOption,
BubbleReactionItem,
BubbleReactionPicker,
BubbleReactions,
} from "@/components/kinetic/ui/bubble";
const CUSTOM_REACTIONS: readonly BubbleReactionOption[] = [
{ id: "fire", emoji: String.fromCodePoint(0x1f525), label: "Fire" },
{ id: "clap", emoji: String.fromCodePoint(0x1f44f), label: "Clap" },
];
<Bubble align="end">
<BubbleContent>Shipped!</BubbleContent>
<BubbleReactionPicker options={CUSTOM_REACTIONS} selectedId="fire" onSelectReaction={onSelect} />
<BubbleReactions side="bottom" align="end">
<BubbleReactionItem reactionId="fire" emoji={CUSTOM_REACTIONS[0].emoji} label="Fire" count={3} active />
</BubbleReactions>
</Bubble>Interactive content
Use asChild on BubbleContent to render it as a button or link, or on BubbleReactionTrigger to attach trigger semantics to your own button.
<BubbleContent asChild>
<button type="button" onClick={retry}>Tap to retry</button>
</BubbleContent>Group
BubbleGroup staggers consecutive bubbles with staggerMs.
<BubbleGroup staggerMs={60}>...</BubbleGroup>Motion preferences
animated, blurPx and speed tune entrance springs, picker stagger, ballistic flight timing, and landing bounce. Reduced motion disables flight, spring bounce, and blur transitions while keeping bubble and picker state instant.
API Reference
Bubble
Zero-dependency message surface launching from its start/end tail corner via spatial Euler springs and coordinating reaction picker state and ballistic reaction flights.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "secondary" | "muted" | "tinted" | "outline" | "ghost" | "destructive" | "default" | Selects semantic background, foreground, and hover token styling. |
align | "start" | "end" | "start" | Sets tail corner origin (bottom-left vs. bottom-right) and alignment. |
animated / blurPx / speed | boolean / number / number | true / 4 / 1 | Controls spatial entrance, initial blur (0-16px), and spring speed multiplier (0.25-4). |
pickerOpen / defaultPickerOpen / onPickerOpenChange | boolean / boolean / (open: boolean) => void | - / false / - | Controlled or uncontrolled open state for a nested BubbleReactionPicker. |
longPressDelay | number | 320 | Hold duration in milliseconds on BubbleContent before opening the picker and entering hold-drag (quick taps under 90ms do not trigger press feedback; clamped 120-1200ms, or 0 to disable long-press). |
openOnContextMenu | boolean | false | Optional right-click opening on BubbleContent (disabled by default for hold-only message gestures). |
BubbleGroup
Capped staggered reveal container coordinating consecutive chat bubbles cleanly.
| Prop | Type | Default | Description |
|---|---|---|---|
animated / staggerMs / blurPx / speed | boolean / number / number / number | true / 40 / 4 / 1 | Configures group stagger delay (0-120ms, max 180ms), blur radius, and speed. |
BubbleReactionPicker
Portaled floating emoji toolbar anchored to BubbleContent with staggered entrance, continuous spring dock hover magnification, keyboard roving focus, and velocity-blurred ballistic flight launch.
| Prop | Type | Default | Description |
|---|---|---|---|
options | readonly BubbleReactionOption[] | BUBBLE_DEFAULT_REACTIONS | Array of reaction options ({ id, emoji, label }). Defaults to six native emoji entries built with String.fromCodePoint. |
selectedId / selectedIds | string | null / readonly string[] | - | Marks the active single or multiple reaction IDs in the picker and skips flight when re-selecting an active reaction. |
onSelectReaction | (option: BubbleReactionOption) => void | - | Callback invoked when a user clicks, activates via keyboard, or releases a long-press drag on an option. |
side / sideOffset | "top" | "bottom" / number | "top" / 10 | Preferred dock placement side relative to BubbleContent and pixel gap before automatic viewport flip. |
ariaLabel | string | "Add reaction" | Accessible label applied to the role="toolbar" picker dock. |
BubbleReactionTrigger
Optional accessible button beside Bubble that opens or closes BubbleReactionPicker for explicit click and keyboard activation.
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Merges trigger toggle behavior, ARIA attributes, and ref onto a custom child element. |
aria-label | string | "React to message" | Accessible button name announced to assistive technology. |
children | React.ReactNode | - | Optional custom icon node; renders a clean inline SVG smile icon when omitted. |
BubbleReactionItem
Interactive reaction pill inside BubbleReactions with RollingDigits count wheels that keep pre-existing emoji glyphs visible during flight and bounce on impact.
| Prop | Type | Default | Description |
|---|---|---|---|
reactionId | string | - | Stable ID matching a picker option so flying reactions target this chip's glyph. |
emoji | React.ReactNode | - | Reaction glyph rendered inside the chip and hidden while the matching flight is airborne. |
label / count | string / number | - | Optional accessible name and tabular-numeral count combined automatically into aria-label. |
active | boolean | false | Marks the chip as currently selected with aria-pressed and primary highlight styling. |
BubbleReactions / BubbleContent
Reaction strip with pop-in, landing bounce, width morph, and directional blur swap on count changes, plus asChild content slot with long-press drag.
| Prop | Type | Default | Description |
|---|---|---|---|
side / align (BubbleReactions) | "top" | "bottom" / "start" | "end" | "bottom" / "end" | Anchors reaction strip above or below the start/end corner of Bubble. |
animated / blurPx / speed (BubbleReactions) | boolean / number / number | true / 2 / 1 | Controls reaction pop-in and directional count-change swap animations. |
asChild (BubbleContent) | boolean | false | Merges bubble content styling and picker interactions onto a single child button, link, or wrapper. |