▦K2 Advanced GridsDeveloper Portal / 0.24
Documentation / Developer reference

Styling & themes

Adapt K2 Advanced Grids to the visual identity of your SmartForms without modifying the engine. This reference distinguishes host styling, shared CSS tokens, and module-specific configuration in Beta 1.0.

Styling architecture

The engine injects its own CSS for extension controls. Native K2 headers, cells, toolbar controls and themes remain owned by the host application. CSS custom properties used by the extension resolve from the surrounding DOM; if absent, the engine uses local fallback values. These fallbacks are not a complete K2 theme.

LayerResponsibility
K2 SmartForms themeNative grid and form appearance
Shared CSS tokensExtension surfaces, text, buttons and state colors
Module configurationBoolean colors, conditional rules, data visualization, merging and sizing
Internal --k2ag-* propertiesRuntime-generated geometry and rendering state; not a stable theme API

Shared CSS token reference

The following 31 tokens are referenced in the frozen engine. Multiple fallback values mean different controls use different defaults. A token only affects rules that reference it; it does not recolor the entire native K2 form.

CSS propertyPurposeFallback(s) in engine
--k2ux-grid-bgPinned base, menus and popups#f8fafc / #fff
--k2ux-grid-borderBorders across extension controls#cbd5df / #cbd5e1 / #d1d5db / #d5dce5 / #dbe2e9
--k2ux-grid-dividerDividers#e3e8ed
--k2ux-grid-header-bgGroup headers#e8edf3
--k2ux-grid-header-textGroup text and inactive icons#334155 / #526171 / #64748b
--k2ux-grid-hoverHover surface#eef3f8
--k2ux-grid-radiusSummary metric radius6px
--k2ux-grid-row-bgCard background#fff
--k2ux-grid-row-hoverRow/card hover and pinned overlay#c9ebf7 / #f5f8fa / rgba(100,116,139,.12)
--k2ux-grid-row-selectedSelection overlay, chips and active filter icons#00aeef / #e7f0fa
--k2ux-grid-row-textSummary, pager and filter panel text#243444
--k2ux-grid-shadowFilter panel shadow0 8px 30px #0003
--k2ux-grid-surfaceSticky header, summary and pager surfaces#fff
--k2ux-grid-textCard and menu text#243449 / #334155
--k2ux-successAutomatic positive Boolean color#26845b
--k2ux-dangerAutomatic negative Boolean color#b91c1c
--keds-font-familyExtension font familyArial,sans-serif
--keds-font-size-mdFilter panel font size14px
--keds-font-size-smSummary and pager font size13px
--keds-radius-lgFilter panel radius8px
--keds-radius-mdFilter button radius4px
--x-accentActive controls and automatic resize indicator#1765a5
--x-button-normal-bgNormal button background#fff
--x-button-normal-borderNormal button border#cbd5df
--x-button-normal-textNormal button text#234
--x-button-primary-bgApply button background#1765a5
--x-button-primary-textApply button text#fff
--x-dangerError text#ad2535
--x-input-bgFilter input background#fff
--x-input-borderFilter input border#bcc8d3
--x-input-textFilter input text#243444

Apply a custom palette

Place the following CSS in an application-owned stylesheet loaded by the SmartForm, or inject it through an approved custom styling mechanism. Do not modify the standard K2 theme files or the engine. The example uses :root so that overlays outside the grid also inherit the palette.

:root {
    --x-accent: #8439A6;
    --k2ux-grid-bg: #ffffff;
    --k2ux-grid-surface: #ffffff;
    --k2ux-grid-row-bg: #ffffff;
    --k2ux-grid-text: #334155;
    --k2ux-grid-row-text: #243444;
    --k2ux-grid-header-bg: #f3e8fa;
    --k2ux-grid-header-text: #51266b;
    --k2ux-grid-border: #d9cce2;
    --k2ux-grid-divider: #e8e0ee;
    --k2ux-grid-hover: #f6effa;
    --k2ux-grid-row-hover: #f6effa;
    --k2ux-grid-row-selected: #e8d6f3;
    --k2ux-success: #26845b;
    --k2ux-danger: #b91c1c;
    --x-button-normal-bg: #ffffff;
    --x-button-normal-border: #d9cce2;
    --x-button-normal-text: #334155;
    --x-button-primary-bg: #8439A6;
    --x-button-primary-text: #ffffff;
    --x-input-bg: #ffffff;
    --x-input-border: #d9cce2;
    --x-input-text: #243444;
    --x-danger: #b91c1c;
}

For a quick reversible Console test, use a dedicated style element. Remove it to restore the previous stylesheet cascade.

{
  const id = 'k2ag-theme-preview';
  let style = document.getElementById(id);
  if (!style) {
    style = document.createElement('style');
    style.id = id;
    document.head.append(style);
  }
  style.textContent = `:root { --x-accent: #8439A6; --x-button-primary-bg: #8439A6; --k2ux-grid-header-bg: #f3e8fa; --k2ux-grid-header-text: #51266b; }`;
  K2AdvancedGrids.instance.refresh();
}
// Undo:
// document.getElementById('k2ag-theme-preview')?.remove();
// K2AdvancedGrids.instance.refresh();

