Vlad
Vlad

Reputation: 3764

Shiny for python - adding an icon to the input_action_button

With R Shiny, adding an icon to an actionButton uses icon() function.

    actionButton(
       ...
      , icon = shiny::icon(icon_name)
    )

How can this be achieved with shiny.ui.input_action_button?

    ui.input_action_button(
        ...
        icon = ?
    )

Whatever I try in (?) seems to make it into a label instead of an icon.

Upvotes: 2

Views: 1189

Answers (3)

Eaque Arcana
Eaque Arcana

Reputation: 51

Adding to the previous answers, one solution I found is using the "faicons" library which include svg icons.

from faicons import icon_svg

ui.input_action_button(
        "go" , "Apply" ,  
        icon   = icon_svg("play"), 
        class_ = "btn-primary"
    )

A list of all free/pro icons that can be used instead of "play" can be found on Fontawesome website ( https://fontawesome.com/ )

Upvotes: 3

jesliu
jesliu

Reputation: 26

For the functions that accepts icon parameter, you can use an ui.img if you have an image like so:

icon=ui.img(src='image.png',
            height='18px',
            style='margin-bottom:2px'
            )

but you have to first make sure your www_dir is created which contains the image with the correct Path location and your App() function should have static_assets=www_dir

Upvotes: 0

Yousuf Ali
Yousuf Ali

Reputation: 48

Only example I found used emoji directly like this

ui.input_action_button("go", "Go!", icon="🤩")

Not sure you can use icon like R shiny.

Upvotes: 2

Related Questions