yania-n Claude Sonnet 4.6 commited on
Commit
3dc3729
·
1 Parent(s): cffdb58

Fix chatbot bubble CSS: use correct Gradio 6 DOM selectors

Browse files

In Gradio 6, .chatbot is on the inner prose element inside message
bubbles, NOT on the outer container. The old selectors like
.chatbot .bot required .bot to be a DESCENDANT of .chatbot, but
the actual DOM has .bot as an ANCESTOR - so no rule ever matched.

Replace with :root .message-wrap .bot / .user which correctly targets
the bubble divs, plus :root .bubble-wrap for the scroll container.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -225,28 +225,25 @@ button:not(.primary) {
225
  ul[role="listbox"] li,
226
  .option { color: var(--pc-text) !important; }
227
 
228
- /* === Chatbot (Gradio 6) === */
229
- /* Gradio 6 uses .bot / .user directly on the bubble div, not .message.bot */
230
- .chatbot, .chatbot .wrap {
 
 
 
 
231
  background: var(--pc-surface) !important;
232
- border-color: var(--pc-border) !important;
233
  }
234
- .chatbot .bot,
235
- .chatbot [data-testid="bot"] {
236
- background: var(--pc-surface-alt) !important;
237
  }
238
- .chatbot .user,
239
- .chatbot [data-testid="user"] {
240
- background: rgba(74,222,128,0.12) !important;
241
  }
242
- /* Text inside all message bubbles */
243
- .chatbot .bot *,
244
- .chatbot .user *,
245
- .chatbot [data-testid="bot"] *,
246
- .chatbot [data-testid="user"] *,
247
- .chatbot .prose,
248
- .chatbot .prose p,
249
- .chatbot p { color: var(--pc-text) !important; }
250
 
251
  /* === Plotly charts — override SVG text in light mode === */
252
  @media (prefers-color-scheme: light) {
 
225
  ul[role="listbox"] li,
226
  .option { color: var(--pc-text) !important; }
227
 
228
+ /* === Chatbot (Gradio 6) — correct DOM structure ===
229
+ In Gradio 6 the .chatbot class is on the INNER prose element inside each
230
+ message bubble, NOT on the outer container. That means ".chatbot .bot"
231
+ is backwards — .bot is an ANCESTOR of .chatbot, not a descendant.
232
+ Correct scoping: .message-wrap contains the .bot / .user bubble divs.
233
+ .bubble-wrap is the outer scrollable pane. */
234
+ :root .bubble-wrap {
235
  background: var(--pc-surface) !important;
 
236
  }
237
+ :root .message-wrap .bot {
238
+ background-color: var(--pc-surface-alt) !important;
239
+ border-color: var(--pc-border) !important;
240
  }
241
+ :root .message-wrap .user {
242
+ background-color: rgba(74,222,128,0.13) !important;
243
+ border-color: rgba(74,222,128,0.4) !important;
244
  }
245
+ :root .message-wrap .bot *,
246
+ :root .message-wrap .user * { color: var(--pc-text) !important; }
 
 
 
 
 
 
247
 
248
  /* === Plotly charts — override SVG text in light mode === */
249
  @media (prefers-color-scheme: light) {