express.page_chat
express.page_chat(
title,
*,
id='chat',
icon=None,
pages_navbar=None,
toolbar=None,
toolbar_global=MISSING,
toolbar_input=None,
navbar_options=None,
sidebar=True,
drawer=True,
window_title=None,
lang=None,
theme=None,
messages=None,
greeting=None,
placeholder='Enter a message...',
width='min(clamp(680px, 50vw, 760px), 100%)',
icon_assistant=None,
icon_send=None,
enable_cancel=MISSING,
allow_attachments=MISSING,
footer=None,
**kwargs,
)Create the sole top-level UI item for a full-window Express chat page.
The chat is the home page and remains mounted while users visit secondary pages. This function configures :func:shiny.express.ui.page_opts internally and owns the complete top-level page layout. Do not also call chat.ui(), add unrelated top-level UI, wrap the returned chat root, or assign it to a variable. Compose additional UI through pages_navbar, toolbar, toolbar_global, sidebar, and drawer.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| title | TagChild | Page title displayed in the header. When it is a string and window_title is omitted, it is also used as the document title. |
required |
| icon | TagChild | None | Optional HTML child displayed next to title. |
None |
| id | str | Unique ID shared by the page shell and its chat. Use the same ID for the server-side :class:~shinychat.express.Chat. |
'chat' |
| pages_navbar | Sequence[ChatNavPanel | NavSetArg | MetadataNode] | None | Secondary navbar items. In addition to :func:~shinychat.chat_nav_panel, this accepts Shiny’s :func:shiny.ui.nav_panel, :func:shiny.ui.nav_menu, :func:shiny.ui.nav_spacer, and :func:shiny.ui.nav_control. Standard content panels use the normal page-chat content width and no page-specific sidebar or toolbar. Shiny for Python does not currently expose nav_panel_hidden() or nav_item(); use :func:shiny.ui.nav_control for non-selecting navigation content. Sidebar navigation is not yet implemented. |
None |
| toolbar | TagChild | None | Optional home-page-scoped HTML child displayed with the navigation controls. Use :func:shiny.ui.toolbar to group toolbar controls. A secondary page’s chat_nav_panel(toolbar=) replaces this scoped segment. |
None |
| toolbar_global | TagChild | None | MISSING_TYPE | Optional persistent HTML child displayed after the page-scoped toolbar in the navigation controls. Use :func:shiny.ui.toolbar to group toolbar controls. When omitted, it contains Shiny’s dark/light mode toggle; pass None to opt out. It remains mounted while secondary pages are selected and while controls move between desktop and mobile layouts. |
MISSING |
| toolbar_input | TagChild | None | Optional HTML content displayed directly below the chat input. Use :func:shiny.ui.toolbar to group toolbar controls. This is independent of the navigation toolbar. |
None |
| navbar_options | Any | Optional :func:shiny.ui.navbar_options that styles the page title bar. position and collapsible are unsupported because page_chat() owns the full-window layout and responsive app menu. |
None |
| sidebar | bool | ChatSidebar | Home-page sidebar. True uses the default conversation-history sidebar, False removes it, and a :class:~shinychat.types.ChatSidebar supplies custom content and behavior. Raw :class:shiny.ui.Sidebar objects are not supported. |
True |
| drawer | bool | ChatDrawer | Whether the chat has an artifact panel. Pass a :class:~shinychat.types.ChatDrawer to configure its initial content and behavior. |
True |
| window_title | str | None | Optional document title. Use this when title is an HTML child or when the browser title should differ from the displayed title. |
None |
| lang | str | None | Optional language for the document’s <html> element. |
None |
| theme | str | Path | Theme | ThemeProvider | None | Theme accepted by :func:shiny.express.ui.page_opts. By default, :func:~shinychat.page_chat_theme layers page-chat tokens over the "shiny" preset. |
None |
| messages | Optional[Iterable[str | TagChild | 'ChatMessageDict' | 'ChatMessage' | Any]] | Initial chat messages. See :meth:shinychat.express.Chat.ui. |
None |
| greeting | Optional[Union[str, HTML, Tag, TagList, 'ChatGreeting']] | Optional initial chat greeting. See :func:~shinychat.chat_greeting. |
None |
| placeholder | str | Placeholder text for the chat input. | 'Enter a message...' |
| width | 'CssUnit' | Maximum width of the chat content. | 'min(clamp(680px, 50vw, 760px), 100%)' |
| icon_assistant | Optional[HTML | Tag | TagList | bool] | Default icon for assistant messages. None (the default) or False omits it; True uses the built-in robot icon. |
None |
| icon_send | Optional[HTML | Tag | TagList | bool] | The icon to use for the chat input’s ready-state submit button. None (the default) or False uses the default arrow icon. |
None |
| enable_cancel | 'bool | MISSING_TYPE' | Whether to show the streaming cancel control. When omitted, a chat constructed with client= enables it automatically. |
MISSING |
| allow_attachments | 'bool | list[str] | MISSING_TYPE' | Whether to allow attachments, or a list of accepted MIME types. When omitted, a chat constructed with client= enables them automatically. |
MISSING |
| footer | Optional[TagChild] | Optional HTML content in a bottom-pinned, full-width chat region. | None |
| **kwargs | Any | Additional :func:~shinychat.chat_ui options and HTML attributes. page_chat() owns height, fill, and show_history; these arguments cannot be overridden. |
{} |
Returns
| Name | Type | Description |
|---|---|---|
| Tag | The internally created chat root. It must remain the sole top-level Express UI item. |
Examples
from shiny import ui
from shinychat import chat_nav_panel, chat_sidebar
from shinychat.express import Chat, page_chat
chat = Chat("chat")
page_chat(
"Assistant",
pages_navbar=[
chat_nav_panel("About", ui.p("About this app"), sidebar=False),
],
sidebar=chat_sidebar(history=False),
)See Also
: Create the same layout in a Core app. : Configure page sidebars. : Configure secondary navbar pages. : Configure the artifact panel.