Style the chat widget with CSS

Every part, state and variable you can style in Deacon’s chat widget with your own CSS, and the six things to know before you write a look.

View as Markdown

You can restyle every part of Deacon, the AI customer support agent on your site, with your own CSS, in Appearance's CSS box. Deacon keeps every name, state and variable on this page, so a look written with them keeps working as the widget changes.

Six things to know

  • Use start and end, not left and right. Write margin-inline-start, padding-inline-end and text-align: start. Deacon answers a visitor who writes in Arabic or Hebrew in their language, and its answer and what they type run right to left. Text set with start and end turns round with them.
  • Use .is-phone, not a width query. A max-width media query reads the chat window's own width, which is 441px on a computer, so it matches there too. Deacon puts .is-phone on the widget when it lays the window out for a phone, so write .is-phone .starter-questions { … }. Appearance's Phone preview sets it too.
  • A rule on a launcher name styles the button on your page. Every other rule styles the chat window. A rule that names both is split between them.
  • What Deacon refuses, and why. Deacon reads your CSS on its own server before anything shows it, and keeps out anything that could fetch from another server or reach the rarer corners of a browser. So url(), @import, @font-face, image-set() and any function or at-rule not on its list are refused, and so are backslashes and pseudo-elements other than ::before, ::after, ::placeholder, ::marker and ::selection. Refusing them keeps a look from ever sending what a visitor types to another server. Appearance names a refused line with its number. Until it's fixed, your look stays in the draft, a preset you picked too: Publish puts your other changes live, such as new colours, and visitors keep the look they see now.
  • A part you recolour directly beats a colour setting, though the setting can't show it. Set a colour through its variable, such as --color-widget-accent on :root, and Appearance's colour row says the CSS sets it, with the line. Recolour a part itself, such as .send { background: … }, and the row keeps showing your saved colour while the CSS wins on screen.
  • Touch sizes show only on a real phone. Appearance's Phone preview is a phone's width and sets .is-phone, but rules under (pointer: coarse), and the 16px Deacon holds fields to on a touch screen, show only on a phone itself.

The rules Deacon keeps

  • Deacon keeps every name, state and variable here. It doesn't promise the structure around them: a rule like .ask-box > label or a bare :nth-child can break when the widget changes.
  • A plain rule on a name always wins over Deacon's own, with nothing extra to type, but for three things that stay Deacon's:
    • Under reduced motion, Deacon's rule ends every transition and animation at once, a look's too.
    • On a touch screen, fields stay at 16px or more, so a phone never zooms the page into one.
    • The sizes Deacon sets as the widget runs stay its own, such as the ask field growing with a question and the height the list of messages may take.
  • Every browser state works on every part: :hover, :focus-visible, :focus-within, :active, :disabled, ::placeholder and the rest.
  • To pick a part by its place, name it: .starter-question:nth-child(even of .starter-question).
  • Deacon uses ::after on starter questions and on small controls for a larger area to tap. Decorate with ::before.
  • Variables, and anything for the whole widget such as font-smoothing, go on :root.
  • A rule that names a launcher part styles the button on your page; every other rule styles the chat window.
  • On your site the window's and the bar's shadows show up to 64px beyond them. Anything else a look draws outside the window or the bar is cut off.

Parts

Each part is a class on the widget. Point at a part on Appearance's stage to see its name, and click it to add a rule for it.

