Skip to content

Commit f0243f6

Browse files
Resize the chat input field for long inputs
1 parent 7c43499 commit f0243f6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

static/styles.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ pre {
375375

376376
.inputForm {
377377
display: flex;
378+
align-items: flex-end;
378379
width: 100%;
379380
padding: 10px;
380381
padding-bottom: 40px;
@@ -389,6 +390,11 @@ pre {
389390
border: 2px solid transparent;
390391
font-size: 1em;
391392
background-color: #efefef;
393+
resize: none; /* Prevent manual resize */
394+
overflow-y: hidden; /* Hide scrollbar */
395+
min-height: calc(1em + 32px + 4px); /* font-size + padding + border */
396+
height: auto; /* Allow it to grow */
397+
line-height: 1.5; /* Adjust for better multi-line readability */
392398
}
393399

394400
.input:focus {
@@ -403,6 +409,7 @@ pre {
403409
color: white;
404410
border: none;
405411
font-size: 1em;
412+
height: calc(1em + 32px + 4px); /* font-size + padding + border */
406413
border-radius: 60px; /* Removed duplicate border-radius property */
407414
}
408415

templates/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@
2525
</div>
2626
<form id="chatForm" class="inputForm clearfix"
2727
hx-on::after-request="this.reset()">
28-
<input
29-
type="text"
28+
<textarea
3029
class="input"
3130
name="userInput"
3231
placeholder="Enter your question"
3332
id="userInput"
3433
autocomplete="off"
34+
rows="1" {# Start with one row, will expand with CSS #}
35+
oninput="this.style.height = 'auto'; this.style.height = (this.scrollHeight) + 'px';"
3536
required
36-
/>
37+
></textarea>
3738
<button
3839
type="submit"
3940
class="button"

0 commit comments

Comments
 (0)