Chat Container

A component for creating chat interfaces with intelligent auto-scrolling behavior, designed to provide a smooth experience in conversation interfaces.

stick-to-bottom-svelte

Auto-follow preview

A compact thread using the default `smooth` resize preset.

The latest reply will stay pinned to the bottom as the thread grows.

Add one more message so I can see the behavior.

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/chat-container.json

Examples

Basic conversation

A standard message list wrapped in the auto-scrolling container primitives.

Basic conversation

Append a message and the container stays pinned to the bottom.

Can you outline a launch checklist for a new chat feature?
AI

Absolutely. Start with tracking, latency budgets, rate limiting, and a short fallback experience for model downtime.

What should I review before enabling it for everyone?
AI

Check analytics, moderation coverage, prompt regression cases, and whether support has canned responses for common failures.

Streaming response

Stream new assistant text into the latest message while the container keeps pace near the bottom.

Streaming response

Streaming text keeps the last assistant reply visible as it grows.

Explain CSS Grid auto-fit in simple terms.
AI

auto-fit tells the grid to create as many columns as will fit while respecting the minimum size you provide.

Preset comparison

Compare the built-in `smooth` and `ease-out` resize animations with identical message content.

Preset comparison

Compare `smooth` and `ease-out` with the same message flow.

smooth

Which scroll preset should I use for a conversational UI?

Use smooth if you want the default spring, or ease-out if you want a softer finish at the bottom.

ease-out

Which scroll preset should I use for a conversational UI?

Use smooth if you want the default spring, or ease-out if you want a softer finish at the bottom.

Props

ChatContainer.Root

PropTypeDefaultDescription
refHTMLDivElement | null-Bindable reference to the scrollable root element.
childrenSnippet-Message list and any overlay controls rendered inside the scroll area.
classstring-Additional CSS classes for the scroll container.
resize"instant" | "smooth" | "ease-out" | { damping?: number; stiffness?: number; mass?: number }"smooth"Animation used when content height changes while sticking to the bottom.
initialfalse | "instant" | "smooth" | "ease-out" | { damping?: number; stiffness?: number; mass?: number }"instant"Initial scroll behavior applied when the container first measures content.

ChatContainer.Content

PropTypeDefaultDescription
childrenSnippet-Message content rendered inside the tracked content element.
classstring-Additional CSS classes for the content wrapper.