Fix UI: Reduce dialog size and prevent input focus layout shifts
Browse files- Reduce chatbot height from 600px to 400px for better screen usage
- Add CSS to prevent textarea resize and layout shifts on focus
- Set fixed heights instead of viewport-based heights for consistency
- Improve textbox behavior with max-lines and autofocus settings
- Add responsive design with fixed heights for larger screens
- gradio_app.py +33 -7
gradio_app.py
CHANGED
|
@@ -269,8 +269,9 @@ css = """
|
|
| 269 |
padding: 20px !important;
|
| 270 |
}
|
| 271 |
#chatbot {
|
| 272 |
-
height:
|
| 273 |
-
|
|
|
|
| 274 |
overflow-y: auto !important;
|
| 275 |
border-radius: 12px !important;
|
| 276 |
border: 1px solid #e0e0e0 !important;
|
|
@@ -299,13 +300,31 @@ css = """
|
|
| 299 |
.gr-textbox {
|
| 300 |
border-radius: 8px !important;
|
| 301 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
/* Responsive design for different screen sizes */
|
| 303 |
@media (min-width: 1400px) {
|
| 304 |
.gradio-container {
|
| 305 |
padding: 40px !important;
|
| 306 |
}
|
| 307 |
#chatbot {
|
| 308 |
-
height:
|
|
|
|
| 309 |
}
|
| 310 |
}
|
| 311 |
@media (min-width: 1800px) {
|
|
@@ -313,7 +332,8 @@ css = """
|
|
| 313 |
padding: 60px !important;
|
| 314 |
}
|
| 315 |
#chatbot {
|
| 316 |
-
height:
|
|
|
|
| 317 |
}
|
| 318 |
}
|
| 319 |
"""
|
|
@@ -343,9 +363,11 @@ with gr.Blocks(css=css, title="Llama Chat", theme=gr.themes.Soft()) as demo:
|
|
| 343 |
avatar_images=(None, None),
|
| 344 |
show_share_button=False,
|
| 345 |
type="messages", # Use new message format
|
| 346 |
-
height=
|
| 347 |
render_markdown=True,
|
| 348 |
-
show_copy_button=True
|
|
|
|
|
|
|
| 349 |
)
|
| 350 |
|
| 351 |
with gr.Row():
|
|
@@ -353,7 +375,11 @@ with gr.Blocks(css=css, title="Llama Chat", theme=gr.themes.Soft()) as demo:
|
|
| 353 |
msg = gr.Textbox(
|
| 354 |
placeholder="Type your message here...",
|
| 355 |
show_label=False,
|
| 356 |
-
container=False
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
)
|
| 358 |
with gr.Column(scale=1):
|
| 359 |
submit_btn = gr.Button("Send", variant="primary")
|
|
|
|
| 269 |
padding: 20px !important;
|
| 270 |
}
|
| 271 |
#chatbot {
|
| 272 |
+
height: 400px !important;
|
| 273 |
+
max-height: 400px !important;
|
| 274 |
+
min-height: 400px !important;
|
| 275 |
overflow-y: auto !important;
|
| 276 |
border-radius: 12px !important;
|
| 277 |
border: 1px solid #e0e0e0 !important;
|
|
|
|
| 300 |
.gr-textbox {
|
| 301 |
border-radius: 8px !important;
|
| 302 |
}
|
| 303 |
+
|
| 304 |
+
/* Prevent textbox from affecting layout */
|
| 305 |
+
.gradio-textbox textarea {
|
| 306 |
+
resize: none !important;
|
| 307 |
+
max-height: 120px !important;
|
| 308 |
+
min-height: 40px !important;
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
/* Prevent layout shifts on focus */
|
| 312 |
+
.gradio-container .wrap {
|
| 313 |
+
min-height: auto !important;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
/* Stable row heights */
|
| 317 |
+
.gradio-row {
|
| 318 |
+
min-height: auto !important;
|
| 319 |
+
}
|
| 320 |
/* Responsive design for different screen sizes */
|
| 321 |
@media (min-width: 1400px) {
|
| 322 |
.gradio-container {
|
| 323 |
padding: 40px !important;
|
| 324 |
}
|
| 325 |
#chatbot {
|
| 326 |
+
height: 450px !important;
|
| 327 |
+
max-height: 450px !important;
|
| 328 |
}
|
| 329 |
}
|
| 330 |
@media (min-width: 1800px) {
|
|
|
|
| 332 |
padding: 60px !important;
|
| 333 |
}
|
| 334 |
#chatbot {
|
| 335 |
+
height: 500px !important;
|
| 336 |
+
max-height: 500px !important;
|
| 337 |
}
|
| 338 |
}
|
| 339 |
"""
|
|
|
|
| 363 |
avatar_images=(None, None),
|
| 364 |
show_share_button=False,
|
| 365 |
type="messages", # Use new message format
|
| 366 |
+
height=400, # Reduced from 600 to 400
|
| 367 |
render_markdown=True,
|
| 368 |
+
show_copy_button=True,
|
| 369 |
+
container=True,
|
| 370 |
+
scale=1
|
| 371 |
)
|
| 372 |
|
| 373 |
with gr.Row():
|
|
|
|
| 375 |
msg = gr.Textbox(
|
| 376 |
placeholder="Type your message here...",
|
| 377 |
show_label=False,
|
| 378 |
+
container=False,
|
| 379 |
+
lines=1,
|
| 380 |
+
max_lines=3,
|
| 381 |
+
autofocus=False,
|
| 382 |
+
interactive=True
|
| 383 |
)
|
| 384 |
with gr.Column(scale=1):
|
| 385 |
submit_btn = gr.Button("Send", variant="primary")
|