Here is my solution without using value_box
function of library(bslib)
library(bsicons).
title: "Count N" format: dashboard server: shiny
#| context: setup
library(shiny)
library(shinyWidgets)
library(tidyverse)
data <- tibble::tibble(a = c(1, 2, 3)) # The data should always be retrieved from a server when the dashboard starts later, that's why I need the server context
sliderInput(
inputId = "myValue",
label = "custom slider",
min = 1,
max = 50,
value = 30
)
#| title: "n1"
#| icon: "trash"
#| color: teal
textOutput("n1")
#| content: valuebox
#| title: "n4"
#| icon: pencil
#| color: teal
textOutput("n4")
#| content: valuebox
#| title: "n2"
#| icon: music
#| color: teal
textOutput("n2")
#| content: valuebox
#| title: "n2"
#| icon: music
#| color: teal
textOutput("n2")
#| content: valuebox
#| title: "Fixed Value: n3"
#| icon: "trash"
#| color: "danger"
textOutput("myFixValue")
#| title: "Dynamic Value Depends on Slider"
textOutput("myValueText")
#| context: server
n <- data |> nrow() |> as.character()
output$n1 <- renderText(n)
output$n4 <- renderText(paste0("my new value:", " ", n))
output$n2 <- renderText(n)
n3 <- 99 |> as.character()
output$myFixValue <- renderText(n3)
output$myValueText <- renderText({ input$myValue})