word_count: Word Count Function

View source: R/word_count.R

word_countR Documentation

Word Count Function

Description

This function create tracks the word count and should be used with the text area function.

Usage

word_count(inputId, input, word_limit = NULL)

Arguments

inputId

The input slot of the text area that you want to affect

input

The text input that is associated with the box

word_limit

Change the word limit if needed. Default will keep as what was used in text area component

Value

no value returned. Updates the word count in a shiny app

See Also

Other Govstyle text types: date_Input(), gov_list(), heading_text(), input_field(), text_Input(), text_area_Input()

Examples

ui <- shiny::fluidPage(
  shinyjs::useShinyjs(),
  shinyGovstyle::header(
    "Justice", "", logo = "shinyGovstyle/images/moj_logo.png"
  ),
  gov_layout(
    size = "full",
    text_area_Input(
      inputId = "text_area",
      label = "Can you provide more detail?",
      hint_label = paste(
        "Do not include personal or financial information,",
        "like your National Insurance number or credit card details."
      ),
      word_limit = 300
    )
  ),
  footer(TRUE)
)

server <- function(input, output, session) {
  shiny::observeEvent(input$text_area,
    word_count(
      inputId = "text_area",
      input = input$text_area
    )
  )
}
if (interactive()) shinyApp(ui = ui, server = server)

shinyGovstyle documentation built on April 13, 2026, 5:06 p.m.