Skip to contents

Output Function for Displaying reactive objects and values

Usage

sd_output(id, type = NULL, display = "inline", wrapper = NULL, ...)

Arguments

id

Character string. A unique identifier for the output element.

type

Character string. Specifies the type of output. Can be "question", "value", or NULL. If NULL, the function behaves like shiny::uiOutput().

display

Character string. Specifies the display type for "value" outputs. Can be "inline", "text", "verbatim", or "ui". Only used when type = "value".

wrapper

Function. A function to wrap the output. Only used when type = "value".

...

Additional arguments passed to the underlying Shiny functions or the wrapper function.

Value

A Shiny UI element, the type of which depends on the input parameters.

Details

The function behaves differently based on the type parameter:

  • If type is NULL, it acts like shiny::uiOutput().

  • If type is "question", it creates a placeholder for a reactive survey question.

  • If type is "value", it creates an output to display the value of a survey question, with the display style determined by the display parameter.

Examples

if (FALSE) { # \dontrun{
# Create a placeholder for a reactive question
sd_output('cbc1', type = 'question')

# Display the value of a survey question inline
sd_output('cbc1', type = 'value', display = 'inline')

# Use as a simple uiOutput
sd_output('redirect')

# Use with a wrapper function
sd_output('age', type = 'value', display = 'text',
          wrapper = function(x) tags$strong(x))
} # }