Spaces:
Sleeping
Sleeping
| from future import annotations | |
| from typing import Iterable | |
| import gradio as gr | |
| gr.themes.builder() | |
| from gradio.themes.base import Base | |
| from gradio.themes.utils import colors, fonts, sizes | |
| class Modern(Base): | |
| def __init__( | |
| self, | |
| *, | |
| primary_hue: colors.Color | str = colors.neutral, | |
| secondary_hue: colors.Color | str = colors.neutral, | |
| neutral_hue: colors.Color | str = colors.neutral, | |
| spacing_size: sizes.Size | str = sizes.spacing_md, | |
| radius_size: sizes.Size | str = sizes.radius_md, | |
| text_size: sizes.Size | str = sizes.text_lg, | |
| font: fonts.Font | str | Iterable[fonts.Font | str] = ( | |
| "ui-sans-serif", | |
| "system-ui", | |
| "Segoe UI", | |
| "Roboto", | |
| ), | |
| font_mono: fonts.Font | str | Iterable[fonts.Font | str] = ( | |
| "ui-monospace", | |
| "SFMono-Regular", | |
| "Consolas", | |
| ), | |
| ): | |
| super().__init__( | |
| primary_hue=primary_hue, | |
| secondary_hue=secondary_hue, | |
| neutral_hue=neutral_hue, | |
| spacing_size=spacing_size, | |
| radius_size=radius_size, | |
| text_size=text_size, | |
| font=font, | |
| font_mono=font_mono, | |
| ) | |
| self.name = ("Modern",) | |
| def set(self): | |
| super().set( | |
| # Base styles | |
| background_fill_primary="#0F0F0F", | |
| background_fill_primary_dark="#0F0F0F", | |
| background_fill_secondary="#0F0F0F", | |
| background_fill_secondary_dark="#0F0F0F", | |
| body_text_color="white", | |
| body_text_color_dark="white", | |
| body_text_color_subdued="#999", | |
| body_text_color_subdued_dark="#999", | |
| border_color_primary="#333", | |
| border_color_primary_dark="#333", | |
| spacing_size=sizes.spacing_md, | |
| # Blocks | |
| block_radius="0 0 0 0", | |
| block_border_width="1px", | |
| block_border_color="#333", | |
| block_background_fill="#151515", | |
| block_padding="*spacing_lg", | |
| block_margin="*spacing_md 0", | |
| # Buttons | |
| button_primary_background_fill="#111", | |
| button_primary_background_fill_hover="#222", | |
| button_primary_text_color="white", | |
| button_secondary_background_fill="transparent", | |
| button_secondary_border_color="#666", | |
| button_secondary_text_color="#fff", | |
| button_secondary_border_width="1px", | |
| button_radius="6px", | |
| button_transition="0.2s", | |
| # Inputs | |
| input_background_fill="#181818", | |
| input_border_color="#444", | |
| input_text_color="white", | |
| input_padding="*spacing_md", | |
| input_radius="6px", | |
| input_border_width="1px", | |
| # Textarea | |
| textarea_background_fill="#181818", | |
| textarea_border_color="#444", | |
| textarea_text_color="white", | |
| textarea_padding="*spacing_md", | |
| textarea_radius="6px", | |
| textarea_border_width="1px", | |
| # Layout | |
| layout_gap="*spacing_lg", | |
| block_label_padding="*spacing_sm *spacing_lg", | |
| block_label_radius="6px", | |
| block_label_border_width="1px", | |
| block_label_border_color="#333", | |
| block_label_background_fill="#151515", | |
| ) | |
| def your_function(text): | |
| print(text) | |
| range = text | |
| return range | |
| # Assuming SimpleModern is your custom theme class | |
| demo = gr.Interface( | |
| fn=your_function, | |
| inputs=gr.Textbox(), | |
| outputs=gr.Textbox(), | |
| theme=Modern(), | |
| title="Test App", | |
| ) | |
| demo.launch() | |