A stick-to-bottom transcript viewport for streaming chat. Follows the live edge only while the reader is at the bottom; scrolling up detaches and surfaces a jump-to-latest button. Prepended history preserves the visible anchor. Part of the chat/AI kit.
Usage
shad_message_scroller(
id,
...,
auto_scroll = TRUE,
default_position = c("end", "start", "last-anchor"),
jump_label = "Jump to latest",
height = NULL,
class = NULL
)
shad_message_scroller_item(..., anchor = FALSE, class = NULL)Arguments
- id
Element id (namespaced automatically in modules).
- ...
Rows – typically
shad_message_scroller_item()wrapping ashad_message(),shad_bubble(), orshad_marker().- auto_scroll
If
TRUE(default), follow new content while at the bottom.FALSEnever auto-follows.- default_position
Initial scroll position:
"end"(default),"start", or"last-anchor"(scroll the lastdata-anchoritem to top).- jump_label
Label for the jump-to-latest button.
- height
CSS height of the scroller (e.g.
400,"60vh").- class
Extra CSS classes.
- anchor
If
TRUE, marks this row as a turn boundary (data-anchor) fordefault_position = "last-anchor".
Details
Position is not a form value, so there is no input$<id>. Drive it from the
server with shad_message_scroller_to_bottom().
See also
shad_message_scroller_item(), shad_message_scroller_to_bottom()
Other shadshiny tier-3 components:
shad_accordion(),
shad_alert_dialog(),
shad_carousel(),
shad_collapsible(),
shad_command(),
shad_command_palette(),
shad_context_menu(),
shad_dialog(),
shad_drawer(),
shad_dropdown_menu(),
shad_hover_card(),
shad_menu_parts,
shad_menubar(),
shad_navigation_menu(),
shad_pagination(),
shad_popover(),
shad_resizable(),
shad_scroll_area(),
shad_sheet(),
shad_sidebar_layout(),
shad_tabs(),
shad_tooltip()
Examples
shad_message_scroller(
"chat", height = 400,
shad_message_scroller_item(shad_marker("Today", variant = "separator"),
anchor = TRUE),
shad_message_scroller_item(shad_bubble("Hi!", align = "start"))
)
#> <div class="shad-message-scroller" data-shad="message-scroller" id="chat" data-auto-scroll data-default-position="end" style="height:400px;">
#> <div class="shad-message-scroller__viewport" aria-live="polite" tabindex="0">
#> <div class="shad-message-scroller__content">
#> <div class="shad-message-scroller__item" data-anchor>
#> <div class="shad-marker shad-marker--separator">
#> <span class="shad-marker__content">Today</span>
#> </div>
#> </div>
#> <div class="shad-message-scroller__item">
#> <div class="shad-bubble shad-bubble--default shad-bubble--start">
#> <div class="shad-bubble__content">Hi!</div>
#> </div>
#> </div>
#> </div>
#> </div>
#> <button type="button" class="shad-message-scroller__button" aria-label="Jump to latest">
#> <svg class="shad-icon shad-icon--sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14"/><path d="m19 12-7 7-7-7"/></svg>
#> Jump to latest
#> </button>
#> </div>