updateSelectInput_dsfr

updateNumericInput_dsfr(
  inputId,
  label = NULL,
  value = NULL,
  min = NULL,
  max = NULL,
  step = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

inputId

inputId

label

label

value

valeur par défaut

min

valeur minimale

max

valeur maximale

step

pas utilisé entre 2 valeurs

session

session shiny

Valeur de retour

html

Examples

## Only run examples in interactive R sessions
if (interactive()) {
  library(shiny)
  library(shinygouv)

  ui <- fluidPage_dsfr(
    header = header_dsfr(
      intitule = c("Intitule", "Officiel"),
      nom_site_service = "Nom du site / service",
      baseline = "baseline - precisions sur l organisation",
      class = "fr-m-1w"
    ),
    title = "Exemple",
    fluidRow_dsfr(
      numericInput_dsfr(
        inputId = "mynumericinput",
        label = "Numeric input",
        value = 12,
        min = 0,
        max = NA,
        step = 2
      ),
      actionButton_dsfr(
        inputId = "updateLabel",
        label = "updateLabel"
      ),
      actionButton_dsfr(
        inputId = "updateValue",
        label = "updateValue"
      ),
      actionButton_dsfr(
        inputId = "updateMin",
        label = "updateMin à la valeur en cours"
      ),
      actionButton_dsfr(
        inputId = "updateMax",
        label = "updateMax à la valeur en cours"
      ),
      actionButton_dsfr(
        inputId = "updateStep",
        label = "updateStep"
      ),
      verbatimTextOutput(outputId = "numericinputvalue")
    )
  )
  server <- function(input, output, session) {
    output$numericinputvalue <- renderText({
      paste("La valeur de l'input est", input$mynumericinput)
    })

    r <- reactiveValues()

    observeEvent(input$mynumericinput, {
      r$current_value <- input$mynumericinput
    })

    observeEvent(input$updateLabel, {
      updateNumericInput_dsfr(
        session = session,
        inputId = "mynumericinput",
        label = sample(LETTERS, 10)
      )
    })

    observeEvent(input$updateValue, {
      updateNumericInput_dsfr(
        session = session,
        inputId = "mynumericinput",
        value = sample(1:1000, size = 1)
      )
    })

    observeEvent(input$updateMin, {
      updateNumericInput_dsfr(
        session = session,
        inputId = "mynumericinput",
        min = r$current_value
      )
    })

    observeEvent(input$updateMax, {
      updateNumericInput_dsfr(
        session = session,
        inputId = "mynumericinput",
        max = r$current_value
      )
    })

    observeEvent(input$updateStep, {
      updateNumericInput_dsfr(
        session = session,
        inputId = "mynumericinput",
        step = sample(seq(0.1, 1, by = .1), size = 1)
      )
    })
  }

  shinyApp(ui, server)
}