NameWhat it is
.widgetThe chat window and the bar under it, together.
.windowThe chat window.
.drag-stripThe strip along the top of the window that it's dragged by. On your site the area that starts a drag is laid over the strip, whatever its size, and takes the pointer, so :hover and :active never fire on .drag-strip or .drag-dot; Deacon brightens the dots itself while the pointer is over them. Hide the strip and the window drags by .header instead.
.drag-dotEach of the three dots in the drag strip.
.headerA row under the drag strip with the team's logo, its name and its header line, and the bar's buttons for a look that wants them at the top. It and every part in it stay hidden until a look shows them: .header { display: flex }, then each part it wants. With the drag strip hidden, the window drags by the header, beside its buttons. On your site that area takes the pointer, so :hover never fires on the header's logo or words.
.header-logoThe team's logo, from Appearance's Copy room. A team with no logo has none.
.header-nameThe team's name: the company name in Appearance, never translated.
.header-taglineThe header line beside the name, "AI assistant" until the team writes its own in Appearance. It comes in the visitor's language.
.header-buttonsThe bar's buttons, in the header's row. A look shows these or the bar's, never both: show these and hide .dock.
.header-buttonAny button in the header's row.
.header-previousShow or hide earlier messages. It's also a .header-button.
.header-recentRecent chats. It's also a .header-button.
.header-unreadThe dot on Recent chats when a teammate's reply is waiting.
.header-new-chatNew chat. It's also a .header-button.
.header-backBack, from recent chats or a past chat. It's also a .header-button.
.header-closeClose. It's also a .header-button.
.transcriptThe list of messages, which scrolls. It runs from the bottom up, so its first child is the newest message. Set gap for the space between messages, and never flex-direction, which turns the chat upside down.
.messageAny message, whoever wrote it, including Deacon's typing and an answer that failed.
.from-visitorA message the visitor wrote. It's also a .message.
.from-deaconA message from Deacon. It's also a .message.
.from-teammateA message from someone on your team. It's also a .message.
.greetingThe first message, which tells the visitor they're talking to an AI. It's also a .message.from-deacon. Deacon keeps it in view whatever a look writes, so only its font, colour, size, ground, alignment and spacing change. Set the size of its words on .greeting itself: they take it, at 12px at least. A look's letter-spacing goes no tighter than -0.05em, anywhere.
.message-textA message's words, without its files: where a bubble goes.
.markDeacon's hexagon at the start of its messages.
.mark-logoThe team's logo, just before Deacon's mark. Show it and hide the mark with .mark-logo + .mark { display: none }, and a team with no logo keeps the mark.
.teammate-nameThe teammate's name over their message.
.sent-signThe tick after the visitor's latest message while someone on your team holds the chat: it has reached them.
.linkA link in a message's words, and the team's address in the email line.
.listA bulleted or numbered list in a message.
.sourceThe page an answer came from, under the answer.
.filesA message's files: its pictures in one block, its other files in another.
.pictureA picture in a message.
.file-chipA file that isn't a picture, in a message or waiting to be sent.
.typing-dotsThe dots while Deacon writes an answer.
.ended-lineThe line saying the chat has ended.
.email-cardThe offer under an answer Deacon couldn't give: the team follows up by email.
.email-askIts question, "Want the team to follow up?"
.email-fieldThe box for the visitor's email.
.email-buttonThe button that sends it.
.email-directThe line with the team's own address: "or email … directly".
.email-linkThe team's address in that line. It's also a .link.
.starter-questionsThe row of starter questions.
.starter-questionOne starter question.
.file-trayThe files waiting to be sent, above the ask box.
.ask-boxWhere the visitor types: the field, the paperclip and send, side by side. The three are items of its own layout, so order moves one, and its padding places them all.
.ask-fieldThe field the visitor types in.
.paperclipThe button that adds a file.
.sendThe send button.
.iconThe icon inside a control: send, the paperclip, the bar's buttons, the email button, Start a new chat, the source's arrow, a file's download button and the picture viewer's buttons.
.recent-chatsThe visitor's recent chats: the title, the list and its button.
.recent-chatOne chat in that list.
.start-new-chatThe "Start a new chat" button, under recent chats and under a past chat.
.picture-viewerA picture opened full size over the page.
.dockThe bar under the window that holds close, new chat and the rest. Its shape stays a pill on your site for now: Deacon cuts the bar to one there, whatever its corner.
.dock-buttonAny button in the bar.
.dock-previousShow or hide earlier messages. It's also a .dock-button.
.dock-recentRecent chats. It's also a .dock-button.
.dock-unreadThe dot on Recent chats when a teammate's reply is waiting.
.dock-new-chatNew chat. It's also a .dock-button.
.dock-backBack, from recent chats or a past chat. It's also a .dock-button.
.dock-closeClose. It's also a .dock-button.
.launcherThe button on your page that opens the chat. Until the launcher takes your CSS as the window does, Deacon's own hover and focus on it win, and its icon keeps the launcher's colours.
.launcher-iconIts icon.
.launcher-logoThe team's logo, just before the icon, hidden until a look shows it. Show it and hide the icon with .launcher:has(.launcher-logo) .launcher-icon { display: none }, and a team with no logo keeps the icon. Hide both for words alone.
.launcher-labelIts words.
.launcher-badgeThe count of unread replies on its corner.

States

NameWhat it means
.is-phoneThe widget is laid out for a phone, across the foot of the screen. Use it where you'd reach for a max-width media query, which reads the window's own width (441px on a computer). Write it before a part: .is-phone .starter-questions. Deacon sets it with the first size it sends the window as it opens, and Appearance's Phone preview sets it too. The launcher doesn't see it: for the launcher on a phone, use @media (max-width: 640px).
.is-freshNothing has been asked yet in the chat on screen. Write it before a part: .is-fresh .greeting.

Variables

Set these on :root.

