grasscnGitHub

Message Scroller

Follow-latest and manual-reading behavior for Minecraft messages.

Preview

<Steve> The dashboard is ready for review.
<Alex> 带上你的镐子。
<Steve> I added the revenue breakdown.
<Alex> 找到钻石了!
<You> I will check the mobile layout.
Changes saved.
<Steve> The sun is setting.
<Alex> 回家吧。
<You> The bridge is finished.
<Steve> Looks great!
<Alex> 明天继续。
Changes saved.
12 messages
Loading example...
To run this copied example, install these items using the linked CLI or manual instructions:

Usage

Install message, then import the scroller parts from components/ui/message-scroller. MessageScrollerProvider must wrap every hook consumer; the visual Root alone does not provide that hook boundary. Give the viewport an explicit bounded height.

Composition

Compose Root, Viewport, Content and Item with stable messageId values. Root propagates MessageScale. The example uses Provider autoScroll/defaultScrollPosition end and useMessageScroller().scrollToStart({behavior:"instant"}); the Latest button scrolls back to the end.

Interaction and limits

Content role log and aria-live polite are choices made by this example, not automatic semantics. Follow-latest respects manual reading through the @shadcn/react engine. Scrolling controls and conversation layout are web adaptations; this is part of the message install identity.

See the upstream API for the underlying part and event contracts.

Installation

The message composer in this example also uses Input. Install input alongside message when copying it; Message already includes its Button implementation.

This page shares the message installation identity; choose its own implementation file below. There is no separate registry item for this part.

Loading registry address

Component source

This is the component implementation. Its supporting styles, helpers and resources are also required. See complete manual installation.

Component implementationcomponents/ui/message-scroller.tsx · tsx
"use client";

import { MessageScroller as Primitive } from "@shadcn/react/message-scroller";

import "./minecraft-message-scroller.css";
import * as React from "react";

import { Button } from "./button";
import { MessageContent, MessageScale } from "./message";
import {
  isMinecraftTextContent,
  minecraftClasses as cn,

Interactive playground

<Steve> The dashboard is ready for review.
<Alex> 带上你的镐子。
<Steve> I added the revenue breakdown.
<Alex> 找到钻石了!
<You> I will check the mobile layout.
Changes saved.
<Steve> The sun is setting.
<Alex> 回家吧。
<You> The bridge is finished.
<Steve> Looks great!
<Alex> 明天继续。
Changes saved.
12 messages