[Python] Use CSS for Shiny for Python with ui.tags.style

Discussão em 'Python' iniciado por Stack, Dezembro 18, 2024.

  1. Stack

    Stack Membro Participativo

    I want to CSS style my Shiny for Python Input fields, but It somehow doesn't work. I can however style the card headers. Does anyone know, what I am doing wrong? Or can the ui.input* elements not be styled directly?

    from shiny import App, render, ui, reactive
    from pathlib import Path


    app_ui = ui.page_fillable(
    ui.panel_title(
    ui.row(
    ui.column(12, ui.h1("title1")),
    )
    ),
    ui.layout_sidebar(
    ui.sidebar(
    ui.input_text("input_text1", "input_text1", value=""),
    ui.input_selectize("input_selectize1", "input_selectize1", choices=["1", "2"]),
    ui.input_numeric("input_numeric1", "input_numeric1", value=4),
    ui.input_switch("input_switch1", "input_switch1", value=False),
    ui.input_action_button("input_action_button1", "input_action_button1"),
    width="350px"
    ),
    ui.layout_columns(
    ui.card(
    ui.card_header("card_header1"),
    ui.output_data_frame("card1"),
    full_screen=True
    ),
    col_widths=12
    )
    ),
    ui.tags.style(
    ".card-header { color:white; background:#2A2A2A !important; }",
    ".input-text { color:red; height:0px; }",
    ".input-numeric { color:red; height:0px; }")
    )


    def server(input, output, session):

    @reactive.event(input.input_action_button1)
    def reactive_function1():
    pass

    @output
    @render.data_frame
    def card1():
    return reactive_function1()

    src_dir = Path(__file__).parent / "src"
    app = App(app_ui, server, static_assets=src_dir)

    Continue reading...

Compartilhe esta Página