# 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.

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.

| Name | What it is |
|---|---|
| `.widget` | The chat window and the bar under it, together. |
| `.window` | The chat window. |
| `.drag-strip` | The 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-dot` | Each of the three dots in the drag strip. |
| `.header` | A 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-logo` | The team's logo, from Appearance's Copy room. A team with no logo has none. |
| `.header-name` | The team's name: the company name in Appearance, never translated. |
| `.header-tagline` | The header line beside the name, "AI assistant" until the team writes its own in Appearance. It comes in the visitor's language. |
| `.header-buttons` | The bar's buttons, in the header's row. A look shows these or the bar's, never both: show these and hide `.dock`. |
| `.header-button` | Any button in the header's row. |
| `.header-previous` | Show or hide earlier messages. It's also a `.header-button`. |
| `.header-recent` | Recent chats. It's also a `.header-button`. |
| `.header-unread` | The dot on Recent chats when a teammate's reply is waiting. |
| `.header-new-chat` | New chat. It's also a `.header-button`. |
| `.header-back` | Back, from recent chats or a past chat. It's also a `.header-button`. |
| `.header-close` | Close. It's also a `.header-button`. |
| `.transcript` | The 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. |
| `.message` | Any message, whoever wrote it, including Deacon's typing and an answer that failed. |
| `.from-visitor` | A message the visitor wrote. It's also a `.message`. |
| `.from-deacon` | A message from Deacon. It's also a `.message`. |
| `.from-teammate` | A message from someone on your team. It's also a `.message`. |
| `.greeting` | The 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-text` | A message's words, without its files: where a bubble goes. |
| `.mark` | Deacon's hexagon at the start of its messages. |
| `.mark-logo` | The 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-name` | The teammate's name over their message. |
| `.sent-sign` | The tick after the visitor's latest message while someone on your team holds the chat: it has reached them. |
| `.link` | A link in a message's words, and the team's address in the email line. |
| `.list` | A bulleted or numbered list in a message. |
| `.source` | The page an answer came from, under the answer. |
| `.files` | A message's files: its pictures in one block, its other files in another. |
| `.picture` | A picture in a message. |
| `.file-chip` | A file that isn't a picture, in a message or waiting to be sent. |
| `.typing-dots` | The dots while Deacon writes an answer. |
| `.ended-line` | The line saying the chat has ended. |
| `.email-card` | The offer under an answer Deacon couldn't give: the team follows up by email. |
| `.email-ask` | Its question, "Want the team to follow up?" |
| `.email-field` | The box for the visitor's email. |
| `.email-button` | The button that sends it. |
| `.email-direct` | The line with the team's own address: "or email … directly". |
| `.email-link` | The team's address in that line. It's also a `.link`. |
| `.starter-questions` | The row of starter questions. |
| `.starter-question` | One starter question. |
| `.file-tray` | The files waiting to be sent, above the ask box. |
| `.ask-box` | Where 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-field` | The field the visitor types in. |
| `.paperclip` | The button that adds a file. |
| `.send` | The send button. |
| `.icon` | The 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-chats` | The visitor's recent chats: the title, the list and its button. |
| `.recent-chat` | One chat in that list. |
| `.start-new-chat` | The "Start a new chat" button, under recent chats and under a past chat. |
| `.picture-viewer` | A picture opened full size over the page. |
| `.dock` | The 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-button` | Any button in the bar. |
| `.dock-previous` | Show or hide earlier messages. It's also a `.dock-button`. |
| `.dock-recent` | Recent chats. It's also a `.dock-button`. |
| `.dock-unread` | The dot on Recent chats when a teammate's reply is waiting. |
| `.dock-new-chat` | New chat. It's also a `.dock-button`. |
| `.dock-back` | Back, from recent chats or a past chat. It's also a `.dock-button`. |
| `.dock-close` | Close. It's also a `.dock-button`. |
| `.launcher` | The 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-icon` | Its icon. |
| `.launcher-logo` | The 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-label` | Its words. |
| `.launcher-badge` | The count of unread replies on its corner. |

## States

| Name | What it means |
|---|---|
| `.is-phone` | The 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-fresh` | Nothing has been asked yet in the chat on screen. Write it before a part: `.is-fresh .greeting`. |

## Variables

Set these on `:root`.

| Name | Deacon's own | What it sets |
|---|---|---|
| `--color-widget-accent` | `#266eeb` | The 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` | `#2978ff` | The 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` | `#ffffff` | Icons and words on the accent: ink or white, whichever reads better on it. A browser without relative colours keeps white. |
| `--color-widget-send-fg` | `var(--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` | `#ffffff` | The window and the bar, starter questions, the email field and file chips. |
| `--color-widget-surface-2` | `#f7f7f7` | What 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` | `#161616` | Deacon's words. |
| `--color-widget-visitor-text` | `rgba(22, 22, 22, 0.6)` | The visitor's words. |
| `--color-widget-teammate-text` | `var(--color-widget-text)` | A teammate's words. |
| `--color-widget-muted` | `#767676` | Quiet words and icons: the email question, a teammate's name, the ended line, the source, the paperclip and the typing dots. |
| `--color-widget-link` | `var(--color-widget-accent)` | Links in messages, and the team's address in the email line. |
| `--color-widget-focus` | `var(--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` | `#161616` | What the visitor types. |
| `--color-widget-placeholder` | `rgba(0, 0, 0, 0.57)` | The words in an empty field, the ask field's and the email field's. |
| `--color-widget-border` | `#ededed` | The edges of the window, the bar, starter questions and the source, and the line above waiting files. |
| `--color-widget-border-strong` | `#949494` | The edge of the email field and of Try again. |
| `--color-widget-file-ground` | `color-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` | `#b04030` | The line saying an email didn't send. |
| `--color-widget-danger-ink` | `color-mix(in oklab, #d13b3b 90%, var(--color-widget-text))` | The line saying a file can't be sent. |
| `--color-widget-dock-icon-strong` | `#161616` | The drag dots, and the bar's icons under the pointer. Deacon's words' colour on a window too dark for it. |
| `--color-widget-dock-icon` | `color-mix(in srgb, var(--color-widget-dock-icon-strong) 50%, var(--color-widget-surface))` | The bar's icons at rest. |
| `--color-widget-ask-box` | `transparent` | The ask box's background. |
| `--color-widget-ask-box-border` | `transparent` | A 1px edge drawn just inside the ask box, so nothing moves when it shows. |
| `--font-widget` | `ui-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-message` | `1rem` | The size of the words in messages. The email card follows it. |
| `--radius-widget` | `20px` | The window's corner. |
| `--radius-widget-control` | `9999px` | The 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-box` | `0px` | The ask box's corner. |
| `--spacing-widget-inset` | `clamp(20px, calc(var(--radius-widget) - 4px), 48px)` | How far the words sit from the window's sides. |
| `--width-widget` | `417px` | The 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-side` | `16px` | How 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-bottom` | `16px` | How 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-window` | `0 1px 2px rgb(22 22 22 / 0.06), 0 6px 16px rgb(22 22 22 / 0.09)` | The window's shadow. |
| `--shadow-widget-dock` | `0 1px 2px rgb(22 22 22 / 0.06)` | The shadow under the bar. |
| `--shadow-widget-starter-question` | `0 1px 2px rgb(22 22 22 / 0.06)` | The shadow under a starter question. |
| `--shadow-widget-start-new-chat` | `0 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-launcher` |  | The 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-fg` |  | The launcher's words and icon, set from Appearance. A look can set it on `.launcher` to recolour both. |
