-
Notifications
You must be signed in to change notification settings - Fork 81
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
Possibility of user-defined custom toggles [enhancement] #352
Comments
@candidosobrinhosa I am looking for the same and I managed to add a custom toggle using this code, but it looks fugly:
It would be nice to include a native toggle switch just like the "dark" and "help" toggles. In the help for |
ok so with my limited css knowledge I managed to align and make it a bit nicer, but
|
Hi, I think you could leverage Bootstrap 4 power and use the custom switch component (the same I used in the header for the theme switch and help switch): https://getbootstrap.com/docs/4.2/components/forms/#switches library(shiny)
library(bs4Dash)
switch_input <- function(inputId, label, checked = FALSE, disabled = FALSE) {
div(
class = "custom-control custom-switch",
tags$input(
id = inputId,
type = "checkbox",
disabled = if (disabled) NA,
class = "custom-control-input"
),
tags$label(
label,
`for` = inputId,
class = "custom-control-label"
)
)
}
ui <- dashboardPage(
header = dashboardHeader(
title = dashboardBrand(
title = "My dashboard",
color = "primary",
href = "https://adminlte.io/themes/v3",
image = "https://adminlte.io/themes/v3/dist/img/AdminLTELogo.png"
),
switch_input("plop", "Activate me!")
),
sidebar = dashboardSidebar(),
body = dashboardBody(),
controlbar = dashboardControlbar(),
title = "DashboardPage"
)
server <- function(input, output, session) {
observe({
print(input$plop)
})
}
shinyApp(ui, server) |
@DivadNojnarg That is awesome thanks! I think the Update: Just figured how to include the
|
I have generalised @DivadNojnarg's
I did some digging and implemented a similar function for form check inputs that seems to accept multiple choice inputs per type. Useful if you want to use the same style of inputs throughout your bs4Dash app:
|
Hello! Thanks for all the hard work!
I am currently hosting a web app reporting SARS in Brazil in two languages: English and Portuguese.
In order to swap between them, the user have to access radio buttons inside a dropdownmenu(notification) but a switch would look way better.
I wonder if there is a way to add a custom toggle, just like the "dark theme" and the new "help" toggles.
Best regards
The text was updated successfully, but these errors were encountered: