I do not know how to do this with buttons. Below is a rough example using check boxes. I expect it is not good enough to meet your needs but perhaps it can get you started.
library(shiny)
ui <- fluidPage(
titlePanel("Table"),
fluidRow(
column(style = "background-color: skyblue; border-style:solid;
border-color: white;", width = 1, HTML('<div>-</div>')),
column(style = "background-color: skyblue; border-style:solid;
border-color: white;", width = 1, HTML('<div>A</div>')),
column(style = "background-color: skyblue; border-style:solid;
border-color: white;", width = 1, HTML('<div>B</div>')),
column(style = "background-color: skyblue; border-style:solid;
border-color: white;", width = 1, HTML('<div>C</div>'))
),
fluidRow(
column(width = 1, style = "background-color: skyblue;
border-style:solid ; border-color: white;", HTML('<div>1</div>')),
column(width = 1, uiOutput("B1out"), checkboxInput("B1", label = NULL)),
column(width = 1, uiOutput("B2out"), checkboxInput("B2", label = NULL)),
column(width = 1, uiOutput("B3out"), checkboxInput("B3", label = NULL))
),
fluidRow(
column(width = 1, style = "background-color: skyblue;
border-style:solid ; border-color: white;", HTML('<div>2</div>')),
column(width = 1, uiOutput("B4out"), checkboxInput("B4", label = NULL)),
column(width = 1, uiOutput("B5out"), checkboxInput("B5", label = NULL)),
column(width = 1, uiOutput("B6out"), checkboxInput("B6", label = NULL))
),
fluidRow(
column(12, uiOutput("Count"))
)
)
server <- function(input, output) {
output$B1out <- renderUI(if(input$B1) {
HTML("<span style=background-color:red;>___+___</span>")
} else HTML("<span style=background-color:green;>___o___</span>"))
output$B2out <- renderUI(if(input$B2) {
HTML("<span style=background-color:red;>___+___</span>")
} else HTML("<span style=background-color:green;>___o___</span>"))
output$B3out <- renderUI(if(input$B3) {
HTML("<span style=background-color:red;>___+___</span>")
} else HTML("<span style=background-color:green;>___o___</span>"))
output$B4out <- renderUI(if(input$B4) {
HTML("<span style=background-color:red;>___+___</span>")
} else HTML("<span style=background-color:green;>___o___</span>"))
output$B5out <- renderUI(if(input$B5) {
HTML("<span style=background-color:red;>___+___</span>")
} else HTML("<span style=background-color:green;>___o___</span>"))
output$B6out <- renderUI(if(input$B6) {
HTML("<span style=background-color:red;>___+___</span>")
} else HTML("<span style=background-color:green;>___o___</span>"))
Count <- reactive(input$B1 + input$B2 + input$B3 + input$B4 + input$B5 + input$B6)
output$Count <- renderUI(tags$span(paste("Number of boxes checked = ", Count())))
}
# Run the application
shinyApp(ui = ui, server = server)