-
Is it possible to provide an example of a split button with menuProps ? |
Beta Was this translation helpful? Give feedback.
Answered by
jakubsob
Feb 27, 2023
Replies: 2 comments
-
Hi @Kvit, please take a look at the following example: library(shiny)
library(shiny.fluent)
menuProps <- list(
items = list(
list(
key = "emailMessage",
text = "Email message",
onClick = JS("() => alert('Email message clicked')"),
iconProps = list(
iconName = "Mail"
)
),
list(
key = "calendarEvent",
text = "Calendar event",
onClick = JS("() => alert('Calendar event clicked')"),
iconProps = list(
iconName = "Calendar"
)
)
)
)
shinyApp(
ui = fluentPage(
Stack(
horizontal = TRUE,
wrap = TRUE,
tokens = list(
childrenGap = 40
),
DefaultButton.shinyInput(
inputId = "button_1",
text = "Standard",
primary = FALSE,
split = TRUE,
splitButtonAriaLabel = "See 2 options",
`aria-roledescription` = "split button",
menuProps = menuProps,
disabled = FALSE,
checked = FALSE
),
DefaultButton.shinyInput(
inputId = "button_2",
text = "Primary",
primary = TRUE,
split = TRUE,
splitButtonAriaLabel = "See 2 options",
`aria-roledescription` = "split button",
menuProps = menuProps,
disabled = FALSE,
checked = FALSE
),
DefaultButton.shinyInput(
inputId = "button_3",
text = "Main action disabled",
primaryDisabled = NA,
split = TRUE,
splitButtonAriaLabel = "See 2 options",
`aria-roledescription` = "split button",
menuProps = menuProps,
checked = FALSE
),
DefaultButton.shinyInput(
inputId = "button_4",
text = "Disabled",
disabled = TRUE,
split = TRUE,
splitButtonAriaLabel = "See 2 options",
`aria-roledescription` = "split button",
menuProps = menuProps,
checked = FALSE
)
),
uiOutput("text")
),
server = function(input, output) {
output$text <- renderUI({
lapply(seq_len(4), function(i) {
paste0("button_", i, ": ", input[[paste0("button_", i)]])
})
})
}
) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jakubsob
-
@jakubsob, thank you a lot; looks great. Follow-up question: how to modify |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @Kvit,
please take a look at the following example: