Skip to Content
WidgetReferenceAttributes

Attributes Reference

Every option you can set on the <script> tag and its initKnokuWidget() equivalent. For the full visual override surface (per-slot, per-property), see Component Styles. For programmatic control, see Runtime API.

Only data-project-id is required. Invalid values for enums, hex colors, and data-language are dropped with a console warning and the default takes over.

Identity

Attributenpm optionTypeDefault
data-project-idprojectIdUUIDrequired

Behavior

Attributenpm optionTypeDefault
data-themethemeauto | light | darkauto
data-languagelanguageen, tr, de, es, fr, it, pt, nl, ja, ko, zh, ru, csbrowser-detected → en
data-layoutlayoutoverlay | pushoverlay
data-launcher-alignlauncherAlignbottom-right | bottom-leftbottom-right
data-launcher-hiddenlauncherHiddentrue | falsefalse
data-launcher-iconlauncherIconbuilt-in icon name (see Icons) or — npm only — raw SVG content starting with <book-open
data-open-selectoropenSelectorCSS selectornone

data-language controls built-in UI strings (placeholders, buttons, default consent copy). It does not translate data-greeting, data-suggested-questions, or your custom consent text; provide those in the language you want users to see. See Translate the widget.

data-layout="overlay" (default) floats the panel above the existing layout; data-layout="push" adds a right margin to the page body while open so the panel looks embedded next to your content. See Choose a panel layout.

Copy

Attributenpm optionTypeDefault
data-greetinggreetingtextnone (greeting hidden)
data-launcher-textlauncherTexttextNeed help?
data-launcher-subtitlelauncherSubtitletextAsk AI
data-suggested-questionssuggestedQuestionscomma-separated text, optional |icon-name per itemnone

data-greeting is hidden when the attribute is omitted. Set it to a value to show a centered greeting line above the chat (How can I help?, Hi there!, etc.).

data-suggested-questions accepts an optional |icon-name suffix per item to set a leading icon — e.g. Get started|rocket,Pricing|card,API|code. See the icon reference for the full list of built-in names. Suggestion items without | use the sparkle icon. For questions containing commas or |, or to pass custom SVG, use the npm path with the object form.

Attributenpm optionTypeDefault
data-consent-requiredconsent.requiredtrue | falsefalse
data-consent-titleconsent.titletexttranslated default for data-language
data-consent-disclaimerconsent.disclaimertexttranslated default for data-language
data-consent-accept-textconsent.acceptTexttexttranslated default for data-language
data-consent-reject-textconsent.rejectTexttexttranslated default for data-language

When required, window.Knoku.ask(question) opens the panel on the consent screen first; the question is held until the user accepts. See Require consent before chat.

Colors

Attributenpm optionTypeDefault
data-primary-colorprimaryColor#RRGGBBnone (sets light + dark)
data-primary-color-lightprimaryColorLight#RRGGBB#171717
data-primary-color-darkprimaryColorDark#RRGGBB#d4d4d4

The primary accent applies to the launcher, submit button, and focus states. For per-slot overrides (panel header, suggestion chips, hover states, dark variants), see Component Styles.

Component Styles

Per-slot, per-property visual overrides follow the pattern data-{slot}-{property} (with optional {state} and -dark suffix). Full slot list, allowed CSS properties, and examples live on the dedicated page: Component Styles.

Light and Dark Mode

data-theme="auto" (the default) detects dark mode from the host page in this order:

  1. <html class="dark">: Tailwind class-based dark mode, VitePress, Nextra, Mintlify
  2. <html data-theme="dark">: Docusaurus
  3. OS-level prefers-color-scheme: dark

Only <html> is checked, not <body>. Theme changes on the host are followed live without a remount.

data-theme="light" and data-theme="dark" force a mode regardless of host signals.

npm Path

Every attribute above maps to a property on the initKnokuWidget(options) argument. Component styles are passed as a nested componentStyles object (see the Component Styles npm equivalent).

import { initKnokuWidget } from '@knoku/widget' await initKnokuWidget({ projectId: 'YOUR_PROJECT_ID', theme: 'auto', language: 'en', layout: 'overlay', greeting: 'How can I help?', launcherText: 'Need help?', launcherSubtitle: 'Ask AI', launcherAlign: 'bottom-right', launcherHidden: false, openSelector: '#ask-ai', suggestedQuestions: [ { text: 'Get started', icon: 'rocket' }, { text: 'API reference', icon: 'code' }, { text: 'Pricing', icon: 'card' }, 'How does authentication work?', // string also accepted; defaults to sparkle icon ], primaryColorLight: '#171717', primaryColorDark: '#d4d4d4', launcherIcon: 'book-open', consent: { required: true, title: 'AI chat consent', disclaimer: 'Your question is sent to our AI to generate an answer.', acceptText: 'Continue', rejectText: 'Cancel', }, componentStyles: { 'panel-header': { 'background-color': '#ffffff' }, 'panel-header:dark': { 'background-color': '#020617' }, }, })
Last updated on