Skip to Content
WidgetReferenceComponent Styles

Component Styles

The widget is composed of named slots: launcher, panel header, message bubbles, suggestion chips, and so on. Each slot can be styled independently with data-* attributes on the script tag.

For brand color and dark/light mode setup, see Match your brand. Component styles always take precedence over the default theme.

How It Works

Concatenate the data- prefix with the component’s slot name and the CSS property:

data-{slot}-{property}="value"

Example. Give the panel header a dark background and light text:

<script async src="https://cdn.knoku.com/widget.js" data-project-id="YOUR_PROJECT_ID" data-panel-header-background-color="#1a1a2e" data-panel-header-color="#ffffff" ></script>

Each attribute targets exactly one CSS property on one slot. Add as many as you need.

Available Components

SlotAttribute NameDescription
PanelpanelThe chat panel container
Panel Headerpanel-headerTop bar of the panel
Panel Bodypanel-bodyMessage scroll area
Panel Footerpanel-footerBottom area below messages
LauncherlauncherFloating launcher button (outer positioning)
Bottom Barbottom-barLauncher card (visible background, border, shadow)
Launcher Marklauncher-markIcon container on the left of the launcher
Launcher Textlauncher-textLauncher label text (Need help? by default)
Launcher Subtitlelauncher-subtitleLauncher second line (Ask AI by default)
Launcher Sendlauncher-sendArrow button on the right of the launcher
Submit Buttonsubmit-buttonSend button inside the panel composer
User Bubbleuser-bubbleUser’s question bubble
Assistant Answerassistant-answerAssistant’s answer block
GreetinggreetingEmpty-state greeting line
Suggestion Chipsuggestion-chipStarter question chip
Source Chipsource-chipCitation chip on assistant answers
DisclaimerdisclaimerChat disclaimer line
Consent Screenconsent-screenConsent screen container
Consent Accept Buttonconsent-accept-buttonConsent accept button
Consent Reject Buttonconsent-reject-buttonConsent reject button
Feedback Thumb Upfeedback-up👍 button selected color (default green)
Feedback Thumb Downfeedback-down👎 button selected color (default red)

The Knoku branding footer is plan-controlled and not customizable.

feedback-up / feedback-down are special: overrides apply to the selected state only. The unselected thumbs stay in the generic placeholder color. Defaults are green / red because they’re universal “good / bad” signals; override them to a single brand color (e.g. primary) when you want a uniform look.

Supported CSS Properties

The following CSS properties can be applied to any slot. All are optional; defaults come from the widget’s built-in theme.

PropertyNotes
background-color
borderShorthand: 1px solid #e5e7eb
border-bottom
border-color
border-radius
colorText color
font-family
font-size
font-weight
opacity0 to 1
height, width
min-height, max-height, min-width, max-width
paddingShorthand
padding-top, padding-bottom, padding-left, padding-right
padding-x, padding-yHorizontal / vertical padding shortcuts
margin-top, margin-bottom, margin-left, margin-right
margin-x, margin-yHorizontal / vertical margin shortcuts
flex-direction, justify-content
top, left, right, bottom
box-shadow, text-shadow
z-index

Properties not in this list are dropped silently.

padding-x expands to padding-left and padding-right; padding-y expands to padding-top and padding-bottom. margin-x and margin-y work the same way for horizontal and vertical margins.

Pseudo-State Variants

To style a hover, focus, or active state, insert the state between the slot name and the property:

data-{slot}-{state}-{property}="value"
PrefixCSS StateExample
hover:hoverdata-launcher-hover-background-color
focus:focusdata-submit-button-focus-border-color
active:activedata-suggestion-chip-active-background-color
<script async src="https://cdn.knoku.com/widget.js" data-project-id="YOUR_PROJECT_ID" data-launcher-background-color="#6366f1" data-launcher-hover-background-color="#4f46e5" data-suggestion-chip-active-background-color="#eef2ff" ></script>

Dark Mode Variants

Append -dark to any component-style attribute to apply it only when the widget is in dark mode:

data-{slot}-{property}-dark="value" data-{slot}-{state}-{property}-dark="value"

Without -dark, a value applies in both modes. With -dark, it overrides only in dark mode.

<script async src="https://cdn.knoku.com/widget.js" data-project-id="YOUR_PROJECT_ID" data-panel-header-background-color="#f9fafb" data-panel-header-background-color-dark="#0f172a" data-panel-header-color="#111827" data-panel-header-color-dark="#f1f5f9" ></script>

The widget detects dark mode automatically from the host page (<html class="dark">, <html data-theme="dark">, or prefers-color-scheme). See Light and Dark Mode in the attributes reference.

Examples

Custom launcher with brand colors

<script async src="https://cdn.knoku.com/widget.js" data-project-id="YOUR_PROJECT_ID" data-launcher-background-color="#0ea5e9" data-launcher-hover-background-color="#0284c7" data-launcher-text-color="#ffffff" data-launcher-text-font-weight="600" ></script>

Tighter suggestion chips

<script async src="https://cdn.knoku.com/widget.js" data-project-id="YOUR_PROJECT_ID" data-suggestion-chip-border-radius="6px" data-suggestion-chip-padding-x="10px" data-suggestion-chip-padding-y="6px" data-suggestion-chip-font-size="13px" ></script>

Distinct dark-mode panel header

<script async src="https://cdn.knoku.com/widget.js" data-project-id="YOUR_PROJECT_ID" data-panel-header-background-color="#ffffff" data-panel-header-background-color-dark="#020617" data-panel-header-border-bottom="1px solid #e5e7eb" data-panel-header-border-bottom-dark="1px solid #1e293b" ></script>

Uniform feedback thumbs in brand color

<script async src="https://cdn.knoku.com/widget.js" data-project-id="YOUR_PROJECT_ID" data-feedback-up-color="#6366f1" data-feedback-down-color="#6366f1" data-feedback-up-color-dark="#818cf8" data-feedback-down-color-dark="#818cf8" ></script>

npm Equivalent

When mounting via npm, pass componentStyles as a nested object. Keys follow the same slot / slot:state / slot:dark / slot:state:dark convention:

import { initKnokuWidget } from '@knoku/widget' await initKnokuWidget({ projectId: 'YOUR_PROJECT_ID', componentStyles: { 'panel-header': { 'background-color': '#ffffff', 'border-bottom': '1px solid #e5e7eb', }, 'panel-header:dark': { 'background-color': '#020617', }, 'launcher': { 'background-color': '#0ea5e9', }, 'launcher:hover': { 'background-color': '#0284c7', }, }, })
Last updated on