user3463225 user3463225 - 1 month ago 22
CSS Question

R shiny: use css template to action button

I want to change layout of actionButton in shiny with css file. I define action button in server.R and use as uiOutput() in ui.R as below

server.R

shinyServer(function(input, output) {
output$ActionButtonExample <- renderUI({
actionButton(
inputId = "ActionButtonExample",
label = "Accept",
icon = icon("check"),
width = '50%',
style = 'float:right;'
)
})

})


ui.R

# Define UI for application that draws a histogram
shinyUI(fluidPage(

# Application title
titlePanel("Old Faithful Geyser Data"),

# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),

# Show a plot of the generated distribution
mainPanel(
uiOutput("ActionButtonExample")
)
)
))


Could somebody explain how to style button for example with css define here: http://bootsnipp.com/snippets/l05nD ?

Answer
  1. Create a www subfolder under your project root, put the css file over there.
  2. Add the following line to ui

    tags$head(tags$style(src="btn3d.css"))
    
  3. Change your actionButton class (change the class as needed)

    actionButton("id", "name", class="btn3d btn-primary")
    
Comments