htmlcssrshinyuioutput

R Shiny: Change uiOutput wrapper


Every time I use renderUI (server side) and uiOutput (UI side) the html is wrapper by a div, how can I wrappe it by a span instead?

For example:

UI side:

tags$p(uiOutput("my_variable"))

Server side:

output$currentLev1 <- renderUI({return(input$my_variable)})

Result:

<div id="my_variable" class="shiny-html-output shiny-bound-output">my_variable</div>

Desired result:

<span id="my_variable" class="shiny-html-output shiny-bound-output">my_variable</span>

(simply change div by span)

Thanks for the help


Solution

  • Using argument inline=T creates a span instead of a div:

    > args(uiOutput)
    function (outputId, inline = FALSE, container = if (inline) span else div, 
        ...) 
    NULL
    

    and so:

    > uiOutput("test", inline=T)
    <span id="test" class="shiny-html-output"></span>