Ui

From datagrok-ai/public · View interactive version

Ui is an AI agent skill from the GitHub repository datagrok-ai/public. UI building guidelines for Datagrok TypeScript components, viewers, and drag-and-drop

How to use this skill

Skill file

Datagrok UI Building Guidelines

Rules and patterns for building UI in TypeScript packages and libraries. These are

authoritative — follow them unless the user explicitly overrides.

Tab Controls

// Good
const tabs = ui.tabControl();
tabs.addPane('Sheet 1', () => {
  const df = buildDataFrame();
  const grid = DG.Viewer.grid(df);
  return grid.root;
});

// Bad — all tabs built eagerly
const tabs = ui.tabControl({
  'Sheet 1': buildExpensiveGrid(),
  'Sheet 2': buildExpensiveGrid(),
});

Grids and Viewers

Layouts

Dialogs and Inputs

Prefer onValueChanged in the options object over .onChanged.subscribe():

  ui.input.bool('Debug', {value: DG.Test.isInDebug, onValueChanged: (v) => DG.Test.isInDebug = v});

Use ui.form([...inputs]) to render a labeled list of inputs inside a dialog

which automatically appear in the context panel

Toggle Settings in Popup Menus

For toggleable settings in a DG.Menu.popup(), use menu.items() with isChecked — never use text-prefix hacks like ` ${flag ? '✓ ' : ''}Label `:

const toggles = [
  {label: 'Debug', get: () => DG.Test.isInDebug, set: (v: boolean) => { DG.Test.isInDebug = v; }},
  {label: 'Benchmark', get: () => DG.Test.isInBenchmark, set: (v: boolean) => { DG.Test.isInBenchmark = v; }},
];
const menu = DG.Menu.popup();
menu.closeOnClick = false;
const refresh = () => {
  menu.clear();
  menu.items(toggles, (t) => { t.set(!t.get()); refresh(); }, {isChecked: (t) => t.get()});
};
refresh();
menu.show();

Performance

Accordion

const acc = ui.accordion();
acc.addPane('Details', () => buildDetailsPanel());
acc.addPane('Statistics', () => buildStatsPanel());

Drag and Drop

Common Anti-Patterns

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.