NameDeacon's ownWhat it sets
--color-widget-accent#266eebThe team's accent: the email button, Start a new chat, unread dots, "Now" and selected words. By default, links and the focus ring too.
--color-widget-send#2978ffThe send button's colour. Once Appearance has an accent, send follows --color-widget-accent unless its own colour is set there too. Before that it's Deacon's own blue, so a look that changes the accent should set this as well.
--color-widget-accent-fg#ffffffIcons and words on the accent: ink or white, whichever reads better on it. A browser without relative colours keeps white.
--color-widget-send-fgvar(--color-widget-accent-fg)The send button's icon: the accent's pick while send follows the accent, and ink or white, whichever reads better on send, once Appearance sets send apart. A look that sets --color-widget-send apart from the accent can set this too.
--color-widget-surface#ffffffThe window and the bar, starter questions, the email field and file chips.
--color-widget-surface-2#f7f7f7What a starter question, a bar button or a recent chat turns under the pointer, and the ground behind code. On a window too dark for Deacon's near-black icons, a lift of the window's own colour instead.
--color-widget-text#161616Deacon's words.
--color-widget-visitor-textrgba(22, 22, 22, 0.6)The visitor's words.
--color-widget-teammate-textvar(--color-widget-text)A teammate's words.
--color-widget-muted#767676Quiet words and icons: the email question, a teammate's name, the ended line, the source, the paperclip and the typing dots.
--color-widget-linkvar(--color-widget-accent)Links in messages, and the team's address in the email line.
--color-widget-focusvar(--color-widget-accent)The ring round whatever a keyboard has reached. Deacon's words' colour when the accent is too faint on the window.
--color-widget-input-text#161616What the visitor types.
--color-widget-placeholderrgba(0, 0, 0, 0.57)The words in an empty field, the ask field's and the email field's.
--color-widget-border#edededThe edges of the window, the bar, starter questions and the source, and the line above waiting files.
--color-widget-border-strong#949494The edge of the email field and of Try again.
--color-widget-file-groundcolor-mix(in srgb, var(--color-widget-text) 6%, var(--color-widget-surface))Behind a picture while it loads, and behind a file's kind.
--color-widget-danger#b04030The line saying an email didn't send.
--color-widget-danger-inkcolor-mix(in oklab, #d13b3b 90%, var(--color-widget-text))The line saying a file can't be sent.
--color-widget-dock-icon-strong#161616The drag dots, and the bar's icons under the pointer. Deacon's words' colour on a window too dark for it.
--color-widget-dock-iconcolor-mix(in srgb, var(--color-widget-dock-icon-strong) 50%, var(--color-widget-surface))The bar's icons at rest.
--color-widget-ask-boxtransparentThe ask box's background.
--color-widget-ask-box-bordertransparentA 1px edge drawn just inside the ask box, so nothing moves when it shows.
--font-widgetui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'The widget's font. The launcher doesn't follow it yet: give .launcher a font-family of its own.
--text-widget-message1remThe size of the words in messages. The email card follows it.
--radius-widget20pxThe window's corner.
--radius-widget-control9999pxThe corner of every control: starter questions, send, the paperclip, the email field and button, the source, the bar's buttons, Start a new chat, Try again and file chips. Each takes the smaller of this and its own corner, so 6px squares them all.
--radius-widget-ask-box0pxThe ask box's corner.
--spacing-widget-insetclamp(20px, calc(var(--radius-widget) - 4px), 48px)How far the words sit from the window's sides.
--width-widget417pxThe window's width on a computer. On a phone the window spans the screen. Set it on :root in px: Deacon reads the number and keeps the window on the screen.
--spacing-widget-from-side16pxHow far the window and the bar sit from the side of the screen they're on. Set it on :root in px, as for --width-widget.
--spacing-widget-from-bottom16pxHow far the window and the bar sit from the foot of the screen. Set it on :root in px, as for --width-widget.
--shadow-widget-window0 1px 2px rgb(22 22 22 / 0.06), 0 6px 16px rgb(22 22 22 / 0.09)The window's shadow.
--shadow-widget-dock0 1px 2px rgb(22 22 22 / 0.06)The shadow under the bar.
--shadow-widget-starter-question0 1px 2px rgb(22 22 22 / 0.06)The shadow under a starter question.
--shadow-widget-start-new-chat0 1px 2px rgb(22 22 22 / 0.14), 0 3px 8px rgb(22 22 22 / 0.1)The shadow under Start a new chat.
--color-launcherThe launcher's colour, set from the Help button's colour in Appearance. A look can set it on .launcher to recolour the launcher. The focus ring stays Deacon's own.
--color-launcher-fgThe launcher's words and icon, set from Appearance. A look can set it on .launcher to recolour both.