chat_ui
chat_ui(
id,
*,
messages=None,
greeting=None,
placeholder='Enter a message...',
width='min(680px, 100%)',
height='auto',
fill=True,
icon_assistant=None,
enable_cancel=MISSING,
footer=None,
**kwargs,
)UI container for a chat component (Shiny Core).
This function is for locating a :class:~shiny.ui.Chat instance in a Shiny Core app. If you are using Shiny Express, use the :method:~shiny.ui.Chat.ui method instead.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| id | str | A unique identifier for the chat UI. | required |
| messages | Optional[Iterable[str | TagChild | ChatMessageDict | ChatMessage | Any]] | A sequence of messages to display in the chat. A given message can be one of the following: * A string, which is interpreted as markdown and rendered to HTML on the client. * To prevent interpreting as markdown, mark the string as :class:~shiny.ui.HTML. * A UI element (specifically, a :class:~shiny.ui.TagChild). * This includes :class:~shiny.ui.TagList, which take UI elements (including strings) as children. In this case, strings are still interpreted as markdown as long as they’re not inside HTML. * A dictionary with content and role keys. The content key can contain a content as described above, and the role key can be “assistant” or “user”. * More generally, any type registered with :func:shinychat.message_content. NOTE: content may include specially formatted input suggestion links (see :method:~shiny.ui.Chat.append_message for more info). |
None |
| greeting | Optional[Union[str, HTML, Tag, TagList, ChatGreeting]] | An optional greeting to display at the top of the chat before any conversation messages. Can be a markdown string or a :func:~shinychat.chat_greeting object. For a dynamic or streaming greeting, use :meth:~shinychat.Chat.set_greeting from the server instead. When no greeting is set and the chat is visible with no messages, an input named {id}_greeting_requested fires. Use this input with @reactive.event(input.{id}_greeting_requested) to generate a greeting on demand from the server. It fires again after :meth:~shinychat.Chat.clear_messages is called with greeting=True. |
None |
| placeholder | str | Placeholder text for the chat input. | 'Enter a message...' |
| width | 'CssUnit' | The width of the chat container. | 'min(680px, 100%)' |
| height | 'CssUnit' | The height of the chat container. | 'auto' |
| fill | bool | Whether the chat should vertically take available space inside a fillable container. | True |
| icon_assistant | Optional[HTML | Tag | TagList] | The icon to use for the assistant chat messages. Can be a HTML or a tag in the form of :class:~htmltools.HTML or :class:~htmltools.Tag. If None, a default robot icon is used. |
None |
| enable_cancel | 'bool | MISSING_TYPE' | Whether to show a stop button during streaming that allows the user to cancel the in-progress response. When True, the chat UI shows a stop button in place of the send button while streaming. You must observe input.<id>_cancel on the server and call ctrl.cancel() on a chatlas StreamController to actually stop the stream. When left unset (the default), a chat driven by a client= enables the stop button automatically; otherwise it stays hidden. Passing an explicit True/False always wins over that automatic behavior. |
MISSING |
| footer | Optional[TagChild] | Optional HTML content to display below the chat input. This can be any HTML content (tags, tag lists, or strings). Useful for adding disclaimers, attribution, or other information. The footer text is styled slightly smaller and lighter than body text by default. Customize with CSS properties --shiny-chat-footer-font-size and --shiny-chat-footer-color on the chat container or footer element. |
None |
| kwargs | TagAttrValue | Additional attributes for the chat container element. | {} |