Light and dark themes

The engine does not provide its own application-wide theme switch. Integrate the token palette with your existing host theme. The example below assumes your application sets data-k2ag-theme on the HTML element; this is an example convention, not an engine configuration setting. Apply the light palette above first, then the dark override. The host must separately style native K2 controls.

html[data-k2ag-theme="dark"] {
    --x-accent: #c084fc;
    --k2ux-grid-bg: #20232b;
    --k2ux-grid-surface: #20232b;
    --k2ux-grid-row-bg: #272a34;
    --k2ux-grid-text: #e2e8f0;
    --k2ux-grid-row-text: #e2e8f0;
    --k2ux-grid-header-bg: #373044;
    --k2ux-grid-header-text: #e9d5ff;
    --k2ux-grid-border: #505363;
    --k2ux-grid-divider: #404450;
    --k2ux-grid-hover: #323640;
    --k2ux-grid-row-hover: #323640;
    --k2ux-grid-row-selected: #49395c;
    --k2ux-success: #86efac;
    --k2ux-danger: #fca5a5;
    --x-button-normal-bg: #272a34;
    --x-button-normal-border: #505363;
    --x-button-normal-text: #e2e8f0;
    --x-button-primary-bg: #713b96;
    --x-button-primary-text: #ffffff;
    --x-input-bg: #20232b;
    --x-input-border: #505363;
    --x-input-text: #e2e8f0;
    --x-danger: #fca5a5;
}
document.documentElement.dataset.k2agTheme = 'dark';
K2AdvancedGrids.instance.refresh();
// Restore light: delete document.documentElement.dataset.k2agTheme;

Illustrative palette comparison

These are static palette mockups, not screenshots or proof of dark-mode compatibility.

Light palette
Department · Procurement (32)
PO-2026-00001 · Apex Services
PO-2026-00009 · Gulf Technologies
Apply
Dark palette
Department · Procurement (32)
PO-2026-00001 · Apex Services
PO-2026-00009 · Gulf Technologies
Apply

Module-specific styling

Use configuration rather than CSS overrides when a module provides a styling option. Explicit colors may remain unchanged when the host theme switches. Review contrast in both themes.

ModuleConfiguration controlsRelated lesson
Boolean FormattingtrueColor, falseColor, iconSize, alignment; auto uses mode-specific defaultsLesson 8
Conditional FormattingRule style: background, color, fontWeight and badgeLesson 8
Data VisualizationpositiveColor, negativeColor, minColor, midColor, maxColor, opacityLesson 9
Cell Mergingbackground, borderColor, showGroupBorders, alignmentLesson 10
Column ResizeindicatorColor: auto reads --x-accent; indicatorWidthLesson 5
Card Viewlayout.gap, minCardWidth, maxCardWidth, densityLesson 13

Scope and overlay placement

CSS variables can be scoped to a form or a grid for local changes, but not all extension elements are descendants of that grid. The filter panel is appended to the nearest runtime-form or document.body. Use a shared ancestor for consistent overlay colors. Test multiple grids and popups before narrowing the scope.

KEDS integration boundary

The engine consumes KEDS-compatible token names and listens for the document event keds-theme-changed. In Beta 1.0 the listener calls the filter panel positioning function, not a complete theme rebuild. CSS inheritance updates ordinary token-based styling; refresh the engine if runtime-calculated geometry or colors need to be recomputed. This is an integration hook, not a claim of completed KEDS product integration.

document.dispatchEvent(new Event('keds-theme-changed'));
K2AdvancedGrids.instance.refresh();

Diagnostics

Replace the placeholder with your actual Area Item ID. Compare the computed token values on the grid and on an open filter panel. Empty values mean that the custom property is not defined at that element; the CSS rule may still use its fallback.

{
  const id = 'REPLACE_WITH_YOUR_AREAITEMID';
  const grid = Array.from(document.querySelectorAll('[data-areaitemid]'))
    .find(el => el.dataset.areaitemid === id);
  if (!grid) throw new Error('Grid not found');
  const panel = document.querySelector('.k2gf-panel');
  const tokens = ['--x-accent', '--k2ux-grid-bg', '--k2ux-grid-row-text', '--k2ux-grid-row-selected'];
  console.table(tokens.map(token => ({token,
    grid: getComputedStyle(grid).getPropertyValue(token).trim(),
    panel: panel ? getComputedStyle(panel).getPropertyValue(token).trim() : '(closed)'
  })));
}

Validation and limitations

  • Check normal, hover, selection and pinned states, including text contrast.
  • Check filtering, pagination, summary, cards, grouping and menus in both themes and RTL.
  • Pinned cells combine computed backgrounds and state overlays; do not override their internal positioning or stacking styles.
  • Fixed business-rule colors and native Excel export are not a live reflection of a CSS theme.
  • Do not rely on internal CSS class names or --k2ag-* variables as a guaranteed public API.
  • The palette examples are source-based recommendations; full dark-theme and KEDS integration regression testing has not been performed in this reference release.
Enlarged screenshot