Enhance UI theme support with dark mode detection

pull/727/head
harshalmore31 1 day ago committed by GitHub
parent 6ae0b7c99f
commit 3c074aee4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1249,22 +1249,34 @@ class UI:
outputs=[component],
)
@staticmethod
def create_ui_theme(primary_color="red"):
import darkdetect # First install: pip install darkdetect
# Detect system theme
is_dark = darkdetect.isDark()
# Set text colors based on system theme
text_color = "#f0f0f0" if is_dark else "#000000"
bg_color = "#20252c" if is_dark else "#ffffff"
# Enforce theme settings
return gr.themes.Ocean(
primary_hue=primary_color,
secondary_hue=primary_color,
neutral_hue="gray",
).set(
body_background_fill="#20252c",
body_text_color="#f0f0f0",
body_background_fill=bg_color,
body_text_color=text_color,
button_primary_background_fill=primary_color,
button_primary_text_color="#ffffff",
button_primary_text_color=text_color,
button_secondary_background_fill=primary_color,
button_secondary_text_color="#ffffff",
button_secondary_text_color=text_color,
shadow_drop="0px 2px 4px rgba(0, 0, 0, 0.3)",
)
def create_agent_details_tab(self):
"""Create the agent details tab content."""
with gr.Column():
@ -1339,7 +1351,7 @@ def create_app():
with ui.blocks:
with gr.Row():
with gr.Column(scale=4): # Left column (80% width)
ui.create_markdown("Swarms", is_header=True)
ui.create_markdown("<b>Swarms</b>")
ui.create_markdown(
"<b>The Enterprise-Grade Production-Ready Multi-Agent"
" Orchestration Framework</b>"

Loading…
Cancel
Save