sd_ui {surveydown} | R Documentation |
Create the UI for a surveydown survey
Description
This function creates the user interface for a surveydown survey, including necessary CSS and JavaScript files, and applies custom styling. It retrieves theme and progress bar settings from the survey.qmd file.
Usage
sd_ui()
Details
The function reads the following settings from the survey.qmd YAML header:
-
theme
: The theme to be applied to the survey. -
barcolor
: The color of the progress bar (should be a valid hex color). -
barposition
: The position of the progress bar ('top'
,'bottom'
, or'none'
).
If barcolor
is not specified or is NULL
, the default theme color will be
used. If barposition
is not specified, it defaults to 'top'.
Value
A 'shiny' UI object
See Also
sd_server()
for creating the server-side logic of the survey
Examples
if (interactive()) {
library(surveydown)
# Get path to example survey file
survey_path <- system.file("examples", "sd_ui.qmd",
package = "surveydown")
# Copy to a temporary directory
temp_dir <- tempdir()
file.copy(survey_path, file.path(temp_dir, "survey.qmd"))
orig_dir <- getwd()
setwd(temp_dir)
# Define a minimal server
server <- function(input, output, session) {
sd_server()
}
# Run the app
shiny::shinyApp(ui = sd_ui(), server = server)
# Clean up
setwd(orig_dir)
}
[Package surveydown version 0.12.6 Index]