Ask AI chat panel
AskAiChat renders a sidebar panel with AI chat (no keyword search). It’s one of the two components in the @fern-api/search-widget package, which covers the prerequisites and the Content Security Policy the widget needs.
The AskAiChat component embedded in a marketing site.
Setup
Render the chat
Import the component and the bundled styles, then render it with your docs domain. By default, the component renders its own trigger button, and citations in its answers link to your docs domain and open in a new tab. cmd/ctrl + / toggles the panel, and it becomes a bottom drawer below 768px.
Match the chat to your product
theme controls light and dark mode, and accentColor sets the accent used for the sparkles, the send button, and links in answers, in both modes. trigger chooses between the corner launcher (floating), an unpainted button you place and style yourself (inline), and no button at all (none).
Custom triggers
Opening the chat from your own UI
If the trigger is an element you already have (a link, a list row, a command palette entry), set trigger="none" so the widget renders no button, and drive open yourself:
Wire onOpenChange back to your state, or the chat’s own controls (its close button, Escape, and cmd/ctrl + /) will appear to do nothing. Pass neither prop and the widget manages its own state. With trigger="none", the trigger’s accessibility attributes (aria-haspopup="dialog", plus aria-expanded on a button) are yours to provide.
AskAiChat.Sparkles is the sparkle icon the built-in trigger uses, for making your own trigger read as the same affordance. It sizes to 1em of the surrounding text and takes its color.
Properties
All standard HTML button attributes are also supported and forwarded to the trigger button.
The URL of your published Fern Docs site (for example, https://docs.example.com). Include the full path if your docs aren’t at the root (for example, https://buildwithfern.com/learn).
Language code for the interface.
Icon element to display in the trigger button.
Trigger button content (text, icons, etc.).
inherit follows the host page’s theme (a dark class or data-theme="dark" on <html> or <body>) and switches live with it. light and dark pin the widget to that mode. auto follows the visitor’s prefers-color-scheme.
Accent color for the sparkles, send button, and links in answers. Accepts any CSS color (for example, #6b4eff), and derives the light and dark variants from it. Defaults to a neutral gray.
floating renders a styled launcher pinned to a corner of the viewport. inline renders an unpainted button to place and style yourself, such as in a nav bar. Both carry the sparkle icon and an Ask AI label by default. none renders no trigger at all, for driving the open state from your own UI.
Controls the open state instead of letting the widget own it. Wire onOpenChange back to your state when passing this prop.
The initial open state when uncontrolled. Ignored once open is passed.
Fires whenever the chat wants to open or close, from any source: the trigger, the close button, Escape, or cmd/ctrl + /. Called in both controlled and uncontrolled mode.
The corner the launcher and card anchor to.
Locale used for retrieval. Defaults to lang.