Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: add inline option for buttons #17

Closed
FrissAnalytics opened this issue Sep 24, 2017 · 2 comments
Closed

feature request: add inline option for buttons #17

FrissAnalytics opened this issue Sep 24, 2017 · 2 comments

Comments

@FrissAnalytics
Copy link

hi!

great package! Small question, can you add an option to have buttons e.g. a materialSwitch behave like inline elements? Say with an option materialSwitch( ..., inline = TRUE). Sometimes you want to place buttons next to each other instead of below each other.

kind regards, Herman

@pvictor
Copy link
Member

pvictor commented Sep 25, 2017

Thank you !
Your shiny JS tutorial help me a lot, so thanks to you !

I've added an inline argument to materialSwitch, so now you can do :

library("shiny")
library("shinyWidgets")

inline <- TRUE
right <- FALSE

ui <- fluidPage(
  tags$h2("Inline materialSwitch"),
  br(),
  materialSwitch(inputId = "msh1", label = "Switch 1", status = "primary", inline = inline, right = right),
  materialSwitch(inputId = "msh2", label = "Switch 2", status = "danger", inline = inline, right = right),
  materialSwitch(inputId = "msh3", label = "Switch 3", status = "success", inline = inline, right = right),
  materialSwitch(inputId = "msh4", label = "Switch 4", status = "warning", inline = inline, right = right),
  verbatimTextOutput("value1"),
  verbatimTextOutput("value2"),
  verbatimTextOutput("value3"),
  verbatimTextOutput("value4")
)

server <- function(input, output) {
 
  output$value1 <- renderText(input$msh1)
  output$value2 <- renderText(input$msh2)
  output$value3 <- renderText(input$msh3)
  output$value4 <- renderText(input$msh4)
}

shinyApp(ui = ui, server = server)

There is also an alternative in shiny with flowLayout :

library("shiny")
library("shinyWidgets")


ui <- fluidPage(
  tags$h2("Inline materialSwitch"),
  br(),
  flowLayout(
    materialSwitch(inputId = "msh1", label = "Switch 1", status = "primary"),
    materialSwitch(inputId = "msh2", label = "Switch 2", status = "danger"),
    materialSwitch(inputId = "msh3", label = "Switch 3", status = "success"),
    materialSwitch(inputId = "msh4", label = "Switch 4", status = "warning")
  ),
  verbatimTextOutput("value1"),
  verbatimTextOutput("value2"),
  verbatimTextOutput("value3"),
  verbatimTextOutput("value4")
)

server <- function(input, output) {
  
  output$value1 <- renderText(input$msh1)
  output$value2 <- renderText(input$msh2)
  output$value3 <- renderText(input$msh3)
  output$value4 <- renderText(input$msh4)
}

shinyApp(ui = ui, server = server)

Best,

Victor

@FrissAnalytics
Copy link
Author

great, thanks a bunch! Also nice to hear our Shiny JS tutorial series was helpful to you :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants