Author: David Granjon
Date: 2025-08-25

# Extra Elements

#### David Granjon

#### 2025-08-25

## Accordion

Accordions are a category of collapsible elements. While collapsible items do not alter the state of other items in the same collapsible container, each accordion item will toggle any other opened accordion, to ensure that only 1 item is visible at once. `accordion()` expects to contain `accordionItems()`. Importantly, to guaranty the uniqueness of each accordion, we must provide an id parameter. This parameter allows to programmatically toggle any accordion item, through an `updateAccordion()` function.

## User messages

`{bs4Dash}` make it possible to create an entire chat system within a Shiny app. `userMessages()` is the main container, `userMessage()` being the message element. `updateUserMessages()` looks for the `userMessages()` id so as to:

- Remove an existing message.
- Add a new message.
- Edit an existing message.

Importantly, we assume that a message structure is composed as follows:

    list(
      author = "David",
      date = "Now",
      image = "https://i.pinimg.com/originals/f1/15/df/f115dfc9cab063597b1221d015996b39.jpg",
      type = "received",
      text = tagList(
        sliderInput(
          "obs",
          "Number of observations:",
          min = 0,
          max = 1000,
          value = 500
        ),
        plotOutput("distPlot")
      )

The type parameter controls the message background color. For a sent message, the color is inherited from the `userMessages()` status, while for a received message, the color is gray by default. The text argument refers to the message content. It may be simple text, shiny tags or event any combinations of shiny inputs/ouput, as shown in the below example.