Skip to content

Commit b31f68b

Browse files
authored
fix(sender): fix max height and optimize scrollbar (#73)
<img width="1144" height="345" alt="image" src="https://github.com/user-attachments/assets/8c86c7f5-9948-4de6-9ad9-aef2d37b3d4e" /> <img width="1130" height="376" alt="image" src="https://github.com/user-attachments/assets/49647db4-2db5-4249-a89e-fc9cd70d95dc" /> After 4 rows, appearing overflow-y-auto. I set the max-h-32 , which could be modified. But the overflow-y-auto looks ugly, and idk how to modify.
1 parent d4f4a69 commit b31f68b

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

.changes/fix-sender-overflow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@matechat/react": patch:fix
3+
---
4+
5+
Fix max height of sender and optimize scrollbar style.

playground/src/Chat.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { InputCount, Sender } from "@matechat/react/sender";
1111
import type { MessageParam } from "@matechat/react/utils";
1212
import { useChat } from "@matechat/react/utils/chat";
1313
import { useMateChat } from "@matechat/react/utils/core";
14+
import clsx from "clsx";
1415
import { MessageSquarePlus } from "lucide-react";
1516
import { useMemo, useState } from "react";
1617

@@ -84,7 +85,13 @@ export function Chat() {
8485
<div className="flex flex-col items-center justify-center min-h-screen bg-gray-100">
8586
<main className="flex flex-col items-center justify-center h-[80vh] w-full max-w-3xl p-4 bg-white rounded-lg shadow-md gap-5">
8687
<BubbleList
87-
className="px-4 w-full max-w-full"
88+
className={clsx(
89+
"px-4 w-full max-w-full",
90+
"[scrollbar-gutter:stable] [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full",
91+
"[&::-webkit-scrollbar-thumb]:cursor-auto",
92+
"[&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-thumb]:bg-gray-600",
93+
"[&::-webkit-scrollbar-thumb:hover]:bg-gray-400 dark:[&::-webkit-scrollbar-thumb:hover]:bg-gray-500",
94+
)}
8895
messages={messages}
8996
background="right-solid"
9097
isPending={pending}

src/sender.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ export function Sender({
180180
data-slot="sender"
181181
className={twMerge(
182182
clsx(
183-
"flex flex-col items-center border border-gray-200 dark:border-gray-700 rounded-2xl shadow-sm transition-all duration-300 hover:shadow-md focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500",
183+
"px-1 flex flex-col items-center border rounded-2xl",
184+
"border-gray-200 dark:border-gray-700 shadow-sm transition-all duration-300 hover:shadow-md",
185+
"focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500",
184186
className,
185187
),
186188
)}
@@ -192,7 +194,16 @@ export function Sender({
192194
onChange={handleChange}
193195
onKeyDown={handleKeyDown}
194196
placeholder={placeholder}
195-
className="w-full pt-4 px-4 border-0 rounded-2xl !resize-none focus:ring-0 focus:outline-none text-gray-700 placeholder-gray-400"
197+
className={clsx(
198+
"w-full pt-4 px-4 border-0 rounded-2xl !resize-none bg-transparent",
199+
"focus:ring-0 focus:outline-none text-gray-700 placeholder-gray-400",
200+
"overflow-y-auto max-h-32",
201+
"[scrollbar-gutter:stable] [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full",
202+
"[&::-webkit-scrollbar-thumb]:cursor-auto",
203+
"[&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-thumb]:bg-gray-600",
204+
"[&::-webkit-scrollbar-thumb:hover]:bg-gray-400 dark:[&::-webkit-scrollbar-thumb:hover]:bg-gray-500",
205+
"[&::-webkit-scrollbar-track]:mt-3",
206+
)}
196207
rows={2}
197208
/>
198209
<div className="flex items-center w-full px-4 py-2 gap-4">

0 commit comments

Comments
 (0)