page_chat
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 a full-window page containing one persistent chat interface.
The chat is the home page and remains mounted while users visit secondary pages. page_chat() owns the document shell, responsive navigation, sidebars, and full-height chat layout. Use :func:~shinychat.chat_ui instead when chat should be embedded in another page layout.
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. The currently selected page is readable server-side as input["<id>_page"]() and settable via :func:shiny.ui.update_navset. The reserved value "__home__" represents the main chat page. |
'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. Its bg, theme, underline, and HTML attributes are supported. 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. A sidebar created without history= defaults to True here. Raw :class:shiny.ui.Sidebar objects are not supported. |
True |
| drawer | bool | ChatDrawer | Whether the chat has a drawer. 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.ui.page_fillable. By default, :func:~shinychat.page_chat_theme layers page-chat surface tokens over Shiny’s "shiny" preset. Pass a :class:shiny.ui.Theme directly to use another preset or a completely custom theme. |
None |
| messages | Optional[Iterable[str | TagChild | 'ChatMessageDict' | 'ChatMessage' | Any]] | Initial chat messages. See :func:~shinychat.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 | A complete fillable Shiny page suitable for use as a Core app’s UI. |
Examples
from shiny import App, ui
from shinychat import Chat, chat_nav_panel, chat_sidebar, page_chat
app_ui = page_chat(
"Assistant",
pages_navbar=[
chat_nav_panel("About", ui.p("About this app"), sidebar=False),
],
sidebar=chat_sidebar(history=False),
)
def server(input, output, session):
Chat("chat")
app = App(app_ui, server)See Also
: Embed chat in an existing page layout. : Configure page sidebars. : Configure secondary navbar pages. : Configure the drawer. : Create the same layout in Express.