1.138.1
Changed 1 entries
- Focus ring of line and text tabs
> Built as 1.136.0 on the branch tabelle/sortierung-merken; numbered 1.138.0 once the Heatmap (1.137.0) had reached main.
GK.sortMemorySortLink list have no id of their own; they are told apart by their…SortLink writes data-gk-sort-param and data-gk-dir-param on the link — only when…gk-sort-<id>; the sorts saved…GridKit\Heatmap is rows × columns with the colour as the value — weekdays by hours, pages by days — a real table with five steps taken from the design tokens, every cell spoken in words, and cells with no data or too little data marked…
GridKit\Heatmapgk-heat gk-heat-cell gk-heat-colhead gk-heat-count gk-heat-empty gk-heat-end +14Examples: Heatmap
newButton() could only open a modal (a "New invoice" that is a…Added 4 .gk-video-frame has been 9:16 only: the SSI Panel put a 16:9 video (its approval dialog "Video freigeben", a recording of a survival day) into a narrow portrait box with black bars on both sides (Martin…Added 3 TableHeader is seen at a glance.Changed 2 GridKit\FileManager is a media library and a receipt drawer — folders, thumbnails or a list, many files uploaded at once with a progress bar each, chosen, dropped or pasted — and FileManager::receive() checks every upload on the server…Added 7 Changed 2 The "VAT" header has a help icon, and the delete button a tooltip of its own instead of the browser's title since 0.9. Two articles are on invoices: their delete is locked with the reason ('lockedIf', 1.128.0), and Back after a search shows the list as it was left. The PDF symbol is one of the 40 row-action symbols that are SVG since 1.129.0; the buttons rest grey at full strength and take their colour on hover. The toolbar ends with a side button (toolbarButton()) and the main button, which is a link here (newButton() with 'href', 1.134.0).
| Unit | Net | VAT | Status | Actions | ||
|---|---|---|---|---|---|---|
| ART-001 | Web Design Package S | flat | €1,200.00 | 20 % | active | |
| ART-002 | Hosting Standard | pcs | €9.90 | 20 % | active | |
| ART-003 | SEO Consulting | h | €95.00 | 20 % | inactive | |
| ART-004 | Logo Design | flat | €450.00 | 20 % | draft | |
| ART-005 | Newsletter Setup | flat | €350.00 | 20 % | active |
$table = new Table('articles');
$table->setData($articles)
->search(['article_number', 'name'])
->column('article_number', 'Article No.', ['width' => '120px', 'sortable' => true, 'nowrap' => true, 'muted' => true])
->column('name', 'Description', ['sortable' => true, 'nowrap' => true])
->column('unit', 'Unit', ['width' => '80px', 'nowrap' => true])
->column('net_price', 'Net', ['format' => 'currency', 'align' => 'right', 'width' => '100px', 'nowrap' => true])
->column('tax_rate', 'VAT', ['format' => 'percent', 'width' => '80px', 'nowrap' => true,
'tooltip' => 'The rate the net price is taxed at'])
->column('is_active', 'Status', ['format' => 'label', 'nowrap' => true])
->filter('is_active', 'select', ['options' => ['active' => 'Active', 'inactive' => 'Inactive', 'draft' => 'Draft'], 'placeholder' => 'All Status'])
->button('edit', ['icon' => 'edit', 'class' => 'primary', 'position' => 'right', 'params' => ['id' => 'article_id']])
->button('pdf', ['icon' => 'picture_as_pdf', 'class' => 'secondary', 'position' => 'right', 'params' => ['id' => 'article_id'], 'title' => 'PDF'])
->button('delete', ['icon' => 'delete', 'class' => 'danger', 'position' => 'right', 'params' => ['id' => 'article_id'],
'tooltip' => ['text' => 'Deletes the article', 'tone' => 'danger'], 'lockedIf' => 'in_use'])
// The right of the toolbar (1.134.0): a side button, then the main button — here a link
// ('href'; a modal or 'id'/'data' for your own script work too).
->toolbarButton('Import', ['icon' => 'upload'])
->newButton('New Article', ['icon' => 'add', 'href' => '#'])
->nowrap(true)
// A box of its own where the content is narrower than the table
// (a 900px window beside the sidebar); the page no longer scrolls sideways.
->stickyColumn()
->paginate(5)
->render();| Actions | Due | Status | Actions | ||||
|---|---|---|---|---|---|---|---|
| RE-2026-001 | Mustermann GmbH | €1,450.00 | paid | ||||
| RE-2026-002 | Tech Solutions AG | €3,200.00 | pending | ||||
| RE-2026-003 | Weber & Partner | €890.50 | overdue | ||||
| RE-2026-004 | Digital Agentur Wien | €5,600.00 | draft | ||||
| RE-2026-005 | Startup Hub Vienna | €2,100.00 | paid |
| Role | Active | ||
|---|---|---|---|
| Martin Huber | [email protected] | admin | ✓ |
| Anna Schneider | [email protected] | editor | ✓ |
| Thomas Berger | [email protected] | viewer | – |
| Lisa Wagner | [email protected] | editor | ✓ |
| Peter Gruber | [email protected] | admin | – |
List table since 1.92 · column priority since 1.92 · who cell since 1.92
Read in the row, change in the sheet: a click anywhere on a row opens its record beside the list — full screen on a phone. One name cell with two lines, groups instead of a status label per row, and colour only for what needs acting on. The six rules behind it are in the agent skill. size('list') sets the row they describe, and 'priority' lets columns give way by the list's own width — open the sheet or narrow the window and watch "Last seen" go first.
| User | Plan | Last seen | Last 30 days |
|---|---|---|---|
| With access3 | |||
| Pro | 2 min ago | 20 failing | |
| Team | just now | 17 failing | |
| Free | today | — | |
| Without access2 | |||
| Team | never | — | |
| Free | never | — | |
// Rule 4: colour only where something needs acting on — a count that
// is fine stays plain text.
foreach ($people as &$p) {
$p['failing_html'] = $p['failing'] > 0
? '<span class="gk-label gk-label-red">' . (int) $p['failing'] . ' failing</span>'
: '—';
}
unset($p);
(new Table('demo-people'))
->setData($people)
->caption('Users')
->size('list')
->groupBy('access', ['with' => 'With access', 'without' => 'Without access'])
->rowLink(['sheet' => 'demo-person-sheet', 'url' => 'form/f_person_sheet.php'])
->column('name', 'User', ['sub' => 'email'])
->column('plan', 'Plan', ['priority' => 3])
->column('seen', 'Last seen', ['muted' => true, 'priority' => 4])
->column('failing_html', 'Last 30 days', ['format' => 'html', 'priority' => 2])
->toolbar(false)
->render();What is rarely needed folds into one row. The toggle shows and hides the rows its aria-controls names; the chevron and aria-expanded carry the state, so the label never has to change.
| User | Plan |
|---|---|
| Anna Schneider | Pro |
| Thomas Berger | Team |
| Profile: Berlin, 1984 | — |
| Profile: Graz, 1991 | — |
| Profile: Linz, 2002 | — |
echo <<<'HTML'
<div class="gk-table-wrap gk-table-mobile-card">
<table class="gk-table">
<caption class="gk-sr-only">Users and chart profiles</caption>
<thead><tr><th scope="col">User</th><th scope="col">Plan</th></tr></thead>
<tbody>
<tr><td data-label="User">Anna Schneider</td><td data-label="Plan">Pro</td></tr>
<tr><td data-label="User">Thomas Berger</td><td data-label="Plan">Team</td></tr>
<tr class="gk-table-more"><td colspan="2">
<button type="button" class="gk-table-more-toggle" aria-expanded="false" aria-controls="demo-profiles">
<span class="gk-table-more-name">3 chart profiles</span>
<span class="gk-cell-sub">Created from charts — they cannot sign in and have no plan.</span>
</button>
</td></tr>
</tbody>
<tbody id="demo-profiles" hidden>
<tr><td data-label="User">Profile: Berlin, 1984</td><td data-label="Plan">—</td></tr>
<tr><td data-label="User">Profile: Graz, 1991</td><td data-label="Plan">—</td></tr>
<tr><td data-label="User">Profile: Linz, 2002</td><td data-label="Plan">—</td></tr>
</tbody>
</table>
</div>
HTML;| Name | Value | Status |
|---|---|---|
| Widget A | 1.200 € | active |
| Widget B | 340 € | inactive |
| Widget C | 890 € | active |
| Name | Value | Status |
|---|---|---|
| Widget A | 1.200 € | active |
| Widget B | 340 € | inactive |
| Widget C | 890 € | active |
| Name | Value | Status |
|---|---|---|
| Widget A | 1.200 € | active |
| Widget B | 340 € | inactive |
| Widget C | 890 € | active |
$table->size('sm'); // compact
$table->size('md'); // standard (default)
$table->size('lg'); // spacious| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
| Description | Price | Status |
|---|---|---|
| Web Design Package | 1.200 € | active |
| Hosting Standard | 9,90 € | active |
| SEO Consulting | 95 € | inactive |
| Logo Design | 450 € | draft |
First column as label/key — ideal for detail views.
| Company name | SSI Schaefer IT Solutions GmbH |
| Founded | 2003 |
| Location | Wien, Oesterreich |
| Employees | 24 |
| Website | ssi.at |
| Status | Active |
$table->variant('default'); // Default
$table->variant('bordered'); // Full border lines
$table->variant('striped'); // Zebra stripes
$table->variant('celled'); // Grid lines around each cell
$table->variant('padded'); // Extra spacing
$table->variant('compact'); // Compact, more rows
$table->variant('selectable'); // Hover cursor, clickable
$table->variant('minimal'); // Only separator, no border
$table->variant('flat'); // Completely flat
$table->variant('inverted'); // Dark table (also in Light Mode)
// A variant is one slot: a second call REPLACES the first, it does not add.
$table->variant('celled')->variant('padded'); // celled is dropped — padded wins
// Variant and size are separate slots, so those two do stack:
$table->variant('striped')->size('sm');stickyHead() keeps the header row in view while the rows scroll under it — on the page, or in a box as high as you say ('320px' here). stickyColumn() keeps the first column in view while the table scrolls sideways, with the checkbox in front of it. Scroll the box both ways. On a phone a table in card mode stays as it is.
| Article No. | Unit | VAT | Gross | Stock | Supplier | Status | Actions | |||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Design Package S | ART-001 | flat | €1,200.00 | 20 % | €1,440.00 | 7 | Supplier A | active | ||
| Hosting Standard | ART-002 | pcs | €9.90 | 20 % | €11.88 | 14 | Supplier B | active | ||
| SEO Consulting | ART-003 | h | €95.00 | 20 % | €114.00 | 21 | Supplier C | inactive | ||
| Logo Design | ART-004 | flat | €450.00 | 20 % | €540.00 | 28 | Supplier D | draft | ||
| Newsletter Setup | ART-005 | flat | €350.00 | 20 % | €420.00 | 35 | Supplier E | active | ||
| Social Media Package | ART-006 | flat | €680.00 | 20 % | €816.00 | 42 | Supplier F | active | ||
| Email Marketing | ART-007 | flat | €420.00 | 20 % | €504.00 | 49 | Supplier G | draft | ||
| Content Creation | ART-008 | h | €75.00 | 20 % | €90.00 | 56 | Supplier H | active | ||
| Server Administration | ART-009 | h | €110.00 | 20 % | €132.00 | 63 | Supplier I | inactive | ||
| SSL Certificate | ART-010 | pcs | €49.00 | 20 % | €58.80 | 70 | Supplier J | active | ||
| Domain Registration | ART-011 | pcs | €15.00 | 20 % | €18.00 | 77 | Supplier K | active | ||
| Web Design Package L | ART-012 | flat | €3,500.00 | 20 % | €4,200.00 | 84 | Supplier L | active | ||
| App Development | ART-013 | h | €125.00 | 20 % | €150.00 | 91 | Supplier M | draft | ||
| Database Migration | ART-014 | flat | €890.00 | 20 % | €1,068.00 | 98 | Supplier N | active | ||
| Security Audit | ART-015 | flat | €1,500.00 | 20 % | €1,800.00 | 105 | Supplier O | inactive |
(new Table('demo-sticky'))
->setData($stickyArticles)
->caption('Articles with a sticky head and column')
->selectable('article_id')
->column('name', 'Description', ['sortable' => true, 'minWidth' => '200px'])
->column('article_number', 'Article No.', ['muted' => true])
->column('unit', 'Unit')
->column('net_price', 'Net', ['format' => 'currency', 'sortable' => true])
->column('tax_rate', 'VAT', ['format' => 'percent'])
->column('gross', 'Gross', ['format' => 'currency'])
->column('stock', 'Stock', ['align' => 'right'])
->column('supplier', 'Supplier', ['minWidth' => '360px'])
->column('is_active', 'Status', ['format' => 'label'])
->button('edit', ['icon' => 'edit', 'params' => ['id' => 'article_id']])
->nowrap()
->toolbar(false)
->stickyHead('320px')
->stickyColumn()
->render();columnToggle() puts a "Columns" button in the toolbar. Untick a column in its menu and it is gone from the header and the rows — through a sort, a search and a page change, and on your next visit too: the browser remembers it for this table. 'hidden' => true starts a column hidden (here the unit and the VAT), 'toggle' => false keeps one on screen (the article number). The CSV holds what the table shows; on a phone a hidden column is left out of the card, and if it was the card's title the next column takes its place.
| Article No. | Unit | VAT | Status | ||
|---|---|---|---|---|---|
| ART-001 | Web Design Package S | flat | €1,200.00 | 20 % | active |
| ART-002 | Hosting Standard | pcs | €9.90 | 20 % | active |
| ART-003 | SEO Consulting | h | €95.00 | 20 % | inactive |
| ART-004 | Logo Design | flat | €450.00 | 20 % | draft |
| ART-005 | Newsletter Setup | flat | €350.00 | 20 % | active |
(new Table('demo-columns'))
->setData(array_slice($articles, 0, 8))
->search(['article_number', 'name'])
->column('article_number', 'Article No.', ['muted' => true, 'toggle' => false])
->column('name', 'Description', ['sortable' => true])
->column('unit', 'Unit', ['hidden' => true])
->column('net_price', 'Net', ['format' => 'currency', 'align' => 'right', 'sortable' => true])
->column('tax_rate', 'VAT', ['format' => 'percent', 'hidden' => true])
->column('is_active', 'Status', ['format' => 'label'])
->columnToggle()
->exportCsv('articles.csv')
->paginate(5)
->render();densityToggle() puts Compact · Normal · Roomy into the toolbar. The steps are those of Theme::density() (konsole, the default, weit), applied to this table only and remembered for its id in this browser — choose one, sort or search, reload the page. Normal is GridKit's default rhythm; on a page set to konsole the control starts at Compact. Without the script the control is not shown.
| No. | Net | Status | Actions | |
|---|---|---|---|---|
| ART-001 | Web Design Package S | €1,200.00 | active | |
| ART-002 | Hosting Standard | €9.90 | active | |
| ART-003 | SEO Consulting | €95.00 | inactive | |
| ART-004 | Logo Design | €450.00 | draft | |
| ART-005 | Newsletter Setup | €350.00 | active | |
| ART-006 | Social Media Package | €680.00 | active |
(new Table('demo-density'))
->setData(array_slice($articles, 0, 6))
->search(['name'])
->column('article_number', 'No.', ['muted' => true, 'width' => '110px'])
->column('name', 'Description', ['sortable' => true])
->column('net_price', 'Net', ['format' => 'currency', 'align' => 'right'])
->column('is_active', 'Status', ['format' => 'label'])
->button('edit', ['icon' => 'edit', 'position' => 'right', 'params' => ['id' => 'article_id']])
->densityToggle()
->render();Every sortable table remembers its sort — the column and the direction, nothing else. Click a header, reload the page or come back later: the same sort is there. A third click on the same column (ascending, descending, off) goes back to the default order and forgets it. It is kept per user, per page and per table, a sort in the address wins, and a search or a filter is never kept. It works for the static table here, for server-driven tables, live tables and SortLink lists alike, and needs no call. data-gk-sort-merken="aus" on a table (or any container around it) switches it off.
| ART-001 | Web Design Package S | €1,200.00 |
| ART-002 | Hosting Standard | €9.90 |
| ART-003 | SEO Consulting | €95.00 |
| ART-004 | Logo Design | €450.00 |
| ART-005 | Newsletter Setup | €350.00 |
| ART-006 | Social Media Package | €680.00 |
(new Table('demo-sort-memory'))
->setData(array_slice($articles, 0, 6))
->column('article_number', 'No.', ['muted' => true, 'width' => '110px', 'sortable' => true])
->column('name', 'Description', ['sortable' => true])
->column('net_price', 'Net', ['format' => 'currency', 'align' => 'right', 'sortable' => true])
->toolbar(false)
->paginate(false)
->render();editable() and a column's 'edit' ('text', 'number' or 'select') let a value be changed where it stands: click a cell with the dotted line, or Tab to it and press Enter. Enter or leaving the field saves, Escape puts the old value back, Tab saves and opens the next one. The field holds the stored value (1200, not €1,200.00). Every change fires gk:celledit; with a URL GridKit posts it there and shows the answer. This page has no server, so the listener below answers with respondWith() after a moment, the way an endpoint would — and refuses a negative price.
| No. | Description | Net | Status |
|---|---|---|---|
| ART-001 | Web Design Package S | €1,200.00 | Active |
| ART-002 | Hosting Standard | €9.90 | Active |
| ART-003 | SEO Consulting | €95.00 | Inactive |
| ART-004 | Logo Design | €450.00 | Draft |
(new Table('demo-edit'))
->setData(array_slice($articles, 0, 4))
->caption('Articles, editable in the cell')
->editable('article_id') // with a URL: ->editable('article_id', '/api/article-cell.php')
->column('article_number', 'No.', ['muted' => true, 'width' => '110px'])
->column('name', 'Description', ['edit' => 'text'])
->column('net_price', 'Net', ['format' => 'currency', 'edit' => 'number'])
->column('is_active', 'Status', ['format' => 'label', 'edit' => 'select', 'labels' => [
'active' => ['color' => 'green', 'text' => 'Active'],
'draft' => ['color' => 'orange', 'text' => 'Draft'],
'inactive' => ['color' => 'gray', 'text' => 'Inactive'],
]])
->toolbar(false)
->render();Resize the browser window to <768px to see the mobile layout. In card mode the first line of a card is its head: the checkbox, the left buttons, the title and the right buttons side by side, then the other fields without rules (since 1.106.0). The title is the first column that is not 'muted' — here the description, because the article number is muted; on a row with rowLink() it is the cell with the link.
| Article No. | Description | Price | Status | Actions |
|---|---|---|---|---|
| ART-001 | Webdesign Paket S | 1.200 € | active | |
| ART-002 | Hosting Standard | 9,90 € | active | |
| ART-003 | SEO Beratung | 95 € | inactive |
| Article No. | Description | Price | Status |
|---|---|---|---|
| ART-001 | Webdesign Paket S | 1.200 € | active |
| ART-002 | Hosting Standard | 9,90 € | active |
| ART-003 | SEO Beratung | 95 € | inactive |
| Article No. | Description | Price | Status |
|---|---|---|---|
| ART-001 | Webdesign Paket S | 1.200 € | active |
| ART-002 | Hosting Standard | 9,90 € | active |
| ART-003 | SEO Beratung | 95 € | inactive |
// Demo 1: Complete article table with pagination
$table = new Table('articles');
$table->setData($articles)
->search(['article_number', 'name'])
->column('name', 'Description', ['sortable' => true])
->column('net_price', 'Net', ['format' => 'currency'])
->column('tax_rate', 'VAT', ['format' => 'percent'])
->column('is_active', 'Status', ['format' => 'label'])
->button('edit', ['icon' => 'edit', 'class' => 'primary'])
->button('delete', ['icon' => 'delete', 'class' => 'danger'])
->newButton('New Article', ['icon' => 'add'])
->nowrap(true)
->paginate(5)
->render();
// Mobile-Responsive
$table->mobile('card'); // Cards on mobile (default): the first column that is
// not 'muted' is the card's title, beside the buttons
$table->mobile('scroll'); // Horizontal Scroll
$table->column('desc', 'Description', ['hideOnMobile' => true]);selectable() adds a checkbox column, a select-all in the header and a bulk bar that appears while rows are ticked; its delete button fires gk:bulkdelete with { ids, tableId }. footer() writes a summary row, loadTime() the milliseconds, toolbarHtml() puts your own markup into the toolbar, 'href' turns a cell into a link with a quiet second line from 'sub', bulkAction() adds a button to the bulk bar (it fires gk:bulkaction; tick a row and try it) and exportCsv() a toolbar button that downloads what the table shows, after the search and the sort, as CSV.
| No. | Net | Status | ||
|---|---|---|---|---|
| ART-001 | Web Design Package S flat | €1,200.00 | active | |
| ART-002 | Hosting Standard pcs | €9.90 | active | |
| ART-003 | SEO Consulting h | €95.00 | inactive | |
| ART-004 | Logo Design flat | €450.00 | draft | |
| ART-005 | Newsletter Setup flat | €350.00 | active | |
| ART-006 | Social Media Package flat | €680.00 | active | |
| Total | 2,849.40 | 37 ms | ||
(new Table('demo-select'))
->setData(array_slice($articles, 0, 6))
->caption('Articles with a selection')
->selectable('article_id')
->search(['name'])
->toolbarHtml('<span class="gk-label gk-label-blue">toolbarHtml()</span>')
->column('article_number', 'No.', ['muted' => true, 'width' => '110px'])
->column('name', 'Description', ['href' => '#table-select', 'sub' => 'unit', 'sortable' => true])
->column('net_price', 'Net', ['format' => 'currency', 'align' => 'right'])
->column('is_active', 'Status', ['format' => 'label'])
->footer(['Total', ['text' => '2,849.40', 'align' => 'right', 'bold' => true]])
->loadTime(37)
->bulkAction('archive', ['icon' => 'archive', 'label' => 'Archive'])
->bulkAction('void', ['icon' => 'block', 'confirm' => 'Void the selected articles?', 'color' => 'danger'])
->exportCsv('articles.csv')
->stickyColumn() // a box of its own just above the phone width, where it was 8px too wide
->render();$form = new Form('article_form');
$form->action('save/process_article.php')
->ajax()
->hidden('article_id', '')
->row()
->field('article_number', 'Article No.', 'text', ['required' => true, 'width' => 8])
->field('name', 'Description', 'text', ['required' => true, 'width' => 8])
->endRow()
->field('description', 'Description', 'textarea', ['rows' => 3])
->row()
->field('unit', 'Unit', 'select', ['options' => ['Stk' => 'Piece', 'h' => 'Hour', 'psch' => 'Flat rate'], 'width' => 5])
->field('net_price', 'Net price', 'number', ['step' => '0.01', 'width' => 5])
->field('tax_rate', 'VAT %', 'select', ['options' => ['20' => '20%', '10' => '10%', '0' => '0%'], 'width' => 6])
->endRow()
->field('is_active', 'Active', 'toggle', ['inline' => true])
->submit('Save')
->render();Local vendor bundle (assets/ckeditor5/), no CDN. Initialization via IntersectionObserver — works in tabs and modals too.
Add 'upload' => '/your/endpoint' and the editor gains a picture button,
drag & drop, paste, size handles and alt text. Without it nothing changes — an upload
button with nowhere to put the file is worse than no button.
Pictures render as a plain <img> inside the paragraph, carrying their size
as an inline style — deliberately not as <figure class="image">,
so the same content survives being sent as an e-mail, where no stylesheet loads and Outlook
does not lay out <figure> reliably.
Try it: click the picture below to get the size handles and the alt-text button.
The upload button works too, but this public demo stores nothing and says so.
Trash icon only appears when a value is set — disappears automatically after clearing.
Uniform height of 44px for all input types. No browser spinner for number.
Searchable Select – Country selection with search field
Multi-Select – Select multiple categories (with chips)
Ajax Select – Customer search via API (min. 2 characters)
// Grid Layout (16 columns)
$form->row()
->field('name', 'Name', 'text', ['width' => 8])
->field('email', 'E-Mail', 'email', ['width' => 8])
->endRow()
->field('agree', 'Accept terms', 'checkbox', ['checked' => true])
->field('payment', 'Payment method', 'radio', [
'options' => ['card' => 'Credit card', 'bank' => 'Bank transfer'],
'value' => 'card', 'inline' => true
])
->field('active', 'Active', 'toggle', ['inline' => true])
->field('volume', 'Volume', 'range', ['min' => 0, 'max' => 100, 'value' => 50])
->field('doc', 'Document', 'file', ['accept' => '.pdf', 'multiple' => true, 'maxSize' => '10MB'])
->field('content', 'Content', 'richtext', ['preset' => 'full'])
->field('datum', 'Date', 'date', ['value' => date('Y-m-d'), 'clearable' => true])
->field('farbe', 'Color', 'color', ['value' => '#6750a4'])
->field('preis', 'Price', 'number', ['placeholder' => '0.00'])Select files via drag & drop or click
Type, size (min/max), count and total size
Image thumbnails directly in the upload zone
Progress indicator, states, errors per file
Document upload with type filter and size limit.
Multi-upload with image thumbnails directly in the zone.
All options combined: types, min/max size, total limit, file count.
Manually cycle queue items through states: pending → uploading → done / error.
Zone with strict limits — PDF only, max. 100 KB.
Styled native color input — color swatch on the left (clickable) + hex field on the right. Swatch and hex value sync automatically, validated as #RRGGBB.
#RRGGBB values are accepted
Wrap any form in .gk-form-compact for reduced spacing. All elements — inputs, selects, toggles, checkboxes — scale down proportionally.
.gk-form-compact<!-- Normal (default) -->
<form>
<div class="gk-field">...</div>
</form>
<!-- Compact -->
<form class="gk-form-compact">
<div class="gk-field">...</div>
</form>
<!-- Also works as wrapper -->
<div class="gk-form-compact">
<div class="gk-card">
<div class="gk-field">...</div>
</div>
</div>
values() fills every field whose name is a key of the record (a field's own 'value' wins), errors() puts each message under its field, and a message that names no field is shown once above the form. Together they are an edit form shown again after a failed save.
$invoice = ['number' => 'INV-2026-007', 'customer' => '', 'status' => 'draft', 'amount' => '12,5', 'ignored' => 'a key without a field'];
(new Form('demo-values'))
->field('number', 'Number', 'text', ['width' => 8, 'required' => true])
->field('status', 'Status', 'select', ['width' => 8, 'options' => ['draft' => 'Draft', 'paid' => 'Paid']])
->field('customer', 'Customer', 'text', ['required' => true])
->field('amount', 'Amount', 'text')
->values($invoice)
->errors(['customer' => 'Required', 'amount' => 'Not a number', '_form' => 'The invoice was not saved.'])
->render();'showIf' shows a field only while another field has a value: equals, not, in or filled. A field that is not shown is hidden and disabled, so it is not posted and required blocks nothing. Choose a kind below; the VAT id waits for the company name, which waits for the kind.
(new Form('demo-show-if'))
->field('kind', 'Kind', 'select', ['native' => true, 'value' => 'person', 'options' => ['person' => 'Person', 'company' => 'Company', 'club' => 'Club']])
->field('company', 'Company name', 'text', ['required' => true, 'showIf' => ['field' => 'kind', 'equals' => 'company']])
->field('vat', 'VAT id', 'text', ['showIf' => ['field' => 'company', 'filled' => true]])
->field('birthday', 'Date of birth', 'date', ['showIf' => ['field' => 'kind', 'equals' => 'person']])
->field('board', 'Board members', 'text', ['showIf' => ['field' => 'kind', 'in' => ['company', 'club']]])
->render();tab() puts the fields that follow it into a tab: fields before the first tab stand above the tabs, fields after endTabs() below them. Press Save while the city is empty: the form opens the tab Address, the browser points at the field, and the tab carries a badge that counts what is wrong until it is put right. Sent, the form comes back on the tab you were on — it posts that tab as _gk_tab, and values($_POST) hands it back (this demo stores nothing). In a modal or a side sheet add tabsSecondary().
$customer = ['ct_number' => 'C-1042', 'ct_name' => 'Ada Lovelace', 'ct_email' => '[email protected]'];
(new Form('demo-tabs'))
->action('#form')
->field('ct_number', 'Customer no.', 'text', ['width' => 8])
->tab('general', 'General', ['icon' => 'person'])
->field('ct_name', 'Name', 'text', ['required' => true])
->field('ct_email', 'Email', 'email')
->tab('address', 'Address', ['icon' => 'home'])
->row()
->field('ct_street', 'Street', 'text', ['width' => 10])
->field('ct_zip', 'Postcode', 'text', ['width' => 6])
->endRow()
->field('ct_city', 'City', 'text', ['required' => true])
->tab('notes', 'Notes', ['icon' => 'sticky_note_2', 'count' => 2])
->field('ct_note', 'Internal note', 'textarea')
->endTabs()
->field('ct_tags', 'Tags', 'text')
->values(array_filter($_POST, 'is_string')) // what was sent, the tab included …
->values($customer) // … else the record
->submit('Save')
->render();The same form shown again after a failed save. errors() opens the first tab with an error — over the tab that was posted (here Notes) — and every tab with errors carries the count, in PHP, so it holds without a script.
(new Form('demo-tabs-errors'))
->action('#form')
->field('ce_number', 'Customer no.', 'text', ['width' => 8])
->tab('general', 'General', ['icon' => 'person'])
->field('ce_name', 'Name', 'text', ['required' => true])
->field('ce_email', 'Email', 'email')
->tab('address', 'Address', ['icon' => 'home'])
->row()
->field('ce_street', 'Street', 'text', ['width' => 10])
->field('ce_zip', 'Postcode', 'text', ['width' => 6])
->endRow()
->field('ce_city', 'City', 'text', ['required' => true])
->tab('notes', 'Notes', ['icon' => 'sticky_note_2', 'count' => 2])
->field('ce_note', 'Internal note', 'textarea')
->endTabs()
->values(['ce_number' => 'C-1042', 'ce_name' => 'Ada Lovelace', 'ce_zip' => '10A', '_gk_tab' => 'notes'])
->errors(['ce_city' => 'Required', 'ce_zip' => 'Not a postcode', '_form' => 'The customer was not saved.'])
->submit('Save')
->render();Card grid for structured content — responsive, with header, body and footer.
.gk-cards // Auto-Grid (min 280px) .gk-cards-2 / -3 / -4 // Fixed columns .gk-card .gk-card-header / .gk-card-body / .gk-card-footer .gk-card-link // Clickable Card
$stats = new StatCards('dashboard');
$stats->card('Customers', 248, ['format' => 'number', 'color' => 'blue'])
->card('Revenue', 84250.00, ['format' => 'currency', 'color' => 'green'])
->card('Outstanding', 12480.00, ['format' => 'currency', 'color' => 'red'])
->render();The small parts an admin page used to style itself, as classes. Light and dark come from the roles.
(new StatCards('demo-tiles'))
->compact()
->card('failing', 3, ['color' => 'danger'])
->card('open', 12, ['sub' => 'for 3 days'])
->card('done', 40)
->render();(new Form('demo-settings'))
->field('demo_login', 'Sign-in allowed', 'toggle', ['hint' => 'Takes effect at once, also on running sessions.', 'value' => 1])
->field('demo_lock', 'Lock the account', 'toggle', ['hint' => 'Signs the person out everywhere.', 'danger' => true])
->field('demo_next', 'What happens now?', 'choice', ['value' => 'fix', 'options' => [
'fix' => 'Fix it now',
'later' => ['title' => 'Later', 'hint' => 'Stays on the list until next week.'],
]])
->render();echo <<<'HTML'
<div class="gk-field-static">
<span class="gk-field-static-label">Plan</span>
<span class="gk-field-static-value">Everything</span>
<span class="gk-field-hint">The superuser always has everything.</span>
</div>
HTML;echo <<<'HTML'
<div class="gk-flex gk-flex-col gk-gap-xl">
<div class="gk-flex gk-flex-wrap gk-gap-xl gk-items-center">
<span><span class="gk-dot gk-dot-success" aria-hidden="true"></span> today 08:12</span>
<span><span class="gk-dot gk-dot-warning" aria-hidden="true"></span> 3 days ago</span>
<span><span class="gk-dot gk-dot-primary gk-dot-pulse" aria-hidden="true"></span> running</span>
<span><span class="gk-dot gk-dot-outline" aria-hidden="true"></span> never</span>
</div>
<div class="gk-flex gk-gap-md">
<span class="gk-avatar gk-avatar-sm gk-avatar-initials gk-avatar-tone-1" aria-hidden="true">AS</span>
<span class="gk-avatar gk-avatar-sm gk-avatar-initials gk-avatar-tone-2" aria-hidden="true">TB</span>
<span class="gk-avatar gk-avatar-sm gk-avatar-initials gk-avatar-tone-3" aria-hidden="true">LW</span>
<span class="gk-avatar gk-avatar-sm gk-avatar-initials gk-avatar-tone-4" aria-hidden="true">PG</span>
<span class="gk-avatar gk-avatar-sm gk-avatar-initials gk-avatar-tone-5" aria-hidden="true">MH</span>
</div>
</div>
HTML;echo <<<'HTML'
<div class="gk-flex gk-flex-wrap gk-gap-xl">
<span><span class="gk-swatch gk-swatch-1" aria-hidden="true"></span> Model A 41 %</span>
<span><span class="gk-swatch gk-swatch-2" aria-hidden="true"></span> Model B 27 %</span>
<span><span class="gk-swatch gk-swatch-3" aria-hidden="true"></span> Model C 18 %</span>
<span><span class="gk-swatch gk-swatch-4" aria-hidden="true"></span> Model D 9 %</span>
<span><span class="gk-swatch gk-swatch-5" aria-hidden="true"></span> Other 5 %</span>
</div>
HTML;echo <<<'HTML'
<div class="gk-message gk-message-warning">
<span>2 runs are stuck.</span>
<div class="gk-message-actions"><button type="button" class="gk-btn gk-btn-outlined gk-btn-warning gk-btn-touch">Check now</button></div>
</div>
HTML;Entries a person puts in order by hand. Write the container with data-gk-sortierbar and give each entry a data-gk-sort-id; js/sortierbar.js adds a handle to every entry (from two entries on). Drag the handle with a mouse or a finger, or focus it and press Space, move with the arrow keys, press Space again to put it down or Esc to cancel. Links and buttons inside an entry keep working. With data-gk-sortierbar-url and -csrf the new order is posted as {"ids":[…]}; without a url the container only fires gk:sortiert, as here.
Online, 14 pages
Draft, 6 pages
Online, 9 pages
Online, 4 pages · Open
Draft, 2 pages
Sent right after the sign-up
Two days later
A week later
echo <<<'HTML'
<div class="demo-sort-grid" data-gk-sortierbar aria-label="Websites, in the order you want them">
<div data-gk-sort-id="12"><h4>survivaltraining.at</h4><p>Online, 14 pages</p></div>
<div data-gk-sort-id="7"><h4>manifestor-akademie.net</h4><p>Draft, 6 pages</p></div>
<div data-gk-sort-id="31"><h4>paneon.ssi.at</h4><p>Online, 9 pages</p></div>
<div data-gk-sort-id="18" data-gk-sort-titel="Deike Pfeil"><h4>deike.at</h4><p>Online, 4 pages · <a href="#sortierbar">Open</a></p></div>
<div data-gk-sort-id="22"><h4>lohr.example</h4><p>Draft, 2 pages</p></div>
</div>
<ul class="demo-sort-list" data-gk-sortierbar>
<li data-gk-sort-id="a"><h4>Welcome mail</h4><p>Sent right after the sign-up</p></li>
<li data-gk-sort-id="b"><h4>Reminder</h4><p>Two days later</p></li>
<li data-gk-sort-id="c"><h4>Offer</h4><p>A week later</p></li>
</ul>
<script>
document.addEventListener('gk:sortiert', function (e) { console.log('gk:sortiert', e.detail.ids); });
</script>
HTML;gk-card-elevated trades the border for a shadow, gk-card-flat keeps a hairline, gk-card-image puts a picture flush with the top, gk-card-title and gk-card-actions fill a header, and gk-card-link makes the whole card a link.
A card takes a colour role (primary, success, info, warning, danger) as well as the colour names; 'trend' with a sign draws the arrow, 'highlight' frames the card that needs attention.
(new StatCards('demo-stat-roles'))
->card('Revenue', 12450.80, ['format' => 'currency', 'icon' => 'euro', 'color' => 'primary', 'trend' => '+12%'])
->card('Paid', 98, ['format' => 'number', 'icon' => 'check_circle', 'color' => 'success', 'trend' => '+3%'])
->card('Open', 14, ['format' => 'number', 'icon' => 'schedule', 'color' => 'info', 'trend' => '-2%'])
->card('Late', 6, ['format' => 'number', 'icon' => 'warning', 'color' => 'warning'])
->card('Errors', 3, ['format' => 'number', 'icon' => 'error', 'color' => 'danger', 'highlight' => true])
->render();Container for related content — single, stacked or with header.
A simple segment visually groups related content.
Segments can have a header to describe the content.
Create account and confirm email.
Fill out profile and configure settings.
Create first project and get started.
With shadow — stands out more from the background.
Muted background — for secondary content.
Less padding — for denser layouts.
.gk-segment / .gk-segment-raised / .gk-segment-muted / .gk-segment-compact .gk-segment-padded / .gk-segment-basic .gk-segments > .gk-segment // Stacked
Notices, warnings and status messages for users.
A notch denser and without a margin of its own, for a place that sets its own gaps: the sentence above a chat, a hint beside a form. All four tones work, light and dark; a long address wraps.
.gk-message / .gk-message-info / .gk-message-success .gk-message-warning / .gk-message-error / .gk-message-compact .gk-message-sm // Denser, no margin of its own .gk-message-dismiss // Close button
The title on the left and the actions on the right. A long title pushes the buttons to the next line instead of squeezing them.
echo '<div class="gk-page-header"><h1>Customers</h1><div class="gk-page-header-actions">';
echo Button::render('Export', ['variant' => 'outlined', 'icon' => 'download']);
echo Button::render('New customer', ['variant' => 'filled', 'color' => 'primary', 'icon' => 'add', 'shape' => 'pill']);
echo '</div></div>';Karteireiter: the tabs sit framed on their surface, the chosen one grows into it — taller, bold, a 3px accent on top. Ordered with .gk-tab-nav-karte and .gk-tab-flaeche; without them every tab row keeps the previous shape. Levels: page tabs > second row (on a line, also inside a window) > segmented button. On a phone every Karteireiter row is a grid, two columns up to 480px — nothing scrolls, nothing is cut.
GridKit\Tabs writes the markup of this page for you: every style, alignment and option below is a call, a panel is HTML or a callable. Like Table it prints; html() returns the same string. Under each example is the code that ran. A wrong value (an unknown style, a key used twice, an active() that names no tab) raises a warning and renders the nearest correct thing — never an exception.
The sign-up form — our default texts apply.
Your own text for the confirmation page.
Three reminders.
Legal notice and privacy.
(new Tabs('demo-php'))
->style('karte')
->label('Texts of this page')
->tab('signup', 'Sign-up', ['icon' => 'edit_note', 'content' => '<p>The sign-up form — our default texts apply.</p>'])
->tab('confirm', 'Confirmation page', ['icon' => 'task_alt', 'badge' => 'Customised', 'content' => '<p>Your own text for the confirmation page.</p>'])
->tab('remind', 'Reminders', ['icon' => 'alarm', 'count' => 3, 'content' => '<p>Three reminders.</p>'])
->tab('legal', 'Legal', ['icon' => 'gavel', 'badge' => ['text' => 'Error', 'tone' => 'error'], 'content' => '<p>Legal notice and privacy.</p>'])
->tab('stats', 'Statistics', ['icon' => 'bar_chart', 'disabled' => true])
->render();Styles — style('karte' | 'linie' | 'kapsel' | 'text'); the card style puts its panels on the surface by itself (surface(false) takes it away).
style('karte')
Three details.
The history.
style('linie')
Three details.
The history.
style('kapsel')
Three details.
The history.
style('text')
Three details.
The history.
foreach (['karte', 'linie', 'kapsel', 'text'] as $style) {
(new Tabs('demo-php-' . $style))->style($style)->label("Style $style")
->tab('a', 'Overview', ['content' => "<p>style('$style')</p>"])
->tab('b', 'Details', ['count' => 3, 'content' => '<p>Three details.</p>'])
->tab('c', 'History', ['content' => '<p>The history.</p>'])
->render();
}Alignment and size — align('top' | 'links' | 'rechts' | 'unten' | 'fest') and size('sm' | 'md' | 'lg'). A bottom row is written after its panels, so the reading order is the order on the screen.
General settings.
Colours and fonts.
Who sees what.
The row stands after the panels.
The details.
(new Tabs('demo-php-links'))->style('linie')->align('links')->label('Settings, left')
->tab('general', 'General', ['icon' => 'tune', 'content' => '<p>General settings.</p>'])
->tab('look', 'Look', ['icon' => 'palette', 'content' => '<p>Colours and fonts.</p>'])
->tab('privacy', 'Privacy', ['icon' => 'lock', 'content' => '<p>Who sees what.</p>'])
->render();
(new Tabs('demo-php-unten'))->style('kapsel')->align('unten')->size('sm')->label('Sections, bottom')
->tab('a', 'Overview', ['content' => '<p>The row stands after the panels.</p>'])
->tab('b', 'Details', ['content' => '<p>The details.</p>'])
->render();Options — iconOnly() keeps the word for a screen reader and gives every tab aria-label (with its badge and count) and title; neutral(), fluid(), iconTop(); secondary(), fill(), oneRow() and flat() for the shapes of 1.99 and 1.104.
The word stays for a screen reader.
Twelve messages.
The history.
Home.
Search.
Inbox.
(new Tabs('demo-php-icons'))->style('kapsel')->iconOnly()->neutral()->label('Symbols only')
->tab('a', 'Overview', ['icon' => 'dashboard', 'content' => '<p>The word stays for a screen reader.</p>'])
->tab('b', 'Inbox', ['icon' => 'inbox', 'count' => 12, 'content' => '<p>Twelve messages.</p>'])
->tab('c', 'History', ['icon' => 'history', 'content' => '<p>The history.</p>'])
->render();
(new Tabs('demo-php-fluid'))->style('linie')->fluid()->iconTop()->size('lg')->label('Full width, symbol above')
->tab('a', 'Home', ['icon' => 'home', 'content' => '<p>Home.</p>'])
->tab('b', 'Search', ['icon' => 'search', 'content' => '<p>Search.</p>'])
->tab('c', 'Inbox', ['icon' => 'inbox', 'content' => '<p>Inbox.</p>'])
->render();Links between pages — when every tab has an href the row is a <nav> of links, the current page (active() or the parameter) marked with aria-current="page". A row is links or panels, never both.
(new Tabs('demo-php-pages'))->style('linie')->label('Pages')->active('results')
->tab('edit', 'Edit', ['href' => '#tabs-php', 'icon' => 'edit'])
->tab('results', 'Results', ['href' => '#tabs-php', 'icon' => 'bar_chart'])
->tab('mails', 'Mails', ['href' => '#tabs-php', 'icon' => 'mail', 'count' => 2])
->render();hash() keeps the chosen tab in the address: choose one and look at the address bar (#tabs&demo-deep=…) — the demo's own part of the fragment stays beside it, and Back still leaves the page. Open that address in another window and the tab is there. remember() keeps the last tab of the row in this browser: reload the page. param('tab') lets the server open a tab from ?tab=… without any script. The address wins over the memory, active() — the page's own decision — over both.
Your profile.
Your password.
Where you are signed in.
Billing.
(new Tabs('demo-deep'))->style('linie')->label('Account')->hash()->remember()->param('tab')
->tab('profile', 'Profile', ['content' => '<p>Your profile.</p>'])
->tab('password', 'Password', ['content' => '<p>Your password.</p>'])
->tab('sessions', 'Sessions', ['content' => '<p>Where you are signed in.</p>'])
->tab('billing', 'Billing', ['content' => '<p>Billing.</p>'])
->render();Links into it: #tabs&demo-deep=billing switches here and now; ?tab=sessions loads the page with Sessions open on the server.
'url' => … leaves the panel empty until its tab is opened, then fetches it (same origin, X-Requested-With), with a skeleton meanwhile and aria-busy on the panel, and keeps it. Widgets inside work: the table in Figures sorts, because GK.initContent() runs on the answer. A failure shows the table's failure state with “Try again” — never the server's own error page. 'reload' => true fetches every time. A page with an older gridkit.js shows a link to the panel's address instead.
This panel came with the page; the others are fetched when you open them.
(new Tabs('demo-lazy'))->style('karte')->label('Invoices')
->tab('now', 'Now', ['content' => '<p>This panel came with the page; the others are fetched when you open them.</p>'])
->tab('figures', 'Figures', ['icon' => 'insights', 'url' => 'api/tab-panel.php?part=figures'])
->tab('slow', 'Slow', ['icon' => 'hourglass_top', 'url' => 'api/tab-panel.php?part=slow'])
->tab('fail', 'Fails', ['icon' => 'error', 'url' => 'api/tab-panel.php?part=fail'])
->tab('time', 'Every time', ['icon' => 'schedule', 'url' => 'api/tab-panel.php?part=time', 'reload' => true])
->render();Every switch — a click, the arrow keys, GK.tabs.select(), the address — fires gk:tabchange first, and it is cancelable: change the name below and choose another tab. The tab stays (focus included) and asks; after a yes the page switches with { force: true }. gk:tabshown follows every switch.
Twelve orders.
No notes yet.
(new Tabs('demo-unsaved'))->style('linie')->label('Customer')
->tab('edit', 'Edit', ['content' => '<div class="gk-field"><label class="gk-label-text" for="demo-unsaved-name">Name</label><input class="gk-input" id="demo-unsaved-name" value="Ecklund & Partner"></div>'])
->tab('orders', 'Orders', ['content' => '<p>Twelve orders.</p>'])
->tab('notes', 'Notes', ['content' => '<p>No notes yet.</p>'])
->render();
echo <<<'HTML'
<pre class="demo-tabs-log" id="demo-unsaved-log" aria-live="polite"></pre>
<script>
(function () {
var row = document.getElementById('demo-unsaved');
var field = document.getElementById('demo-unsaved-name');
var log = document.getElementById('demo-unsaved-log');
var saved = field.value;
function say(line) { log.textContent = [line].concat(log.textContent.split('\n').slice(0, 3)).join('\n'); }
row.addEventListener('gk:tabchange', function (e) {
if (e.target !== row) return; // the events bubble: a row nested inside fires here too
say('gk:tabchange ' + e.detail.from + ' → ' + e.detail.to + ' (' + e.detail.source + ')');
if (!e.cancelable || e.detail.from !== 'edit' || field.value === saved) return;
e.preventDefault(); // the tab stays: the name is not saved
GK.confirm('Leave without saving the name?', { confirmText: 'Leave', danger: true }).then(function (yes) {
if (!yes) return;
field.value = saved;
GK.tabs.select(row, e.detail.to, { force: true });
});
});
row.addEventListener('gk:tabshown', function (e) {
if (e.target === row) say('gk:tabshown ' + e.detail.to);
});
})();
</script>
HTML;GK.tabs.select(), current(), badge(), count() and reload() take the row or its id — rows written by hand as well as by Tabs.
Four new messages.
No drafts.
Sent mail.
(new Tabs('demo-api'))->style('linie')->label('Mail')
->tab('inbox', 'Inbox', ['count' => 4, 'content' => '<p>Four new messages.</p>'])
->tab('drafts', 'Drafts', ['content' => '<p>No drafts.</p>'])
->tab('sent', 'Sent', ['content' => '<p>Sent mail.</p>'])
->render();
echo <<<'HTML'
<div class="demo-tabs-api" id="demo-api-buttons">
<button type="button" class="gk-btn gk-btn-outlined gk-btn-neutral gk-btn-sm" data-demo-api="more">One more mail</button>
<button type="button" class="gk-btn gk-btn-outlined gk-btn-neutral gk-btn-sm" data-demo-api="error">Mark Drafts as failed</button>
<button type="button" class="gk-btn gk-btn-outlined gk-btn-neutral gk-btn-sm" data-demo-api="clear">Clear the marks</button>
<button type="button" class="gk-btn gk-btn-outlined gk-btn-neutral gk-btn-sm" data-demo-api="sent">Open Sent</button>
<output id="demo-api-current"></output>
</div>
<script>
document.getElementById('demo-api-buttons').addEventListener('click', function (e) {
var b = e.target.closest('[data-demo-api]');
if (!b) return;
var count = document.querySelector('#demo-api [data-tab="inbox"] .gk-tab-count');
if (b.dataset.demoApi === 'more') GK.tabs.count('demo-api', 'inbox', (count ? Number(count.textContent) : 0) + 1);
if (b.dataset.demoApi === 'error') GK.tabs.badge('demo-api', 'drafts', 'Error', { tone: 'error' });
if (b.dataset.demoApi === 'clear') { GK.tabs.badge('demo-api', 'drafts', null); GK.tabs.count('demo-api', 'inbox', null); }
if (b.dataset.demoApi === 'sent') GK.tabs.select('demo-api', 'sent', { focus: true });
document.getElementById('demo-api-current').textContent = 'GK.tabs.current() → ' + GK.tabs.current('demo-api');
});
</script>
HTML;Ten tabs in a 340px box. A line, pill or text row still scrolls sideways, and a round arrow shows at each side that has more — a click pages the row. Measured on the row itself, like the card grid. Every tab stays a tab of the one row: the arrow keys and Home/End reach all of them and bring each into view, a screen reader hears all ten; the arrows are only for the pointer. The card style keeps its grid.
Overview.
Details.
History.
Settings.
Members.
Billing.
Invoices.
Reports.
Integrations.
Audit log.
Overview.
Details.
History.
Settings.
Members.
Billing.
Invoices.
Reports.
Integrations.
Audit log.
Overview.
Details.
History.
Settings.
Members.
Billing.
Invoices.
Reports.
Integrations.
Audit log.
$areas = ['Overview', 'Details', 'History', 'Settings', 'Members', 'Billing', 'Invoices', 'Reports', 'Integrations', 'Audit log'];
foreach (['linie', 'kapsel', 'text'] as $style) {
$row = (new Tabs('demo-over-' . $style))->style($style)->label("Ten tabs, $style");
foreach ($areas as $i => $area) $row->tab('t' . $i, $area, ['content' => "<p>$area.</p>"]);
echo '<div class="demo-tabs-box demo-tabs-box-340">';
$row->render();
echo '</div>';
}A badge only reports a deviation from the default (“Customised”, “Error”) — never “Default” on every tab. gk-tab-badge-error is the red one: the word stays, because colour alone says nothing. A count is a number of things behind the tab.
The sign-up form — our default texts apply.
Your own text for the confirmation page.
The welcome mail.
Three reminders.
The unsubscribe page.
Legal notice and privacy.
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-karte">
<button class="gk-tab-btn gk-active" data-tab="a"><span class="material-icons gk-tab-icon" aria-hidden="true">edit_note</span><span>Sign-up</span></button>
<button class="gk-tab-btn" data-tab="b">…<span>Confirmation page</span><span class="gk-tab-badge">Customised</span></button>
<button class="gk-tab-btn" data-tab="c">…<span>Reminders</span><span class="gk-tab-count">3</span></button>
<button class="gk-tab-btn" data-tab="d">…<span>Legal</span><span class="gk-tab-badge gk-tab-badge-error">Error</span></button>
</div>
<div class="gk-tab-panel gk-tab-flaeche gk-active" data-tab="a">…</div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="b">…</div>
</div>The shape of an editor page. The page tabs are cards on their surface; the second row inside the surface is a line tab row — words on a thin line, the chosen one with a 3px stroke in the main colour, no boxes, no grey. The levels never look alike. The corners of both are --gk-tab-radius (4px; set it on any ancestor to change it).
Two steps to go until publishing: the preview is not up to date, and the page changed after it was approved.
<nav class="gk-tab-nav gk-tab-nav-karte" aria-label="Areas">…</nav>
<div class="gk-tab-flaeche">
<nav class="gk-tab-nav gk-tab-nav-karte gk-tab-nav-secondary" aria-label="Ways to edit">…</nav>
<div class="gk-card">…</div>
</div>When a card is the only thing on a framed surface, the surface already is the card: the card loses its edge, shadow, rounding and padding, and its head (symbol, heading, line) and body stand flush with the content of the other tabs. A card inside it, or a card next to other content, keeps its frame. Nothing to order — it follows from .gk-card being the only child of .gk-tab-flaeche.
Made with AI (for the video as a whole): Yes. Material of others needs a proof of rights.
Music: a card inside the card keeps its frame.
Costs — a card next to another one keeps its frame.
Steps.
<div class="gk-tab-panel gk-tab-flaeche" data-tab="a">
<div class="gk-card"> <!-- the only child: no second frame -->
<div class="gk-card-header">…</div>
<div class="gk-card-body">…</div>
</div>
</div>Six tabs in boxes of 700, 560 and 340px. A row that fits stays the one line above; one that does not becomes the grid of the phone — every tab whole, every cell as tall as its row, the chosen one still grown into the surface. GK.tabsFit measures the row itself, so no window width has to be guessed (it puts .gk-tab-nav-raster on and takes it off). Without the script the row simply stays a line.
Preview, 700px box.
Script, 700px box.
Conversation, 700px box.
Material & rights, 700px box.
Log & costs, 700px box.
Publication, 700px box.
Preview, 560px box.
Script, 560px box.
Conversation, 560px box.
Material & rights, 560px box.
Log & costs, 560px box.
Publication, 560px box.
Preview, 340px box.
Script, 340px box.
Conversation, 340px box.
Material & rights, 340px box.
Log & costs, 340px box.
Publication, 340px box.
Links in a <nav>, the current page with aria-current="page". The second row stands quieter on a line inside the surface; a third level is a segmented button, never a tab row.
<nav class="gk-tab-nav gk-tab-nav-karte" aria-label="Areas">
<a class="gk-tab-btn" href="/results" aria-current="page">…</a>
</nav>
<div class="gk-tab-flaeche">
<nav class="gk-tab-nav gk-tab-nav-karte gk-tab-nav-secondary" aria-label="Views">…</nav>
<div class="gk-segmented" role="group" aria-label="Period">…</div>
</div>One list, two drawings: a table and cards. The page renders both, each in a data-gk-view block inside a data-gk-view-scope; a .gk-segmented with data-gk-view-toggle chooses, and the choice is remembered in the browser (since 1.132.0). The toggle is rendered hidden and shown by the script; without it the default drawing stands.
| Name | State |
|---|---|
| Carla | Active |
| Anton | Draft |
Active
Draft
<div class="gk-segmented" role="group" aria-label="View" data-gk-view-toggle="list" data-gk-view-default="table" hidden>
<button type="button" class="gk-segmented-item" data-gk-set-view="table" aria-pressed="false">Table</button>
<button type="button" class="gk-segmented-item" data-gk-set-view="cards" aria-pressed="false">Cards</button>
</div>
<div data-gk-view-scope="list">
<div data-gk-view="table">…</div>
<div data-gk-view="cards" hidden>…</div>
</div>A .gk-tabs inside a panel of another: a click on an outer tab leaves the inner choice alone (fixed in 1.101.0 — it used to clear every inner tab). Arrow keys move inside one row only.
Name, address, tax number.
Two contacts.
No notes yet.
Twelve invoices.
The window is already the surface, so its tabs take the second-row shape and no .gk-tab-flaeche.
Company name and address.
IBAN and BIC.
The logo for invoices.
Roles only: the edge is the outline mixed with 30% text colour (≥ 3:1 in every theme, light and dark).
Light mode.
Two details.
Dark mode.
Two details.
One row, three choices. The style is a class on the row (.gk-tab-nav-karte, -linie, -kapsel, -text), the alignment another (top is the default; -links, -rechts, -unten, -fest), and any number of options (-sm, -lg, -fluid, -icon-oben, -nur-icon, -neutral) join them. One script serves every form: role, selection, arrow keys by axis, Home and End. A row without any of these classes looks as it did before. Links between pages (<nav> with <a> and aria-current="page") take the same classes and keep their place: they are links, not a switch.
Six choices, a live preview, the markup it is made from and the same row as a GridKit\Tabs call. The preview and the listing are one string, so what you see is what you copy. Every choice is a class; try the arrow keys inside the preview.
The same row from PHP, with GridKit\Tabs (1.111.0):
The same three tabs in each style. Colours come from tokens on the row (--gk-tab-akzent for the stroke or fill, --gk-tab-akzent-text for the chosen word, --gk-tab-kante for the track): set them on the row itself to change one row. Light and dark are measured, not guessed — the chosen word is at least 4.5:1, the track and focus ring at least 3:1.
Card — .gk-tab-nav-karte with .gk-tab-flaeche on the panels, as before.
The overview.
Three details.
The history.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-karte" aria-label="Card style">
<button class="gk-tab-btn gk-active" data-tab="s-karte-a">Overview</button>
<button class="gk-tab-btn" data-tab="s-karte-b">Details<span class="gk-tab-count">3</span></button>
<button class="gk-tab-btn" data-tab="s-karte-c">History</button>
</div>
<div class="gk-tab-panel gk-tab-flaeche gk-active" data-tab="s-karte-a"><p>The overview.</p></div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="s-karte-b"><p>Three details.</p></div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="s-karte-c"><p>The history.</p></div>
</div>
HTML;Line — .gk-tab-nav-linie: words on a thin track, a 3px stroke under the chosen one.
The overview.
Three details.
The history.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-linie" aria-label="Line style">
<button class="gk-tab-btn gk-active" data-tab="s-linie-a">Overview</button>
<button class="gk-tab-btn" data-tab="s-linie-b">Details<span class="gk-tab-count">3</span></button>
<button class="gk-tab-btn" data-tab="s-linie-c">History</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="s-linie-a"><p>The overview.</p></div>
<div class="gk-tab-panel" data-tab="s-linie-b"><p>Three details.</p></div>
<div class="gk-tab-panel" data-tab="s-linie-c"><p>The history.</p></div>
</div>
HTML;Pill — .gk-tab-nav-kapsel: the row lies on a quiet track, the chosen tab is filled.
The overview.
Three details.
The history.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-kapsel" aria-label="Pill style">
<button class="gk-tab-btn gk-active" data-tab="s-kapsel-a">Overview</button>
<button class="gk-tab-btn" data-tab="s-kapsel-b">Details<span class="gk-tab-count">3</span></button>
<button class="gk-tab-btn" data-tab="s-kapsel-c">History</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="s-kapsel-a"><p>The overview.</p></div>
<div class="gk-tab-panel" data-tab="s-kapsel-b"><p>Three details.</p></div>
<div class="gk-tab-panel" data-tab="s-kapsel-c"><p>The history.</p></div>
</div>
HTML;Text — .gk-tab-nav-text: only words; the chosen one is bold with a thin line.
The overview.
Three details.
The history.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-text" aria-label="Text style">
<button class="gk-tab-btn gk-active" data-tab="s-text-a">Overview</button>
<button class="gk-tab-btn" data-tab="s-text-b">Details<span class="gk-tab-count">3</span></button>
<button class="gk-tab-btn" data-tab="s-text-c">History</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="s-text-a"><p>The overview.</p></div>
<div class="gk-tab-panel" data-tab="s-text-b"><p>Three details.</p></div>
<div class="gk-tab-panel" data-tab="s-text-c"><p>The history.</p></div>
</div>
HTML;Links between pages take the same classes. The current page is aria-current="page"; a click leaves the page, so these tabs keep their place from one page to the next.
echo <<<'HTML'
<nav class="gk-tab-nav gk-tab-nav-linie" aria-label="Pages">
<a class="gk-tab-btn" href="#tabs-stile" aria-current="page">Overview</a>
<a class="gk-tab-btn" href="#tabs-stile">Results</a>
<a class="gk-tab-btn" href="#tabs-stile">Settings</a>
</nav>
HTML;Top is the default and needs no class. A side row stands next to its panels — from 601px wide; on a phone it becomes the horizontal row, so nothing is squeezed. The arrow keys follow the axis: up and down in a side row, left and right in a horizontal one (aria-orientation says which). The width of the side column is --gk-tab-seitenbreite (14rem at most).
Left — .gk-tab-nav-links. The row and the panels sit in a .gk-tabs, the row as its direct child.
General settings.
Colours and fonts.
Who sees what.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-linie gk-tab-nav-links" aria-label="Settings, left">
<button class="gk-tab-btn gk-active" data-tab="a-links-a"><span class="material-icons gk-tab-icon" aria-hidden="true">tune</span><span>General</span></button>
<button class="gk-tab-btn" data-tab="a-links-b"><span class="material-icons gk-tab-icon" aria-hidden="true">palette</span><span>Look</span></button>
<button class="gk-tab-btn" data-tab="a-links-c"><span class="material-icons gk-tab-icon" aria-hidden="true">lock</span><span>Privacy</span></button>
</div>
<div class="gk-tab-panel gk-active" data-tab="a-links-a"><p>General settings.</p></div>
<div class="gk-tab-panel" data-tab="a-links-b"><p>Colours and fonts.</p></div>
<div class="gk-tab-panel" data-tab="a-links-c"><p>Who sees what.</p></div>
</div>
HTML;Right — .gk-tab-nav-rechts, here with the card style: the stroke moves to the outer edge.
General settings.
Colours and fonts.
Who sees what.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-karte gk-tab-nav-rechts" aria-label="Settings, right">
<button class="gk-tab-btn gk-active" data-tab="a-rechts-a">General</button>
<button class="gk-tab-btn" data-tab="a-rechts-b">Look</button>
<button class="gk-tab-btn" data-tab="a-rechts-c">Privacy</button>
</div>
<div class="gk-tab-panel gk-tab-flaeche gk-active" data-tab="a-rechts-a"><p>General settings.</p></div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="a-rechts-b"><p>Colours and fonts.</p></div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="a-rechts-c"><p>Who sees what.</p></div>
</div>
HTML;Bottom — .gk-tab-nav-unten: the row comes after the panels in the markup, so the order of reading matches what you see.
The overview.
Three details.
The history.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-panel gk-active" data-tab="a-unten-a"><p>The overview.</p></div>
<div class="gk-tab-panel" data-tab="a-unten-b"><p>Three details.</p></div>
<div class="gk-tab-panel" data-tab="a-unten-c"><p>The history.</p></div>
<div class="gk-tab-nav gk-tab-nav-kapsel gk-tab-nav-unten" aria-label="Sections, bottom">
<button class="gk-tab-btn gk-active" data-tab="a-unten-a">Overview</button>
<button class="gk-tab-btn" data-tab="a-unten-b">Details</button>
<button class="gk-tab-btn" data-tab="a-unten-c">History</button>
</div>
</div>
HTML;Fixed bar — .gk-tab-nav-unten .gk-tab-nav-fest: sticks to the lower edge of its box, the symbol above the word, the tabs share the width, and the bar keeps clear of a phone's home bar (env(safe-area-inset-bottom)). For up to five tabs. Scroll inside the frame; the frame is only the demo's phone.
The bar below stays where it is while this text scrolls.
Home: the things you did last. A fixed bar suits the few places an app is made of, not a long list of sections.
Each place is a symbol above its word. The chosen one is marked by the stroke and by the colour, never by colour alone.
On a phone with a home bar, the bar's own padding lifts the tabs above it.
Search.
Inbox.
echo <<<'HTML'
<div class="demo-tabs-telefon">
<div class="gk-tabs">
<div class="gk-tab-panel gk-active" data-tab="a-fest-a">
<p>The bar below stays where it is while this text scrolls.</p>
<p>Home: the things you did last. A fixed bar suits the few places an app is made of, not a long list of sections.</p>
<p>Each place is a symbol above its word. The chosen one is marked by the stroke and by the colour, never by colour alone.</p>
<p>On a phone with a home bar, the bar's own padding lifts the tabs above it.</p>
</div>
<div class="gk-tab-panel" data-tab="a-fest-b"><p>Search.</p></div>
<div class="gk-tab-panel" data-tab="a-fest-c"><p>Inbox.</p></div>
<div class="gk-tab-nav gk-tab-nav-linie gk-tab-nav-unten gk-tab-nav-fest" aria-label="Main places">
<button class="gk-tab-btn gk-active" data-tab="a-fest-a"><span class="material-icons gk-tab-icon" aria-hidden="true">home</span><span>Home</span></button>
<button class="gk-tab-btn" data-tab="a-fest-b"><span class="material-icons gk-tab-icon" aria-hidden="true">search</span><span>Search</span></button>
<button class="gk-tab-btn" data-tab="a-fest-c"><span class="material-icons gk-tab-icon" aria-hidden="true">inbox</span><span>Inbox</span><span class="gk-tab-count">2</span></button>
</div>
</div>
</div>
HTML;Options join any style and any alignment. All of them read the same tokens, so a row stays in tune in light and dark, and on a phone every tab is at least a finger high (44px).
Size — .gk-tab-nav-sm and .gk-tab-nav-lg (the card style takes them from 601px up; on a phone every tab is a finger high).
echo <<<'HTML'
<nav class="gk-tab-nav gk-tab-nav-linie gk-tab-nav-sm" aria-label="Small">
<a class="gk-tab-btn" href="#tabs-optionen" aria-current="page">Small</a>
<a class="gk-tab-btn" href="#tabs-optionen">Compact</a>
<a class="gk-tab-btn" href="#tabs-optionen">Dense</a>
</nav>
<nav class="gk-tab-nav gk-tab-nav-linie" aria-label="Normal">
<a class="gk-tab-btn" href="#tabs-optionen" aria-current="page">Normal</a>
<a class="gk-tab-btn" href="#tabs-optionen">Regular</a>
<a class="gk-tab-btn" href="#tabs-optionen">Plain</a>
</nav>
<nav class="gk-tab-nav gk-tab-nav-linie gk-tab-nav-lg" aria-label="Large">
<a class="gk-tab-btn" href="#tabs-optionen" aria-current="page">Large</a>
<a class="gk-tab-btn" href="#tabs-optionen">Roomy</a>
<a class="gk-tab-btn" href="#tabs-optionen">Big</a>
</nav>
HTML;Full width — .gk-tab-nav-fluid: the tabs share the row equally.
echo <<<'HTML'
<nav class="gk-tab-nav gk-tab-nav-kapsel gk-tab-nav-fluid" aria-label="Period">
<a class="gk-tab-btn" href="#tabs-optionen">Today</a>
<a class="gk-tab-btn" href="#tabs-optionen" aria-current="page">7 days</a>
<a class="gk-tab-btn" href="#tabs-optionen">30 days</a>
</nav>
HTML;Symbol above the word — .gk-tab-nav-icon-oben. Symbol only — .gk-tab-nav-nur-icon: the word is hidden to the eye and stays for a screen reader; give every tab an aria-label and a title too, so the symbol is also named for the mouse.
The overview.
The details.
The history.
The overview.
The details.
The history.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-linie gk-tab-nav-icon-oben" aria-label="Symbol above">
<button class="gk-tab-btn gk-active" data-tab="o-icon-a"><span class="material-icons gk-tab-icon" aria-hidden="true">dashboard</span><span>Overview</span></button>
<button class="gk-tab-btn" data-tab="o-icon-b"><span class="material-icons gk-tab-icon" aria-hidden="true">list_alt</span><span>Details</span></button>
<button class="gk-tab-btn" data-tab="o-icon-c"><span class="material-icons gk-tab-icon" aria-hidden="true">history</span><span>History</span></button>
</div>
<div class="gk-tab-panel gk-active" data-tab="o-icon-a"><p>The overview.</p></div>
<div class="gk-tab-panel" data-tab="o-icon-b"><p>The details.</p></div>
<div class="gk-tab-panel" data-tab="o-icon-c"><p>The history.</p></div>
</div>
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-kapsel gk-tab-nav-nur-icon" aria-label="Symbol only">
<button class="gk-tab-btn gk-active" data-tab="o-nur-a" aria-label="Overview" title="Overview"><span class="material-icons gk-tab-icon" aria-hidden="true">dashboard</span><span>Overview</span></button>
<button class="gk-tab-btn" data-tab="o-nur-b" aria-label="Details" title="Details"><span class="material-icons gk-tab-icon" aria-hidden="true">list_alt</span><span>Details</span></button>
<button class="gk-tab-btn" data-tab="o-nur-c" aria-label="History" title="History"><span class="material-icons gk-tab-icon" aria-hidden="true">history</span><span>History</span></button>
</div>
<div class="gk-tab-panel gk-active" data-tab="o-nur-a"><p>The overview.</p></div>
<div class="gk-tab-panel" data-tab="o-nur-b"><p>The details.</p></div>
<div class="gk-tab-panel" data-tab="o-nur-c"><p>The history.</p></div>
</div>
HTML;Count and label — .gk-tab-count is a number of things behind the tab; .gk-tab-badge reports a deviation and .gk-tab-badge-error the red one (the word stays: colour alone says nothing).
echo <<<'HTML'
<nav class="gk-tab-nav gk-tab-nav-linie" aria-label="With count and label">
<a class="gk-tab-btn" href="#tabs-optionen" aria-current="page">Inbox<span class="gk-tab-count">12</span></a>
<a class="gk-tab-btn" href="#tabs-optionen">Drafts<span class="gk-tab-badge">Customised</span></a>
<a class="gk-tab-btn" href="#tabs-optionen">Legal<span class="gk-tab-badge gk-tab-badge-error">Error</span></a>
</nav>
HTML;Neutral — .gk-tab-nav-neutral: the chosen tab in the text colour instead of the main colour, for a page that already has a strong accent.
echo <<<'HTML'
<nav class="gk-tab-nav gk-tab-nav-linie gk-tab-nav-neutral" aria-label="Neutral line">
<a class="gk-tab-btn" href="#tabs-optionen" aria-current="page">Overview</a>
<a class="gk-tab-btn" href="#tabs-optionen">Results</a>
<a class="gk-tab-btn" href="#tabs-optionen">Settings</a>
</nav>
<nav class="gk-tab-nav gk-tab-nav-kapsel gk-tab-nav-neutral" aria-label="Neutral pill">
<a class="gk-tab-btn" href="#tabs-optionen" aria-current="page">Overview</a>
<a class="gk-tab-btn" href="#tabs-optionen">Results</a>
<a class="gk-tab-btn" href="#tabs-optionen">Settings</a>
</nav>
HTML;Disabled — disabled on a button or aria-disabled="true": dimmed, no hand cursor, no hover tint, skipped by the arrow keys, and a click does nothing.
The overview. Press the right arrow: it jumps over the two dimmed tabs.
Reports.
Billing.
The settings.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-linie" aria-label="With a disabled tab">
<button class="gk-tab-btn gk-active" data-tab="o-aus-a">Overview</button>
<button class="gk-tab-btn" data-tab="o-aus-b" disabled>Reports</button>
<button class="gk-tab-btn" data-tab="o-aus-c" aria-disabled="true">Billing</button>
<button class="gk-tab-btn" data-tab="o-aus-d">Settings</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="o-aus-a"><p>The overview. Press the right arrow: it jumps over the two dimmed tabs.</p></div>
<div class="gk-tab-panel" data-tab="o-aus-b"><p>Reports.</p></div>
<div class="gk-tab-panel" data-tab="o-aus-c"><p>Billing.</p></div>
<div class="gk-tab-panel" data-tab="o-aus-d"><p>The settings.</p></div>
</div>
HTML;Rows inside rows. Each .gk-tabs answers only for its own tabs: an outer click leaves the inner choice alone, and the arrow keys stay inside one row. In every example the outer and the inner tabs use the same data-tab keys on purpose — they are never mixed up.
1 · Card outside, line inside — the page of an editor. The links above are a separate row of pages.
The sign-up text.
The thank-you text.
The mails.
echo <<<'HTML'
<nav class="gk-tab-nav gk-tab-nav-text" aria-label="Pages">
<a class="gk-tab-btn" href="#tabs-kombinationen" aria-current="page">Editor</a>
<a class="gk-tab-btn" href="#tabs-kombinationen">Statistics</a>
</nav>
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-karte" aria-label="Areas">
<button class="gk-tab-btn gk-active" data-tab="a">Texts</button>
<button class="gk-tab-btn" data-tab="b">Mails</button>
</div>
<div class="gk-tab-panel gk-tab-flaeche gk-active" data-tab="a">
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-linie" aria-label="Texts">
<button class="gk-tab-btn gk-active" data-tab="a">Sign-up</button>
<button class="gk-tab-btn" data-tab="b">Thanks</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="a"><p>The sign-up text.</p></div>
<div class="gk-tab-panel" data-tab="b"><p>The thank-you text.</p></div>
</div>
</div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="b"><p>The mails.</p></div>
</div>
HTML;2 · Side row on the left, line row in its panel — a vertical row outside, a horizontal one inside.
Your profile.
Your password.
Where you are signed in.
The team.
Billing.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-linie gk-tab-nav-links" aria-label="Areas">
<button class="gk-tab-btn gk-active" data-tab="a">Account</button>
<button class="gk-tab-btn" data-tab="b">Team</button>
<button class="gk-tab-btn" data-tab="c">Billing</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="a">
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-linie" aria-label="Account">
<button class="gk-tab-btn gk-active" data-tab="a">Profile</button>
<button class="gk-tab-btn" data-tab="b">Password</button>
<button class="gk-tab-btn" data-tab="c">Sessions</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="a"><p>Your profile.</p></div>
<div class="gk-tab-panel" data-tab="b"><p>Your password.</p></div>
<div class="gk-tab-panel" data-tab="c"><p>Where you are signed in.</p></div>
</div>
</div>
<div class="gk-tab-panel" data-tab="b"><p>The team.</p></div>
<div class="gk-tab-panel" data-tab="c"><p>Billing.</p></div>
</div>
HTML;3 · Bottom bar around, card row in the page — an app's places below, a Karteireiter in one of them (in the demo's phone frame, so the bar has an edge to stick to).
Today.
This week.
Search.
echo <<<'HTML'
<div class="demo-tabs-telefon">
<div class="gk-tabs">
<div class="gk-tab-panel gk-active" data-tab="a">
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-karte" aria-label="Inside the home place">
<button class="gk-tab-btn gk-active" data-tab="a">Today</button>
<button class="gk-tab-btn" data-tab="b">Week</button>
</div>
<div class="gk-tab-panel gk-tab-flaeche gk-active" data-tab="a"><p>Today.</p></div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="b"><p>This week.</p></div>
</div>
</div>
<div class="gk-tab-panel" data-tab="b"><p>Search.</p></div>
<div class="gk-tab-nav gk-tab-nav-linie gk-tab-nav-unten gk-tab-nav-fest" aria-label="Places">
<button class="gk-tab-btn gk-active" data-tab="a"><span class="material-icons gk-tab-icon" aria-hidden="true">home</span><span>Home</span></button>
<button class="gk-tab-btn" data-tab="b"><span class="material-icons gk-tab-icon" aria-hidden="true">search</span><span>Search</span></button>
</div>
</div>
</div>
HTML;4 · Pill row over a card row — a switch of areas above, the sections of one area below.
Open offers.
Orders.
Invoices.
Support.
echo <<<'HTML'
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-kapsel" aria-label="Areas">
<button class="gk-tab-btn gk-active" data-tab="a">Sales</button>
<button class="gk-tab-btn" data-tab="b">Support</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="a">
<div class="gk-tabs">
<div class="gk-tab-nav gk-tab-nav-karte" aria-label="Sales">
<button class="gk-tab-btn gk-active" data-tab="a">Offers</button>
<button class="gk-tab-btn" data-tab="b">Orders</button>
<button class="gk-tab-btn" data-tab="c">Invoices</button>
</div>
<div class="gk-tab-panel gk-tab-flaeche gk-active" data-tab="a"><p>Open offers.</p></div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="b"><p>Orders.</p></div>
<div class="gk-tab-panel gk-tab-flaeche" data-tab="c"><p>Invoices.</p></div>
</div>
</div>
<div class="gk-tab-panel" data-tab="b"><p>Support.</p></div>
</div>
HTML;Collapsible content areas — individually or as a group.
<div class="gk-accordion" data-gk-single>
<div class="gk-accordion-item open">
<button class="gk-accordion-trigger">
<span>Question?</span>
<span class="material-icons">expand_more</span>
</button>
<div class="gk-accordion-content">
<div class="gk-accordion-body">Answer...</div>
</div>
</div>
</div>
// data-gk-single: only one item open at a time
// .open: item open by defaultProfile pictures with initials fallback, status dot and groups.
.gk-avatar.gk-avatar-lg // Sizes: xs, sm, md, lg, xl .gk-avatar-status.online // Status: online, away, busy, offline .gk-avatar-group // Stacked group .gk-avatar-square // Square instead of round
Path navigation for orientation in nested areas.
Page content here...
<nav class="gk-breadcrumb">
<a href="#"><span class="material-icons">home</span></a>
<span class="gk-breadcrumb-sep"><span class="material-icons">chevron_right</span></span>
<a href="#">Products</a>
<span class="gk-breadcrumb-sep">...</span>
<span class="gk-breadcrumb-current">Current Page</span>
</nav>The line shape every tab row keeps unless it orders the Karteireiter. The current shape, levels, nesting and the phone grid are under Tabs.
This is the overview — the first tab is active by default.
Detail information is displayed here.
Settings and configuration options.
<div class="gk-tabs">
<div class="gk-tab-nav">
<button class="gk-tab-btn gk-active" data-tab="tab-1">Tab 1</button>
<button class="gk-tab-btn" data-tab="tab-2">Tab 2</button>
</div>
<div class="gk-tab-panel gk-active" data-tab="tab-1">Content 1</div>
<div class="gk-tab-panel" data-tab="tab-2">Content 2</div>
</div>When each tab is a page of its own: links in a <nav>, the current page marked with aria-current="page" (it looks like .gk-active). .gk-tab-nav-fill is the main row (44px; on a phone the symbol stands over the word), .gk-tab-nav-secondary a quieter row under it. Above them a status band: a message with steps, a short to-do list (a compact timeline) and a disclosure.
<nav class="gk-tab-nav gk-tab-nav-fill" aria-label="Areas">
<a class="gk-tab-btn" href="/edit"><span class="material-icons gk-tab-icon" aria-hidden="true">edit</span><span>Edit</span></a>
<a class="gk-tab-btn" href="/results" aria-current="page">…</a>
</nav>
<nav class="gk-tab-nav gk-tab-nav-secondary" aria-label="Views">…</nav>
<ol class="gk-steps"><li class="gk-steps-item gk-steps-done">Draft</li>
<li class="gk-steps-item gk-steps-current" aria-current="step">Approval</li><li class="gk-steps-item">Live</li></ol>
<details class="gk-disclosure"><summary>Show 3 completed checks</summary>…</details>Combination examples showing the full potential of GridKit.
Tabs for main categories, accordion for details — a common pattern in admin UIs.
Dashboard view with status message and data table in a segment.
| Server | Status | CPU | RAM | Uptime |
|---|---|---|---|---|
| Baerli (server8) | Online | 12% | 4.2 GB | 47 days |
| Theo (server7) | Online | 8% | 3.8 GB | 23 days |
| Waldi (server6) | Online | 15% | 5.1 GB | 31 days |
Since 1.118.0 the pager of Table::paginate() is the bar of Pagination: the count on the left, the page buttons on the right, first and last included — the same boxes, sizes and colours in light and dark and in every theme. Below, a table of twelve rows that pages itself, and the bar for a list you page yourself, with the same numbers. The table counts the rows it shows (“1–5 of 12”); Pagination, which is handed pages and not rows, counts its entries.
| Customer | ||
|---|---|---|
| RE-2026-001 | Customer 1 | €125.50 |
| RE-2026-002 | Customer 2 | €251.00 |
| RE-2026-003 | Customer 3 | €376.50 |
| RE-2026-004 | Customer 4 | €502.00 |
| RE-2026-005 | Customer 5 | €627.50 |
$rows = [];
for ($i = 1; $i <= 12; $i++) {
$rows[] = ['id' => $i, 'no' => sprintf('RE-2026-%03d', $i), 'customer' => "Customer $i", 'total' => $i * 125.5];
}
(new Table('demo-one-pager'))->setData($rows)
->column('no', 'Inv. No.', ['sortable' => true, 'nowrap' => true])
->column('customer', 'Customer')
->column('total', 'Amount', ['format' => 'currency', 'align' => 'right', 'sortable' => true])
->toolbar(false)
->caption('Invoices')
->paginate(5)
->render();echo Pagination::build(['page' => 1, 'totalPages' => 3, 'total' => 12, 'baseUrl' => '#pager-match']);$chips = new FilterChips('status-filter', 'status');
$chips->chip('', 'All', ['count' => 152])
->chip('active', 'Active', ['count' => 89, 'color' => 'green'])
->render();One choice of a few that switches the view of a page — a period, overview or visitors. Joined; the chosen one is tinted and ticked. FilterChips::segmented($label) draws the same links in it.
(new FilterChips('period', 'days'))->current('7')->segmented('Period')
->chip('1', 'Today')->chip('7', '7 days')->chip('30', '30 days')->render();$years = new YearFilter('year-nav', 'year');
$years->range(2022, 2026)->render();One unified filter/search bar for all tables. Three fixed sections: Status row · Toolbar · Advanced (collapsible). Stops every page from looking different.
TableHeader::make('exp')
->status(fn() => $statusChips->render())
->search('q', $q, 'Search…', ['live' => 'exp-live'])
->filter(fn() => $yearFilter->render())
->filter('<select class="gk-filter">…</select>')
->advanced(fn() => renderDateRange())
->reset('/faktura/expenses')
->action(Button::render('New expense', ['href' => '/faktura/expenses/new', 'icon' => 'add'])) // 1.134.0
->render();Built-in formatting for table columns: currency, percent, date, boolean, label, email.
| Currency | Percent | Date | Boolean | Label | |
|---|---|---|---|---|---|
| €1,234.56 | 20 % | ✓ | paid | [email protected] | |
| €99.00 | 10 % | – | pending | [email protected] | |
| €5,500.00 | 0 % | ✓ | cancelled |
->column('amount', 'Amount', ['format' => 'currency']) // €1,234.56 (follows the locale)
->column('tax', 'VAT', ['format' => 'percent']) // 20 %
->column('date', 'Date', ['format' => 'date']) // Feb 13, 2026 (follows the locale)
->column('active', 'Active', ['format' => 'boolean']) // ✓ / –
->column('status', 'Status', ['format' => 'label']) // Colored label
->column('email', 'E-Mail', ['format' => 'email']) // mailto: LinkA chip takes green, orange, blue and red or the role names success, danger, primary, neutral; 'icon' puts a symbol in front. A colour shows on the chip that is active, here the first.
(new FilterChips('demo-chip-roles', 'role_status'))
->current('ok')
->chip('ok', 'Done', ['color' => 'success', 'icon' => 'check_circle'])
->chip('stop', 'Failed', ['color' => 'danger', 'icon' => 'error'])
->chip('me', 'Mine', ['color' => 'primary', 'icon' => 'person'])
->chip('rest', 'Others', ['color' => 'neutral', 'icon' => 'group'])
->render();Pagination::build() is the pager for a list you page yourself, PageSize the rows-per-page choice that belongs next to it. Both keep the other query parameters ('params', preserve()). While something loads, gk-skeleton stands in for the text.
echo Pagination::build(['page' => 5, 'totalPages' => 12, 'baseUrl' => '#pager', 'total' => 238, 'label' => 'invoices']);
(new PageSize())->options([10, 25, 50, 100])->current(25)->baseUrl('#pager')->render();echo '<div class="gk-flex gk-flex-col gk-gap-sm" aria-busy="true">';
echo '<div class="gk-skeleton" style="height:14px;width:60%"></div>';
echo '<div class="gk-skeleton" style="height:14px;width:90%"></div>';
echo '<div class="gk-skeleton" style="height:14px;width:40%"></div>';
echo '</div>';Nothing to call: with gridkit.js on the page, a click on a link of the same site or a submitted form shows a thin bar at the top at once, dims the clicked element (gk-page-pending, aria-busy) and says “Loading page …” to a screen reader. A click a script takes (preventDefault), a new tab, a download, a jump within the page or data-gk-ohne-lade shows nothing. GK.pageProgress.start(el) and .done() are there for code that navigates itself.
echo '<div class="gk-flex gk-gap-sm">';
echo '<a class="gk-btn" href="?progress=1#page-progress">Load this page again</a>';
echo '<a class="gk-btn" href="?progress=2#page-progress" data-gk-ohne-lade>Without the bar</a>';
echo '<button type="button" class="gk-btn" data-demo-progress="start">Start the bar</button>';
echo '</div>';Two ways to show pictures. A gallery looks: tiles that open a viewer. An image picker chooses: the same tiles, but each one is a radio button, and the viewer can pick. Both use the same viewer, so it pages with the arrow keys, closes on Escape and gives the focus back.
Tap a tile to pick it, or Tab into the group and use the arrow keys. The magnifier opens the viewer; Select this image in it picks the picture you are looking at. The status line, the form value and the event log below follow every change. One tile has a small origin chip ("AI"), one a remove button, one has no preview, one is disabled and says why. The last one's remove button is locked (since 1.133.0): it says why under the title, and a click explains instead of removing.
The picked tile (21 here) stays visible even though it lies beyond the fold. Resize the window: the number of tiles in the two rows follows the width. On a phone two tiles fit in a row, and thirty images are about four tiles and a button instead of a screen-long list.
| Where | Key | What happens |
|---|---|---|
| Picker | Tab | Enters the group once, on the picked tile; the next Tab reaches that tile's magnifier (and remove button), then the fold button — thirty tiles are not sixty tab stops. |
| Picker | ← → ↑ ↓ | Moves to the next tile and picks it (native radios); disabled tiles are skipped. |
| Picker | Enter on the magnifier | Opens the viewer on that picture. |
| Viewer | ← → | Previous or next picture (all of them, folded ones included). |
| Viewer | Tab | Stays inside: close, previous, next, "Select this image", "Close". |
| Viewer | Esc | Closes it; the focus goes back to the magnifier of the picture last shown — or to the radio, when one was picked from the viewer. |
Picking is the radio's own change event, so a form needs nothing new. A caption button fires gk:pickeraction and does nothing else —
here the page asks "Really?" first (GK.confirm) and only then calls GK.picker.remove(). The library never deletes anything itself.
picker.addEventListener('gk:pickeraction', (e) => {
// e.detail = { action: 'remove', value: 'img-3', item: <the tile>, picker: <the container> }
GK.confirm('Remove this image?', { danger: true }).then((ok) => {
if (ok) GK.picker.remove(e.detail.picker, e.detail.value);
});
});
GK.picker.add(picker, { value: 'img-9', title: 'Fresh upload', thumb: '/t/9.webp', full: '/g/9.webp' },
{ select: true, focus: true }); // picks it as a click would — one change event
// The viewer is open to your own lists too:
GK.lightbox.show([{ src: '/g/1.webp', caption: 'Fireplace', meta: 'Own image' }], 0, openerButton);Image grid with lazy loading, hover overlay and lightbox (arrow keys, Escape).
<div class="gk-gallery">
<div class="gk-gallery-item" data-lightbox="full.jpg" data-caption="Caption" data-lazy>
<img data-src="thumb.jpg" alt="">
<div class="gk-gallery-overlay">
<span class="gk-gallery-caption">Caption</span>
</div>
</div>
</div>
// Variants:
.gk-gallery-sm // Smaller thumbnails (100px min)
.gk-gallery-lg // Larger thumbnails (220px min)
.gk-gallery-masonry // Pinterest layout (columns)
// Lightbox: arrow keys, Escape, click outside to close
// data-lazy: load images only when visibleA frame for a 9:16 video or picture — a short, a story, a phone screenshot. It keeps its shape, is never wider than its column and never taller than 75 % of the window, and shows the whole picture. gk-video-frame-safe draws the zones a platform covers with its own buttons (about the top tenth and the bottom fifth) as guide lines — they never catch a click, so the controls still work. Nothing to show yet, or it broke: gk-video-frame-busy and gk-video-frame-error reuse the empty state. No autoplay.
echo <<<'HTML'
<div class="demo-frames">
<figure class="gk-video-frame">
<div class="gk-video-frame-media">
<video controls playsinline preload="metadata" aria-label="Sample video, 3 seconds" src="media/sample-portrait.webm"></video>
</div>
<figcaption class="gk-video-frame-caption">Version 2 · 3 s</figcaption>
</figure>
<figure class="gk-video-frame gk-video-frame-safe">
<div class="gk-video-frame-media">
<video controls playsinline preload="metadata" aria-label="Sample video with the safe zones shown" src="media/sample-portrait.webm"></video>
</div>
<figcaption class="gk-video-frame-caption">Safe zones shown: top 10 %, bottom 20 %</figcaption>
</figure>
<figure class="gk-video-frame">
<div class="gk-video-frame-media">
<img src="media/sample-portrait.svg" alt="The first frame of the video: a blue field with a pale disc">
</div>
<figcaption class="gk-video-frame-caption">A picture shows in the same frame</figcaption>
</figure>
<figure class="gk-video-frame gk-video-frame-busy">
<div class="gk-video-frame-media">
<div class="gk-empty" role="status">
<div class="gk-empty-inner">
<span class="material-icons gk-empty-icon" aria-hidden="true">movie</span>
<div class="gk-empty-title">Video is being made</div>
<div class="gk-empty-hint">This takes a minute or two. You can leave the page.</div>
</div>
</div>
</div>
<figcaption class="gk-video-frame-caption">Version 3</figcaption>
</figure>
<figure class="gk-video-frame gk-video-frame-error">
<div class="gk-video-frame-media">
<div class="gk-empty">
<div class="gk-empty-inner">
<span class="material-icons gk-empty-icon" aria-hidden="true">error</span>
<div class="gk-empty-title">No video</div>
<div class="gk-empty-hint">The image service did not answer. Try again, or change the topic.</div>
</div>
</div>
</div>
<figcaption class="gk-video-frame-caption">Version 3 failed</figcaption>
</figure>
</div>
HTML;Landscape (1.131.0): gk-video-frame-landscape on the <figure> makes the same frame 16:9 — a recording, a film. It is as wide as its column until the 75 % limit of the window bites, then it keeps its shape; a portrait file in it is shown whole, not cut. Busy and failed work as in the 9:16 frame. One class on the figure, so a rule of your page with one class still wins.
echo <<<'HTML'
<div class="demo-frames">
<figure class="gk-video-frame gk-video-frame-landscape">
<div class="gk-video-frame-media">
<img src="media/sample-landscape.svg" alt="The first frame of the recording: a blue field with a pale disc">
</div>
<figcaption class="gk-video-frame-caption">A recording, 16:9</figcaption>
</figure>
<figure class="gk-video-frame gk-video-frame-landscape gk-video-frame-busy">
<div class="gk-video-frame-media">
<div class="gk-empty" role="status">
<div class="gk-empty-inner">
<span class="material-icons gk-empty-icon" aria-hidden="true">movie</span>
<div class="gk-empty-title">Video is being made</div>
<div class="gk-empty-hint">This takes a minute or two.</div>
</div>
</div>
</div>
<figcaption class="gk-video-frame-caption">Version 3</figcaption>
</figure>
</div>
HTML;System-wide quick search. GridKit provides the widget only —
WHAT is searched is decided by your backend endpoint. Opens with
Ctrl+K (Cmd+K on Mac) or any element
carrying data-gk-search. Arrow keys select, Enter opens, Escape closes.
On this page Ctrl+K belongs to the command palette
(1.122.0), which reads the same JSON and searches the pages and commands as well; the button
below still opens this search.
GK.search.init({
url: '/demo/api/quicksearch.php',
hotkey: 'ctrl+k',
minLength: 0
});
// Server response. The German key names — gruppen / titel / treffer /
// untertitel / betrag — are still read as a fallback, but this is the shape:
{ "groups": [
{ "title": "Transactions",
"items": [
{ "title": "Hetzner",
"subtitle": "Jul 7, 2026",
"amount": "€64.80",
"url": "/transactions/2",
"icon": "account_balance" } ] } ] }Toast notifications for success, error and info messages. Disappear after 3 seconds.
GK.toast.success('Successfully saved!');
GK.toast.error('Error while saving!');
GK.toast.warning('Warning: Limit reached!');
GK.toast.info('3 new entries');A toast is for the corner; this line says "Saved." where the person is working, and a screen reader reads it. The region is on the page from the start and never hidden — empty, it draws no box. GK.announce() changes only its words, and the same words twice are read twice.
echo <<<'HTML'
<div class="demo-announce-row">
<button type="button" class="gk-btn gk-btn-filled gk-btn-primary" data-demo-announce="Saved." data-tone="success">Save</button>
<button type="button" class="gk-btn gk-btn-outlined gk-btn-danger" data-demo-announce="Could not save — the connection dropped." data-tone="error">Fail</button>
<button type="button" class="gk-btn gk-btn-text gk-btn-neutral" data-demo-announce="">Clear</button>
</div>
<div class="gk-message gk-message-compact gk-announce" id="demo-announce" role="status" aria-live="polite" aria-atomic="true"></div>
<script>
document.addEventListener('click', function (e) {
var b = e.target.closest('[data-demo-announce]');
if (b) GK.announce('demo-announce', b.getAttribute('data-demo-announce'), b.getAttribute('data-tone'));
});
</script>
HTML;A log of steps, one under the other: what ran, in which order, how each step ended. A real ordered list, so the order is the information; each state has its own symbol and a word beside the title, never a colour alone. Small chips carry cost or provider, a failed step shows its message as a block. The ring of the running step turns, and stands still when the person asked for less motion. Light and dark follow from the roles; long addresses break.
Three scenes, 38 words, ends with a question.
Picture 2 of 3.
The image service did not answer after 3 tries (https://example.org/api/v1/images/generate?scene=2&attempt=3, timeout after 30 s).
Needs the pictures.
echo <<<'HTML'
<div class="demo-timelines">
<div>
<h4>A run in progress</h4>
<ol class="gk-timeline" role="list" aria-label="Steps of the run in progress">
<li class="gk-timeline-step gk-timeline-ok">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Write the script</span>
<span class="gk-timeline-state">Done</span>
<span class="gk-timeline-time"><time datetime="2026-10-17T09:12:03">09:12:03</time> · 4.2 s</span>
</div>
<div class="gk-timeline-chips"><span class="gk-label gk-label-gray">Claude</span><span class="gk-label gk-label-gray">$0.03</span></div>
<p class="gk-timeline-detail">Three scenes, 38 words, ends with a question.</p>
</div>
</li>
<li class="gk-timeline-step gk-timeline-ok">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Record the voice</span>
<span class="gk-timeline-state">Done</span>
<span class="gk-timeline-time"><time datetime="2026-10-17T09:12:08">09:12:08</time> · 11 s</span>
</div>
<div class="gk-timeline-chips"><span class="gk-label gk-label-gray">Text to speech</span><span class="gk-label gk-label-gray">$0.11</span></div>
</div>
</li>
<li class="gk-timeline-step gk-timeline-running" aria-current="step">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Make the pictures</span>
<span class="gk-timeline-state">Running</span>
<span class="gk-timeline-time"><time datetime="2026-10-17T09:12:19">09:12:19</time> · 8 s so far</span>
</div>
<p class="gk-timeline-detail">Picture 2 of 3.</p>
</div>
</li>
<li class="gk-timeline-step gk-timeline-waiting">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Assemble the video</span>
<span class="gk-timeline-state">Waiting</span>
</div>
</div>
</li>
<li class="gk-timeline-step gk-timeline-waiting">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Check the safe zones</span>
<span class="gk-timeline-state">Waiting</span>
</div>
</div>
</li>
</ol>
</div>
<div>
<h4>A run that broke</h4>
<ol class="gk-timeline" role="list" aria-label="Steps of the run that broke">
<li class="gk-timeline-step gk-timeline-ok">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Write the script</span>
<span class="gk-timeline-state">Done</span>
<span class="gk-timeline-time"><time datetime="2026-10-17T10:40:11">10:40:11</time> · 3.9 s</span>
</div>
<div class="gk-timeline-chips"><span class="gk-label gk-label-gray">Claude</span><span class="gk-label gk-label-gray">$0.03</span></div>
</div>
</li>
<li class="gk-timeline-step gk-timeline-failed">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Make the pictures</span>
<span class="gk-timeline-state">Failed</span>
<span class="gk-timeline-time"><time datetime="2026-10-17T10:40:15">10:40:15</time> · 31 s</span>
</div>
<div class="gk-timeline-chips"><span class="gk-label gk-label-gray">Image service</span></div>
<p class="gk-timeline-error">The image service did not answer after 3 tries (https://example.org/api/v1/images/generate?scene=2&attempt=3, timeout after 30 s).</p>
</div>
</li>
<li class="gk-timeline-step gk-timeline-skipped">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Assemble the video</span>
<span class="gk-timeline-state">Skipped</span>
</div>
<p class="gk-timeline-detail">Needs the pictures.</p>
</div>
</li>
<li class="gk-timeline-step gk-timeline-skipped">
<span class="gk-timeline-marker" aria-hidden="true"></span>
<div class="gk-timeline-body">
<div class="gk-timeline-head">
<span class="gk-timeline-title">Check the safe zones</span>
<span class="gk-timeline-state">Skipped</span>
</div>
</div>
</li>
</ol>
</div>
</div>
HTML;Confirm dialogs as clean modals. Promise-based, with danger mode for destructive actions.
GK.confirm('Send invoice?', {
title: 'Send Invoice', confirmText: 'Send'
}).then(ok => { if (ok) GK.toast.success('Sent!'); });
GK.confirm('Really delete?', {
title: 'Delete', confirmText: 'Delete', danger: true
}).then(ok => { if (ok) { /* ... */ } });Modals in four sizes. Loaded via AJAX, backdrop click and ESC close them.
A modal loads a form via AJAX – the most common use case.
A large modal shows a customer list. Clicking "Edit" opens a second modal with the form.
GK.modal.open('Title', 'form/edit.php', {id: 42}, 'small');
GK.modal.open('Title', 'form/edit.php', {id: 42}, 'medium');
GK.modal.open('Title', 'form/edit.php', {id: 42}, 'large');
GK.modal.open('Title', 'form/edit.php', {id: 42}, 'full');
$table->button('edit', ['icon' => 'edit', 'modal' => 'edit_form'])
->modal('edit_form', 'Edit', 'form/edit.php', ['size' => 'large']);use GridKit\Button;
echo Button::render('Save', ['variant' => 'filled', 'color' => 'primary', 'icon' => 'save']);
echo Button::icon('edit', ['variant' => 'filled', 'color' => 'primary']);
echo Button::fab('add');
echo Button::fab('edit', ['extended' => true, 'label' => 'Edit']);Colored labels for status display — also usable standalone, not only in tables.
<span class="gk-label gk-label-green">Active</span> <span class="gk-label gk-label-orange">Draft</span> <span class="gk-label gk-label-red">Error</span> <span class="gk-label gk-label-gray">Archived</span> <span class="gk-label gk-label-blue">Info</span>
Tooltips appear automatically on buttons with a title attribute. Hover over the buttons:
// Tooltip via title attribute (CSS-only, no JS)
Button::icon('edit', ['title' => 'Edit']);
<button class="gk-btn" title="Tooltip-Text">...</button>Placeholder for empty tables or lists.
| Name | Status | |
|---|---|---|
inboxNo entries found | ||
<div class="gk-empty">No entries found</div>
Minimal (title + user with initials only)
$header = new Header();
echo $header->title('Invoices')
->breadcrumb(['Dashboard' => '/', 'Invoices'])
->search('Search...', 'q')
->action(Button::render('New', ['icon' => 'add', 'size' => 'sm']))
->user('Martin Huber', ['avatar' => '...', 'menu' => [...]])
->sticky()->render();"You are here": the dashboard and the module as links, the steps between, the page last and without a link. Only the page's title is shortened. Put it in a sticky() header — it wraps on a phone. Resize the window to see it.
On the dashboard itself
On the start page of a module
Deep in a module
A very long title
One row, for a header of fixed height (einzeilig)
The menu button with its word, for a first-time visitor
echo (new Header())
->sidebarToggle(true, ['label' => true, 'controls' => 'main-nav']) // "Menü" beside the symbol
->ortszeile([
'dashboard' => ['label' => 'Dashboard', 'href' => '/', 'icon' => 'home'], // the defaults
'modul' => ['label' => 'Billing', 'href' => '/faktura', 'icon' => 'receipt_long'],
'stufen' => ['Invoices' => '/faktura/rechnungen'],
'aktuell' => 'Invoice INV-2026-001', // the page: no link, aria-current="page"
])
->sticky()->render();
echo Layout::skipLink('#main'); // first in <body>; <main id="main" tabindex="-1">
(new Sidebar('main'))->elementId('main-nav') // the button's aria-controls
->brand('Panel', 'dashboard', 'v1', '/') // the brand as a link
->mobileClose() // a brand-less sidebar keeps its close button
->render();Responsive sidebar navigation with groups, icons, badges and mobile toggle. Visible live on this page.
$sidebar = new Sidebar('main');
$sidebar->brand('My Project', 'dashboard', 'v0.7.0')
->group('Modules')
->item('Dashboard', '/dashboard', 'analytics', ['active' => true])
->item('Invoices', '/invoices', 'receipt_long', ['badge' => 3])
->render();
GK.sidebar.toggle(); GK.sidebar.open(); GK.sidebar.close();M3-compliant theme system with 6 themes and Dark/Light Mode.
Surface-container background with on-surface text colors.
Theme::set('ocean', 'dark');
echo Theme::bodyTag('gk-root');
echo Theme::switcher();
GK.theme.set('forest'); GK.theme.toggleMode(); GK.theme.restore();
GK.theme.setMode('auto'); // 'light' | 'dark' | 'auto' — auto follows the system (1.114.0)ActionGroup::html() returns a row of small buttons in one go; render() prints it. An item with 'showIf' => false is left out, 'pill' rounds it, and an icon-only item needs 'title' for its name.
echo ActionGroup::html([
['icon' => 'edit', 'title' => 'Edit'],
['icon' => 'content_copy', 'title' => 'Duplicate'],
['label' => 'Archive', 'icon' => 'archive', 'variant' => 'tonal', 'color' => 'warning'],
['icon' => 'delete', 'title' => 'Delete', 'color' => 'danger', 'showIf' => false],
['label' => 'Send', 'icon' => 'send', 'variant' => 'filled', 'color' => 'primary', 'pill' => true],
]);echo '<div class="gk-flex gk-gap-md gk-items-center" style="flex-wrap:wrap">';
echo Button::render('Extra small', ['variant' => 'outlined', 'size' => 'xs']);
echo Button::render('Next', ['icon' => 'arrow_forward', 'iconPosition' => 'right', 'variant' => 'filled', 'color' => 'primary']);
echo Button::render('Page 3', ['variant' => 'tonal', 'data' => ['row' => 3], 'attrs' => ['aria-current' => 'page']]);
echo '</div>';
echo '<div class="gk-mt-2">' . Button::render('Full width', ['variant' => 'outlined', 'fullWidth' => true]) . '</div>';Every utility class on a small sample, generated from css/blocks.json, so a new class shows up here without anyone writing it twice. Spacing and size classes act on the sample's box, colours and type on its text.
gk-activegk-bg-danger-softgk-bg-mutedgk-bg-primary-softgk-bg-success-softgk-bg-surfacegk-bg-warning-softgk-blockgk-break-wordgk-clickablegk-codegk-disabledgk-flexgk-flex-1gk-flex-betweengk-flex-centergk-flex-colgk-flex-wrapgk-font-monogk-fs-2xlgk-fs-basegk-fs-lggk-fs-mdgk-fs-smgk-fs-xlgk-fs-xsgk-fw-boldgk-fw-mediumgk-fw-normalgk-fw-semiboldgk-gap-2xlgk-gap-lggk-gap-mdgk-gap-smgk-gap-xlgk-gap-xsgk-gridgk-grid-2gk-grid-4gk-h-autogk-h-fullgk-hiddengk-hide-mobilegk-inlinegk-inline-blockgk-inline-flexgk-items-baselinegk-items-centergk-items-endgk-items-startgk-justify-betweengk-justify-centergk-justify-endgk-justify-startgk-m-0gk-m-1gk-m-2gk-m-3gk-m-4gk-m-5gk-m-6gk-mb-0gk-mb-1gk-mb-2gk-mb-3gk-mb-4gk-mb-5gk-mb-6gk-ml-0gk-ml-1gk-ml-2gk-ml-3gk-ml-4gk-ml-autogk-mr-0gk-mr-1gk-mr-2gk-mr-3gk-mr-4gk-mr-autogk-mt-0gk-mt-1gk-mt-2gk-mt-3gk-mt-4gk-mt-5gk-mt-6gk-mx-autogk-no-decorationgk-not-clickablegk-nowrapgk-overflow-x-autogk-overflow-y-autogk-p-0gk-p-1gk-p-2gk-p-3gk-p-4gk-p-5gk-p-6gk-px-0gk-px-1gk-px-2gk-px-3gk-px-4gk-px-5gk-px-6gk-py-0gk-py-1gk-py-2gk-py-3gk-py-4gk-py-5gk-py-6gk-rounded-fullgk-rounded-lggk-rounded-mdgk-rounded-nonegk-rounded-smgk-rounded-xlgk-show-mobilegk-spacergk-spacer-lggk-spacer-mdgk-spacer-smgk-spacer-xlgk-sr-onlygk-text-centergk-text-dangergk-text-leftgk-text-mutedgk-text-on-surfacegk-text-primarygk-text-rightgk-text-successgk-text-warninggk-truncategk-w-autogk-w-full
Everything below this box is a gallery — it shows what exists. If you would
rather see what it is for, examples/invoices/ is a
working invoice manager: create, edit, delete, with search, filter, sort and
paging answered by the server. About 300 lines, no database.
| Amount | Date | Status | ||
|---|---|---|---|---|
| RE-2026-001 | Mustermann GmbH | €2,400.00 | paid | |
| RE-2026-002 | Technik AG | €5,800.00 | pending | |
| RE-2026-003 | Design Studio | €1,200.00 | overdue | |
| RE-2026-004 | Web Solutions | €3,600.00 | paid | |
| RE-2026-005 | Media House | €950.00 | pending |
skeleton.php is the ready-made scaffolding for a new GridKit project. Just copy, adjust title + navigation, fill in sections — done.
cp /path/to/gridkit/skeleton.php my-project/index.php
Every page follows this structure — from skeleton.php to production.
Theme::set('indigo') · Layout::bodyTag('gk-root')
->brand() · ->group() · ->item(label, url, icon)
->title() · ->fixed() · ->user(name, opts)
<main class="gk-main"> · Tables, Forms, Cards…
<script src="gridkit.js">
Auth protects pages with session-based login. Passwords are stored as bcrypt hashes.
One engine for every tooltip: it places the bubble on the side you ask for, flips it when there is no room, shifts it along the edge to stay inside the window (and inside a box that scrolls) and keeps the arrow on its trigger. Hover opens it after a short delay, keyboard focus at once, a tap on touch; Escape, blur, scrolling away and the pointer leaving close it. A screen reader hears the text as the trigger's description. Without the script the CSS-only tooltip is what it always was.
Each trigger in the box below asks for a side it has no room on, at the edge of a box that scrolls: the bubble flips to the other side or slides along the edge, and the arrow still points at the word. Scroll the box — the bubble follows, and closes when its trigger leaves the visible part. auto takes above or below, whichever has more room.
$spot = static fn (string $where, string $label, string $text, string $pos): string =>
'<span class="demo-tt-spot" style="' . $where . '"' . Tooltip::attrs($text, ['pos' => $pos]) . '>' . $label . '</span>';
echo '<div class="demo-tt-box"><div class="demo-tt-inner">'
. $spot('top:6px;left:40%', 'top → flips', 'Asked for top — no room, so below', 'top')
. $spot('top:64px;left:6px', 'left → flips', 'Asked for left — no room, so right', 'left')
. $spot('top:64px;right:6px', 'right → flips', 'Asked for right, at the right edge — so left', 'right')
. $spot('top:112px;right:6px', 'top, shifted', 'A long text at the right edge: shifted left, the arrow stays on the word', 'top')
. $spot('top:160px;left:40%', 'auto', 'auto: above or below, whichever has more room', 'auto')
. $spot('top:380px;left:30%', 'further down', 'Scroll the box: this one follows its trigger', 'bottom')
. '</div></div>';Six tones, each at 4.5:1 or more in light and dark mode, under every theme. kbd adds a key after the text, max narrows the bubble, delay sets the wait on hover (0 opens at once).
echo '<div class="demo-tt-row">';
foreach (['neutral', 'info', 'success', 'warning', 'danger', 'light'] as $tone) {
echo '<span class="demo-tt-chip"' . Tooltip::attrs(ucfirst($tone) . ' tone', ['tone' => $tone]) . '>' . $tone . '</span>';
}
echo '</div><div class="demo-tt-row">';
echo Button::render('Save', ['icon' => 'save', 'tooltip' => ['text' => 'Saves the draft', 'kbd' => 'Ctrl+S']]);
echo '<span class="demo-tt-chip"' . Tooltip::attrs('A long explanation that would run wide is kept to 160 pixels and wraps', ['max' => 160]) . '>max 160</span>';
echo '<span class="demo-tt-chip"' . Tooltip::attrs('Opens at once', ['delay' => 0]) . '>delay 0</span>';
echo '<span class="demo-tt-chip"' . Tooltip::attrs('Took its time', ['delay' => 1000]) . '>delay 1000</span>';
echo '</div>';A toggletip opens on a click, Enter or Space — not on hover — and stays open, so it can hold a link or a button. Its text is read out; the focus stays on the trigger, and Tab walks into its links. Escape, a click outside or a second click close it. Tooltip::help() is the ready-made "?" (24px, 44px to a finger), named after what it explains.
echo '<div class="demo-tt-row">';
echo '<span>VAT ' . Tooltip::help('Reduced rate of 10 % for food and books.', ['label' => 'VAT']) . '</span>';
echo '<span>IBAN ' . Tooltip::help('#demo-iban-help', ['label' => 'IBAN', 'icon' => 'info']) . '</span>';
echo '<button type="button" class="gk-btn gk-btn-outlined gk-btn-neutral"'
. Tooltip::toggletip('Counted from the invoice date, not from delivery.', ['tone' => 'info', 'pos' => 'bottom']) . '>Why 14 days?</button>';
echo '</div>';
echo '<div id="demo-iban-help" hidden>On your bank card and statement. <a href="#tooltip">Where to find it</a></div>';'tooltip' on a button and on a table's row button replaces the browser's title — never both, and a description, not the name. On a table column it is a help icon beside the label (the sort button still sorts); 'help' on a form field puts one beside the label. All of it survives a sort of a setData() table.
| Actions | ||
|---|---|---|
| Mustermann GmbH | €1,450.00 | |
| Weber & Partner | €890.50 |
echo '<p>' . Button::icon('delete', ['color' => 'danger', 'tooltip' => ['text' => 'Deletes the invoice for good', 'tone' => 'danger']]) . '</p>';
(new Table('demo-tooltip-table'))
->setData([
['id' => 1, 'customer' => 'Mustermann GmbH', 'net' => 1450.00],
['id' => 2, 'customer' => 'Weber & Partner', 'net' => 890.50],
])
->column('customer', 'Customer', ['sortable' => true, 'tooltip' => 'As on the contract'])
->column('net', 'Net', ['format' => 'currency', 'align' => 'right', 'sortable' => true,
'tooltip' => ['text' => 'Before VAT', 'tone' => 'info']])
->button('edit', ['icon' => 'edit', 'tooltip' => 'Edit this customer'])
->caption('Customers with tooltips')
->render();
(new Form('demo-tooltip-form'))
->field('iban', 'IBAN', 'text', ['help' => 'On your bank card.'])
->field('terms', 'I accept the terms', 'checkbox', ['help' => 'They fit on one page.'])
->render();Any title gets the same bubble (GK.tip; opt out with data-gk-tip-off). data-gk-tooltip is the plain form by hand; data-gk-tooltip-rich shows an element with HTML in it, and the pointer can move into it.
Real HTML: formatting, and a link the pointer can reach.
echo <<<'HTML'
<div class="demo-tt-row">
<span class="demo-tt-chip" title="Upgraded automatically — just use title">title</span>
<span class="demo-tt-chip" title="First line Second line (\n breaks)">title, two lines</span>
<span data-gk-tip-off><span class="demo-tt-chip" title="This one is the browser's own">opt-out</span></span>
<span class="demo-tt-chip" data-gk-tooltip="Plain, by hand" data-gk-tooltip-pos="bottom">plain</span>
<span class="demo-tt-chip" data-gk-tooltip="Several lines when the text is long enough to need them" data-gk-tooltip-wrap>wrap</span>
<span class="demo-tt-chip" data-gk-tooltip-rich="#richTip1">rich</span>
</div>
<div id="richTip1"><strong>GridKit Tooltip</strong>
<p style="margin:6px 0 4px">Real HTML: formatting, and <a href="#tooltip">a link</a> the pointer can reach.</p>
</div>
HTML;PermissionMatrix puts roles in columns and permissions in rows, grouped by module. It is a plain form first: every cell posts perm[role][permission] as 0 or 1, and read() on the server gives it back as role → permission → true/false. With the script: Support and Editor inherit Guest (ticked "via Guest", changed in Guest's column), Admin is locked, ticking "Publish pages" ticks what it needs and unticking "View pages" unticks what needs it. Tick a whole row, column or group; filter; fold a module; changed cells keep a dot until saved. One tab stop — the arrow keys move between cells, Space toggles. On a phone it shows one role at a time.
$rights = static fn (array $grants): PermissionMatrix => (new PermissionMatrix('rights'))
->caption('Roles and rights')
->role('admin', 'Admin', ['locked' => true, 'color' => 'red', 'description' => 'Owner of the installation'])
->role('accounting', 'Accounting', ['color' => 'green', 'description' => 'Invoices and payments'])
->role('editor', 'Editor', ['parent' => 'guest', 'color' => 'blue', 'description' => 'Pages and newsletters'])
->role('support', 'Support', ['parent' => 'guest', 'color' => 'orange', 'description' => 'Answers customers'])
->role('guest', 'Guest', ['color' => 'gray', 'description' => 'Reads, changes nothing'])
->group('invoices', 'Invoices')
->permission('invoices.view', 'View invoices')
->permission('invoices.edit', 'Create and edit invoices', ['requires' => 'invoices.view'])
->permission('invoices.send', 'Send invoices to customers', ['requires' => 'invoices.view'])
->permission('invoices.cancel', 'Cancel invoices', ['requires' => 'invoices.edit', 'danger' => true,
'description' => 'Writes a credit note; the invoice stays on record.'])
->permission('invoices.delete', 'Delete invoices', ['requires' => 'invoices.edit', 'danger' => true,
'description' => 'Invoices have to be kept for seven years.'])
->group('customers', 'Customers')
->permission('customers.view', 'View customers')
->permission('customers.edit', 'Edit customer data', ['requires' => 'customers.view'])
->permission('customers.export', 'Export the customer list', ['requires' => 'customers.view', 'danger' => true,
'description' => 'Personal data leaves the system as a CSV file.'])
->group('newsletter', 'Newsletter')
->permission('newsletter.view', 'View campaigns and lists')
->permission('newsletter.write', 'Write campaigns', ['requires' => 'newsletter.view'])
->permission('newsletter.send', 'Send to subscribers', ['requires' => 'newsletter.write', 'danger' => true])
->permission('newsletter.lists', 'Manage recipient lists', ['requires' => 'newsletter.view'])
->group('cms', 'CMS pages')
->permission('cms.view', 'View pages and drafts')
->permission('cms.edit', 'Edit pages', ['requires' => 'cms.view'])
->permission('cms.publish', 'Publish pages', ['requires' => 'cms.edit'])
->permission('cms.media', 'Upload images and files', ['requires' => 'cms.view'])
->group('users', 'Users & rights', ['collapsed' => true])
->permission('users.view', 'View users')
->permission('users.edit', 'Create and edit users', ['requires' => 'users.view', 'danger' => true])
->permission('users.roles', 'Change roles and rights', ['requires' => 'users.edit', 'danger' => true])
->permission('users.impersonate', 'Sign in as another user', ['requires' => 'users.view', 'danger' => true])
->grants($grants);
$stored = [ // what your database holds
'accounting' => ['invoices.view', 'invoices.edit', 'invoices.send', 'invoices.cancel',
'customers.view', 'customers.edit', 'customers.export'],
'editor' => ['cms.edit', 'cms.publish', 'cms.media', 'newsletter.write'],
'support' => ['customers.edit', 'invoices.view', 'invoices.send'],
'guest' => ['customers.view', 'newsletter.view', 'cms.view'],
];
if (isset($_POST['perm'])) {
// role => permission => bool for every posted cell; what a ticked right needs is added.
foreach ($rights($stored)->read($_POST['perm']) as $role => $cells) {
$stored[$role] = array_keys(array_filter($cells)); // … write it to your database here
}
$saved = [];
foreach ($stored as $role => $list) $saved[] = $role . ': ' . (implode(', ', $list) ?: '—');
echo '<p class="gk-message gk-message-success" role="status" style="overflow-wrap:anywhere">Read back and saved — '
. htmlspecialchars(implode(' · ', $saved), ENT_QUOTES) . '</p>';
}
echo '<form method="post" action="#permissions">';
$rights($stored)->render();
echo '<div class="demo-btn-row" style="margin-top:12px">'
. Button::render('Save rights', ['type' => 'submit', 'icon' => 'check'])
. '</div></form>';Every change fires gk:permchange — the last one: nothing yet.
// The form posts every cell: a hidden "0", and the checkbox's "1" when it is ticked.
// perm[editor][cms.publish] = 1 perm[editor][cms.media] = 0 (Admin, locked: nothing)
// Build the matrix as for the page, then:
$map = $matrix->read($_POST['perm'] ?? []); // ['editor' => ['cms.publish' => true, 'cms.media' => false, …], …]
// Without the definition at hand — only roles and keys you allow, only 0/1/true/false:
$map = PermissionMatrix::fromPost($_POST['perm'] ?? [], ['editor', 'guest'], ['cms.view', 'cms.edit']);
foreach ($map as $role => $cells) {
foreach ($cells as $permission => $granted) {
$granted ? $db->grant($role, $permission) : $db->revoke($role, $permission);
}
}saveUrl() posts each change as JSON — {"matrix":"pages","changes":{"author":{"cms.publish":true}}} — and expects {"ok":true}. This demo's endpoint refuses to grant "Delete pages": the box goes back and a toast says why. Author inherits Contributor; the matrix is height('260px'), so its head stays in view while it scrolls.
| Permission | All roles | Editor3 of 4 | AuthorInherits Contributor1 of 4 | Contributor1 of 4 |
|---|---|---|---|---|
| CMS pages4 | ||||
| View pages | via Contributor | |||
| Edit pagesNeeds: View pages | ||||
| Publish pagesNeeds: Edit pages | ||||
| Delete pages RiskyNeeds: Edit pages |
No permission matches this filter.
(new PermissionMatrix('pages'))
->caption('Page rights')
->role('editor', 'Editor')
->role('author', 'Author', ['parent' => 'contributor'])
->role('contributor', 'Contributor')
->group('cms', 'CMS pages')
->permission('cms.view', 'View pages')
->permission('cms.edit', 'Edit pages', ['requires' => 'cms.view'])
->permission('cms.publish', 'Publish pages', ['requires' => 'cms.edit'])
->permission('cms.delete', 'Delete pages', ['requires' => 'cms.edit', 'danger' => true])
->grants(['editor' => ['cms.view', 'cms.edit', 'cms.publish'], 'contributor' => ['cms.view']])
->saveUrl('api/permissions.php') // + ['headers' => ['X-CSRF-Token' => $token]]
->height('260px')
->render();readonly() shows who may do what and posts nothing. Filter and folding stay; the cells can still be reached with the arrow keys and say what they are.
| Permission | SupportInherits Guest2 of 2 | Guest1 of 2 |
|---|---|---|
| Customers2 | ||
| View customers | via Guest | |
| Edit customer dataNeeds: View customers |
No permission matches this filter.
(new PermissionMatrix('rights-view'))
->caption('Rights of the support team')
->role('support', 'Support', ['parent' => 'guest'])
->role('guest', 'Guest')
->group('customers', 'Customers')
->permission('customers.view', 'View customers')
->permission('customers.edit', 'Edit customer data', ['requires' => 'customers.view'])
->grants(['guest' => ['customers.view'], 'support' => ['customers.edit']])
->readonly()
->render();Page trees, categories, folders. GridKit\Tree writes a nested list that works without any script — a link is followed, a ticked box is posted. js/tree.js makes it a tree view: the arrow keys, Home and End, *, type-ahead, open and closed remembered per tree, a filter, children loaded when a node is first opened, and moving by drag and drop or by keyboard, saved to a URL and given back when the save fails.
Tab into the tree: ↑ ↓ walk, → opens or goes in, ← closes or goes up, a letter jumps, Enter follows the link, Space selects. Tab from a page reaches its buttons and its handle: Space lifts the page, the arrows move it (→ into the page above, ← out of its parent), Space puts it down, Esc cancels — or drag the handle. Every move is posted to api/tree-move.php, which refuses one on purpose: nothing takes Home's place at the top, so the page goes back and a toast says why. Blog loads its years and posts from api/tree-children.php; Archive fails on purpose; Legal is disabled and takes no pages.
$pages = [
['id' => 'home', 'parent_id' => null, 'title' => 'Home', 'icon' => 'home', 'draggable' => false],
['id' => 'about', 'parent_id' => null, 'title' => 'About us', 'icon' => 'folder'],
['id' => 'team', 'parent_id' => 'about', 'title' => 'Team', 'icon' => 'description'],
['id' => 'history', 'parent_id' => 'about', 'title' => 'History', 'icon' => 'description', 'muted' => 'unpublished'],
['id' => 'services', 'parent_id' => null, 'title' => 'Services', 'icon' => 'folder', 'expanded' => true],
['id' => 'web', 'parent_id' => 'services', 'title' => 'Web design', 'icon' => 'description', 'badge' => ['text' => 'New', 'color' => 'green']],
['id' => 'hosting', 'parent_id' => 'services', 'title' => 'Hosting', 'icon' => 'description'],
['id' => 'seo', 'parent_id' => 'services', 'title' => 'Search engine optimisation for small and medium-sized businesses', 'icon' => 'description'],
['id' => 'blog', 'parent_id' => null, 'title' => 'Blog', 'icon' => 'folder', 'children' => 'lazy', 'count' => 5],
['id' => 'archive', 'parent_id' => null, 'title' => 'Archive', 'icon' => 'inventory_2', 'children' => 'lazy'],
['id' => 'contact', 'parent_id' => null, 'title' => 'Contact', 'icon' => 'description'],
['id' => 'legal', 'parent_id' => null, 'title' => 'Legal', 'icon' => 'gavel', 'disabled' => true, 'badge' => 'Locked'],
['id' => 'imprint', 'parent_id' => 'legal', 'title' => 'Imprint', 'icon' => 'description'],
['id' => 'privacy', 'parent_id' => 'legal', 'title' => 'Privacy', 'icon' => 'description'],
];
foreach ($pages as &$page) $page['href'] = '#tree-page-' . $page['id'];
unset($page);
(new Tree('demo-pages'))
->label('Pages')
->nodes($pages)
->select('single')->name('page')->selected(['hosting'])
->expandTo('team')
->searchable()
->lazyUrl('api/tree-children.php')
->moveUrl('api/tree-move.php', ['headers' => ['X-CSRF-Token' => 'demo-token']])
->actions(fn (array $n): array => [
['icon' => 'edit', 'title' => 'Edit', 'href' => '#tree-edit-' . $n['id']],
['icon' => 'add', 'title' => 'Add a page below', 'href' => '#tree-add-' . $n['id']],
])
->render();Events appear here.
<?php
/**
* The lazy branches of the demo's page tree (GridKit\Tree::lazyUrl(), 1.116.0).
*
* js/tree.js asks GET tree-children.php?parent=<id> the first time a node with
* 'children' => 'lazy' is opened, and puts the <li> of the answer into the node.
* This file is that answer: the rows of one parent, written by renderBranch() on
* a tree configured as on the page — same id, selection, name and buttons — so the
* children look and post like their neighbours. A real endpoint reads the rows from
* its database; nothing else changes.
*/
declare(strict_types=1);
require_once __DIR__ . '/../../autoload.php';
use GridKit\{Lang, Tree};
$lang = $_GET['lang'] ?? $_COOKIE['gk_lang'] ?? 'en';
Lang::set(in_array($lang, ['en', 'de'], true) ? $lang : 'en');
$parent = is_string($_GET['parent'] ?? null) ? $_GET['parent'] : '';
// A moment of latency, so the demo shows the ring that turns in the chevron.
usleep(450000);
// One branch fails on purpose: the node closes again, its row says so and offers "Try again".
if ($parent === 'archive') {
http_response_code(503);
header('Content-Type: text/plain; charset=utf-8');
echo 'The archive server is asleep (on purpose, in this demo).';
exit;
}
$rows = [
'blog' => [
['id' => 'blog-2026', 'title' => '2026', 'icon' => 'folder', 'children' => 'lazy', 'count' => 3],
['id' => 'blog-2025', 'title' => '2025', 'icon' => 'folder', 'children' => 'lazy', 'count' => 2],
],
'blog-2026' => [
['id' => 'post-spring', 'title' => 'Spring sale: 20% on all hosting plans', 'icon' => 'article'],
['id' => 'post-office', 'title' => 'Our new office in Graz', 'icon' => 'article'],
['id' => 'post-green', 'title' => 'Hosting moves to green power — what changes for you and your websites', 'icon' => 'article', 'muted' => 'draft'],
],
'blog-2025' => [
['id' => 'post-ten', 'title' => 'Ten years of web design', 'icon' => 'article'],
['id' => 'post-seo', 'title' => 'Five SEO myths', 'icon' => 'article'],
],
][$parent] ?? [];
foreach ($rows as &$row) {
$row['parent_id'] = $parent;
$row['href'] = '#tree-page-' . $row['id'];
}
unset($row);
header('Content-Type: text/html; charset=utf-8');
(new Tree('demo-pages'))
->select('single')->name('page')
->actions(static fn (array $n): array => [
['icon' => 'edit', 'title' => 'Edit', 'href' => '#tree-edit-' . $n['id']],
['icon' => 'add', 'title' => 'Add a page below', 'href' => '#tree-add-' . $n['id']],
])
->nodes($rows)
->renderBranch($parent);
<?php
/**
* The move endpoint of the demo's page tree (GridKit\Tree::moveUrl(), 1.116.0).
*
* js/tree.js posts every move as JSON {"id", "parent", "index"} — parent null for the
* top level, index counted from 0 among the new siblings — with the headers given to
* moveUrl(). A 2xx is saved unless the JSON says {"ok": false}; anything else puts the
* node back, and "message" is what the person reads.
*
* The demo stores nothing (a reload shows the tree as it was) and refuses one move on
* purpose, so the way back can be seen: nothing may take the place of Home at the top.
*/
declare(strict_types=1);
header('Content-Type: application/json; charset=utf-8');
$answer = static function (int $status, array $body): never {
http_response_code($status);
echo json_encode($body, JSON_UNESCAPED_UNICODE);
exit;
};
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
$answer(405, ['ok' => false, 'message' => 'Moves are posted.']);
}
// The token the page gave moveUrl() in 'headers'. A real application compares it with the session's.
if (($_SERVER['HTTP_X_CSRF_TOKEN'] ?? '') !== 'demo-token') {
$answer(403, ['ok' => false, 'message' => 'The page is out of date. Reload it and try again.']);
}
$move = json_decode((string) file_get_contents('php://input'), true);
$id = is_array($move) && is_scalar($move['id'] ?? null) ? (string) $move['id'] : '';
$parent = is_array($move) && array_key_exists('parent', $move) ? $move['parent'] : false;
$index = is_array($move) ? filter_var($move['index'] ?? null, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]) : false;
if ($id === '' || $index === false || !($parent === null || is_string($parent))) {
$answer(400, ['ok' => false, 'message' => 'The move could not be read.']);
}
if ($parent === null && $index === 0 && $id !== 'home') {
$answer(409, ['ok' => false, 'message' => 'Home stays at the top — the page went back to its place.']);
}
usleep(250000);
$answer(200, ['ok' => true]);
With select('multi') every node has a box. A ticked parent ticks its branch (but not a disabled node in it); a parent with some of its children ticked is mixed. The form posts categories[]=id for every ticked node — with or without the script. Vinyl starts selected.
echo '<form id="demo-tree-form" action="#tree" method="post">';
(new Tree('demo-cats'))
->label('Categories')
->select('multi')->name('categories')->selected(['books', 'vinyl'])
->searchable()
->nodes([
['id' => 'books', 'title' => 'Books', 'children' => [
['id' => 'novels', 'title' => 'Novels', 'count' => 214],
['id' => 'poetry', 'title' => 'Poetry', 'count' => 38],
['id' => 'rare', 'title' => 'Rare editions', 'disabled' => true, 'badge' => ['text' => 'Sold out', 'color' => 'red']],
]],
['id' => 'music', 'title' => 'Music', 'expanded' => true, 'children' => [
['id' => 'cds', 'title' => 'CDs', 'count' => 120],
['id' => 'vinyl', 'title' => 'Vinyl', 'count' => 64],
['id' => 'tapes', 'title' => 'Tapes', 'count' => 9, 'muted' => 'hidden in the shop'],
]],
['id' => 'games', 'title' => 'Games', 'children' => [
['id' => 'board', 'title' => 'Board games'],
['id' => 'puzzles', 'title' => 'Puzzles'],
]],
])
->render();
echo '<p><button type="submit" class="gk-btn gk-btn-filled gk-btn-primary">Save categories</button></p></form>';movable() without moveUrl(): the tree fires the cancelable gk:treemove and the page saves (or not) on its own. This page refuses to put anything into Trash by dragging. The chain under Projects is ten levels deep: the indent stops after eight (five on a phone) and a small number shows the level.
(new Tree('demo-folders'))
->label('Folders')
->movable()
->toolbar(false)
->node('inbox', 'Inbox', null, ['icon' => 'inbox', 'count' => 12, 'expanded' => true])
->node('clients', 'Clients', 'inbox', ['icon' => 'folder'])
->node('offers', 'Offers', 'inbox', ['icon' => 'folder'])
->node('projects', 'Projects', null, ['icon' => 'folder'])
->node('relaunch', 'Website relaunch', 'projects', ['icon' => 'folder'])
->node('design', 'Design', 'relaunch', ['icon' => 'folder'])
->node('drafts', 'Drafts', 'design', ['icon' => 'folder'])
->node('round2', 'Round 2', 'drafts', ['icon' => 'folder'])
->node('mobile', 'Mobile', 'round2', ['icon' => 'folder'])
->node('header', 'Header', 'mobile', ['icon' => 'folder'])
->node('logo', 'Logo', 'header', ['icon' => 'folder'])
->node('variants', 'Variants', 'logo', ['icon' => 'folder'])
->node('final', 'Final', 'variants', ['icon' => 'image'])
->node('trash', 'Trash', null, ['icon' => 'delete', 'draggable' => false])
->expandTo('final')
->render();The lines of an invoice, an offer or an order: GridKit\LineItems. Every field posts
name[i][field] in the order on the screen; the totals — subtotal, discount, shipping, one VAT line
per rate, the total — follow every keystroke, and LineItems::totals() computes the very same figures
in PHP, to the cent: integers all the way, no float. Lines are added (the button, or Enter in the last field),
duplicated, deleted with Undo, and put in order by the handle — mouse, finger or Space and the arrow keys.
Narrower than 56rem, every line is a card.
VAT 20 % and 10 %, a discount on one line, 3 % off everything, shipping, euros with a
decimal comma. Type 1234,5, 1.234,50 or 1 234,50 — it is read the same,
and written back as the page writes it.
(new LineItems('invoice'))
->invoiceColumns() // description, qty, unit, unit price, discount %, VAT, amount
->locale('de') // numbers with a decimal comma
->currency('EUR')
->vatRates([20, 10, 13, 0])
->discount(3) // 3 % off everything, with its own field
->shipping('4.90') // shipping, under the highest rate of the lines
->limits(1, 30)
->items([
['id' => 41, 'description' => "Website relaunch\nDesign, templates, three rounds of changes",
'qty' => 1, 'unit' => 'flat', 'price' => '2400', 'discount' => 5, 'vat' => 20],
['id' => 42, 'description' => 'Web hosting, annual', 'qty' => 12, 'unit' => 'month', 'price' => 19.9, 'vat' => 20],
['id' => 43, 'description' => 'Handbook (print)', 'qty' => 3, 'unit' => 'pcs', 'price' => '34.50', 'vat' => 10],
])
->render();What the page hears — gk:lineitemschange, its
detail.totals:
Change a figure above.
What the editor above posts as it was first drawn, read back with parse(): the
lines in machine form, the messages keyed like the POST, and the totals — computed here, never taken from the
browser. They are the figures under the lines above.
{
"net": "2548.53",
"vat": [
{
"rate": "20",
"base": "2448.14",
"amount": "489.63"
},
{
"rate": "10",
"base": "100.39",
"amount": "10.04"
}
],
"gross": "3048.20",
"errors": []
}$lines = (new LineItems('invoice'))->invoiceColumns()->locale('de')->vatRates([20, 10, 13, 0])
->discount(0)->shipping(0);
$in = $lines->parse([
'invoice' => [
['id' => '41', 'description' => "Website relaunch\nDesign, templates, three rounds of changes",
'qty' => '1', 'unit' => 'flat', 'price' => '2.400,00', 'discount' => '5', 'vat' => '20'],
['id' => '42', 'description' => 'Web hosting, annual', 'qty' => '12', 'unit' => 'month',
'price' => '19,90', 'discount' => '', 'vat' => '20'],
['id' => '43', 'description' => 'Handbook (print)', 'qty' => '3', 'unit' => 'pcs',
'price' => '34,50', 'discount' => '', 'vat' => '10'],
],
'invoice_discount' => '3',
'invoice_shipping' => '4,90',
]);
$t = $in['totals'];
echo '<pre class="demo-log">' . htmlspecialchars(json_encode([
'net' => $t['net'], 'vat' => $t['vat'], 'gross' => $t['gross'], 'errors' => $in['errors'],
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)) . '</pre>';The same invoice once it has gone out: the same columns and grid, the figures as text — no field, no button, no handle, nothing that posts.
(new LineItems('sent'))->invoiceColumns()->locale('de')->vatRates([20, 10])->discount(3)->shipping('4.90')
->items([
['description' => "Website relaunch\nDesign, templates, three rounds of changes",
'qty' => 1, 'unit' => 'flat', 'price' => '2400', 'discount' => 5, 'vat' => 20],
['description' => 'Web hosting, annual', 'qty' => 12, 'unit' => 'month', 'price' => 19.9, 'vat' => 20],
['description' => 'Handbook (print)', 'qty' => 3, 'unit' => 'pcs', 'price' => '34.50', 'vat' => 10],
])
->readonly()
->render();A column of type lookup asks api/articles.php as you type (try
"hand" or "hosting"); picking an article fills description, unit, price and VAT. The editor is a field of a
Form here — 'lineitems', named by its label; an AJAX answer
{"errors": {"order[1][qty]": "…"}} lands under that very cell. Gross prices this time.
$lines = (new LineItems('order'))
->column('article', 'Article', ['type' => 'lookup', 'url' => 'api/articles.php', 'minChars' => 1,
'subtextField' => 'number', 'display' => 'article_name',
'fill' => ['description' => 'name', 'unit' => 'unit', 'price' => 'price', 'vat' => 'vat']])
->column('description', 'Description', ['type' => 'text', 'required' => true])
->column('qty', 'Qty', ['type' => 'number', 'required' => true, 'default' => '1'])
->column('unit', 'Unit', ['type' => 'select'])
->column('price', '', ['type' => 'money', 'required' => true])
->column('vat', 'VAT', ['type' => 'select'])
->column('total', 'Amount', ['type' => 'computed'])
->pricesNet(false)
->vatRates([20, 10])
->limits(1);
(new Form('order_form'))
->field('customer', 'Customer', 'text', ['width' => 8])
->field('order', 'Order lines', 'lineitems', ['lines' => $lines])
->render();Recipients, customers, articles from a CSV file: GridKit\Import. The fields are defined in PHP; the columns of the file are matched to them by name and alias (case, umlauts and spaces do not count), and every cell is checked by its field's type — e-mail, number and amount in German or English notation, a date as 31.12.2026, 2026-12-31 or 31/12/2026, yes or no, one of a list — as well as required fields and values that must be unique in the file. The separator, the quotation mark, the header row and the encoding (UTF-8, or Windows-1252 as German Excel writes it) are found by themselves. Without script it is a form in three steps; js/import.js reads the file in the browser, so the preview is there the moment a file is chosen, dropped or pasted, and follows every change of the mapping. Either way the server reads and checks the file again before it hands over a row.
Choose or drop a file, paste its text — or take the sample: kunden.csv, as German Excel saves it (semicolons, Windows-1252, a decimal comma, a note with a line break in it) with five mistakes in it. Change a column's field and the check follows. Import posts the file and the mapping to api/import.php, which reads and checks it once more and shows what it would store — this demo stores nothing.
demoImporter() // the fields: demo/_import.php, below
->action('api/import.php') // the steps after the first are answered there
->render();Events appear here.
<?php
/**
* The importer of the demo (GridKit\Import, 1.119.0), in one place: sections/import.php draws
* its first step (and a second one the server draws on its own), api/import.php answers the
* steps after it. Both build it here, so the server checks with the very fields the page shows.
*
* A public site: small files only, and storage(false) — nothing an anonymous visitor uploads is
* kept on this server; the file travels in the form between the steps and is read and checked
* again on every one of them.
*/
declare(strict_types=1);
use GridKit\Import;
function demoImporter(string $name = 'customers'): Import
{
return (new Import($name))
->label('Import customers')
->field('customer_no', 'Customer no.', ['required' => true, 'unique' => true, 'aliases' => ['Kundennummer', 'Kd-Nr', 'Number']])
->field('first_name', 'First name', ['aliases' => ['Vorname', 'Given name']])
->field('last_name', 'Last name', ['required' => true, 'aliases' => ['Nachname', 'Surname']])
->field('email', 'E-mail', ['type' => 'email', 'required' => true, 'unique' => true, 'aliases' => ['E-Mail', 'Mail', 'E-Mail-Adresse']])
->field('country', 'Country', ['type' => 'select', 'options' => ['AT' => 'Austria', 'DE' => 'Germany', 'CH' => 'Switzerland'], 'aliases' => ['Land']])
->field('birthday', 'Birthday', ['type' => 'date', 'aliases' => ['Geburtsdatum', 'Date of birth']])
->field('revenue', 'Revenue', ['type' => 'money', 'aliases' => ['Umsatz']])
->field('newsletter', 'Newsletter', ['type' => 'bool'])
->locale('de') // German Excel writes 1.234,50 — and 1.500 means fifteen hundred
->limits(2000, 512 * 1024) // a public demo takes small files
->storage(false); // and keeps none of them: the file travels in the form
}
<?php
/**
* The steps after the first of the demo's importer (GridKit\Import, 1.119.0).
*
* Without script the page posts the file here and this page shows step two — the mapping and the
* preview — which posts to itself until the person imports or cancels. With script the browser has
* shown step two already, and the form posts the file and the mapping here once. Either way this
* page reads the file and checks every row again: no row is taken from the browser.
*
* A real page checks its CSRF token before handle() and stores $import->result()['rows'] when
* step() says 'done'. The demo stores nothing and keeps nothing (storage(false) in _import.php):
* it shows what it would store.
*/
declare(strict_types=1);
require_once __DIR__ . '/../../autoload.php';
require_once __DIR__ . '/../_import.php';
use GridKit\{Lang, Layout, Table};
$lang = $_GET['lang'] ?? $_COOKIE['gk_lang'] ?? 'en';
Lang::set(in_array($lang, ['en', 'de'], true) ? $lang : 'en');
$name = isset($_POST['customers-server']) ? 'customers-server' : 'customers';
$import = demoImporter($name)->action('import.php');
if (($_POST['sample'] ?? '') === '1') {
$import->fromString((string) file_get_contents(__DIR__ . '/../media/kunden.csv'), 'kunden.csv');
} else {
$import->handle();
}
$e = static fn (string $s): string => htmlspecialchars($s, ENT_QUOTES, 'UTF-8');
?>
<!DOCTYPE html>
<html lang="<?= $e(Lang::locale()) ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex">
<title>Import customers — GridKit Demo</title>
<link rel="stylesheet" href="<?= Layout::asset('../../css/gridkit.css') ?>">
<link rel="stylesheet" href="<?= Layout::asset('../../css/themes.css') ?>">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<style>body { margin: 0; background: var(--gk-surface-container); } main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.demo-card { background: var(--gk-surface); border: 1px solid var(--gk-outline-variant); border-radius: 12px; padding: 20px; }
h1 { font-size: 22px; margin: 8px 0 16px; } h2 { font-size: 17px; margin: 28px 0 8px; }</style>
<?= Lang::jsConfig() ?>
</head>
<?= Layout::bodyTag('gk-root') ?>
<main>
<p><a href="../#import">← Back to the demo</a></p>
<h1>Import customers</h1>
<div class="demo-card">
<?php $import->render(); ?>
</div>
<?php if ($import->step() === 'done'):
$r = $import->result();
$rows = [];
foreach ($r['rows'] as $row => $values) {
$line = ['row' => $row];
foreach ($values as $key => $value) {
$line[$key] = is_bool($value) ? ($value ? 'yes' : 'no') : (string) ($value ?? '');
}
$rows[] = $line;
}
?>
<h2>What the server would store</h2>
<p>The rows of <code>$import->result()['rows']</code>, read and checked here again. Nothing is stored in this demo.</p>
<?php
$table = (new Table('imported'))->setData($rows)->caption('Imported rows')->column('row', 'Row', ['format' => 'number']);
foreach (['customer_no' => 'Customer no.', 'first_name' => 'First name', 'last_name' => 'Last name', 'email' => 'E-mail',
'country' => 'Country', 'birthday' => 'Birthday', 'revenue' => 'Revenue', 'newsletter' => 'Newsletter'] as $key => $label) {
if (in_array($key, $r['mapping'], true)) $table->column($key, $label);
}
$table->paginate(25)->render();
?>
<?php endif; ?>
</main>
<script src="<?= Layout::asset('../../js/gridkit.js') ?>"></script>
<script src="<?= Layout::asset('../../js/import.js') ?>" defer></script>
</body>
</html>
The sample read on the server with fromString(): what a browser without JavaScript gets after the upload — how the file was read, a field for every column (Notiz matches none and is ignored), the summary, the first rows with every error under its cell in words, the list of every row that will be left out, and the choice: import the valid rows, check again, or cancel. With storage(false) the file travels in the form, so js/import.js takes this one over too and checks every change at once.
demoImporter('customers-server')
->action('api/import.php')
->preview(8)
->fromString((string) file_get_contents(__DIR__ . '/../media/kunden.csv'), 'kunden.csv')
->render();The rows that passed, keyed by their row in the sheet (the header is row 1), typed — amounts as exact strings, dates as Y-m-d, yes and no as booleans, a country as its code — and the messages of the rows that did not.
{
"total": 20,
"valid": 15,
"invalid": 5,
"rows": {
"2": {
"customer_no": "K-1001",
"first_name": "Anna",
"last_name": "Müller",
"email": "[email protected]",
"country": "AT",
"birthday": "1985-03-12",
"revenue": "1234.50",
"newsletter": true
},
"3": {
"customer_no": "K-1002",
"first_name": "Jürgen",
"last_name": "Weiß",
"email": "[email protected]",
"country": "DE",
"birthday": "1979-07-01",
"revenue": "980.00",
"newsletter": false
}
},
"errors": {
"8": {
"email": "Not a valid e-mail address."
},
"9": {
"birthday": "Enter a date such as 31.12.2026 or 2026-12-31."
},
"10": {
"customer_no": "Already in row 3."
},
"11": {
"last_name": "Last name is required."
},
"15": {
"country": "Not one of: Austria, Germany, Switzerland."
}
},
"meta": {
"encoding": "Windows-1252",
"delimiter": ";",
"lineEnding": "CRLF",
"header": true
}
}$r = demoImporter()->fromString((string) file_get_contents(__DIR__ . '/../media/kunden.csv'), 'kunden.csv')->result();
echo '<pre class="demo-log">' . htmlspecialchars((string) json_encode([
'total' => $r['total'], 'valid' => $r['valid'], 'invalid' => $r['invalid'],
'rows' => array_slice($r['rows'], 0, 2, true),
'errors' => $r['errors'],
'meta' => array_intersect_key($r['meta'], array_flip(['encoding', 'delimiter', 'lineEnding', 'header'])),
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), ENT_QUOTES, 'UTF-8') . '</pre>';Two components for time: GridKit\DateRange, a period picker for reports and
invoice lists, and GridKit\Calendar, a month view for appointments, deadlines and campaigns. Both
work without any script — a select and two date fields that are sent, a table of links. js/calendar.js
fills the dates when a preset is chosen, writes the period in words, and makes the month a grid for the keyboard.
In the bar of a TableHeader: choose a preset and the list is asked for it at once;
type a date and the select says Custom, then Apply. The page reads the same period with
current() (or DateRange::fromRequest()) — checked, in order, within min()
and max(), "today" in the page's time zone — and filters its invoices by it.
{"from":"2026-11-05","to":"2026-12-04","preset":"last-30-days","invoices":5,"total":"971.00"}$range = (new DateRange('period'))
->presets(['today', 'last-7-days', 'last-30-days', 'this-month', 'last-month', 'this-quarter', 'this-year'])
->default('last-30-days')
->filter() // its own GET form and Apply; a preset is sent at once
->baseUrl('#dates-filter')
->preserve(['lang']);
$period = $range->current(); // ['from' => 'Y-m-d', 'to' => 'Y-m-d', 'preset' => 'last-30-days']
TableHeader::make('invoices')
->filter(fn () => $range->render())
->reset('?#dates-filter')
->render();
$found = array_filter($invoices, fn (array $i): bool => $i['date'] >= $period['from'] && $i['date'] <= $period['to']);
echo '<pre class="demo-log">' . htmlspecialchars(json_encode($period + [
'invoices' => count($found),
'total' => number_format(array_sum(array_column($found, 'amount')), 2, '.', ''),
])) . '</pre>';daterangeThe field's options are the picker's; its label names the group, its message line describes it. The form below is sent with GET to this page and shows what it read.
{"from":"2026-11-01","to":"2026-11-30","preset":"last-month"}$read = DateRange::fromRequest('report', 'last-month', ['max' => date('Y-m-d')]);
(new Form('report-form'))
->method('get')
->action('#dates-form')
->hidden('lang', $lang)
->row()
->field('report', 'Period', 'daterange', ['width' => 10, 'default' => 'last-month',
'presets' => ['last-7-days', 'last-30-days', 'this-month', 'last-month', 'last-quarter', 'last-year'],
'max' => date('Y-m-d'), 'required' => true])
->field('group', 'Grouped by', 'select', ['width' => 6, 'native' => true,
'options' => ['day' => 'Day', 'week' => 'Week', 'month' => 'Month']])
->endRow()
->values($_GET)
->submit('Show report')
->render();
echo '<pre class="demo-log">' . htmlspecialchars(json_encode($read)) . '</pre>';Click into the month, then ← → ↑ ↓ walk the days, Home and End go to the ends of the week, PgUp and PgDn to the month before and after (the page loads it, the day keeps the focus), Enter chooses the day, Tab reaches its events. A bar runs across the days of the fair and the campaign; a busy day shows three and +3 more, which opens the whole day. Narrower than 600px — on a phone — the month is an agenda.
Choose a day or an event.
| WkWeek | SunSunday | MonMonday | TueTuesday | WedWednesday | ThuThursday | FriFriday | SatSaturday |
|---|---|---|---|---|---|---|---|
| 9Week 9 | |||||||
| 10Week 10 | |||||||
| 11Week 11 | |||||||
| 12Week 12 | |||||||
| 13Week 13 | |||||||
| 14Week 14 |
Nothing this month.
(new Calendar('appointments'))
->label('Appointments')
->weekNumbers()
->baseUrl('?#dates-calendar')
->preserve(['lang'])
->dayUrl('#dates-calendar&day={date}')
->event($dDay(0) . ' 09:30', 'Team meeting', ['href' => '#dates-calendar', 'color' => 'blue'])
->event($dDay(0) . ' 14:00', 'Call with Acme <Ltd>', ['color' => 'green', 'id' => 'call-7'])
->event($dDay(2), 'Invoice run', ['color' => 'red', 'allDay' => true])
->event(['start' => $dDay(3), 'end' => $dDay(6)], 'Trade fair Vienna', ['color' => 'orange', 'href' => '#dates-calendar'])
->event(['start' => $dDay(4), 'end' => $dDay(13)], 'Winter campaign', ['href' => '#dates-calendar'])
->event(['start' => $dDay(3), 'end' => $dDay(4)], 'Booth set-up', ['color' => 'gray'])
->events([
['date' => $dDay(8) . ' 08:00', 'title' => 'Breakfast with the board', 'color' => 'green'],
['date' => $dDay(8) . ' 10:00', 'title' => 'Release 1.120', 'color' => 'blue'],
['date' => $dDay(8) . ' 11:30', 'title' => 'Dentist'],
['date' => $dDay(8) . ' 15:00', 'title' => 'Review of the quarter', 'color' => 'orange'],
['date' => $dDay(8) . ' 17:00', 'title' => 'Yoga', 'color' => 'gray'],
['date' => $dDay(-3), 'title' => 'Tax deadline', 'color' => 'red'],
['date' => $dDay(-9) . ' 16:00', 'title' => 'Workshop: accessible forms'],
['date' => $dDay(17), 'title' => 'Offsite', 'color' => 'blue'],
])
->render();The calendar is a size container: in a column narrower than 600px it shows the days that hold something, one under the other — what a phone shows. Weeks start on Monday here, as in German.
| MonMonday | TueTuesday | WedWednesday | ThuThursday | FriFriday | SatSaturday | SunSunday |
|---|---|---|---|---|---|---|
Nothing this month.
(new Calendar('agenda'))
->weekStart('monday')
->baseUrl('?#dates-agenda')
->preserve(['lang'])
->event($dDay(0) . ' 09:30', 'Team meeting', ['href' => '#dates-agenda', 'color' => 'blue'])
->event(['start' => $dDay(3), 'end' => $dDay(6)], 'Trade fair Vienna', ['color' => 'orange'])
->event($dDay(8) . ' 10:00', 'Release 1.120', ['color' => 'blue'])
->render();Revenue per month, open rates, the sources of a site's visits: GridKit\Chart draws
line, area, bar and donut charts and sparklines as inline SVG on the server — no library, nothing to wait for.
The axis steps by 1, 2 and 5, bars start at zero, numbers are written in the chart's language
(1.234,50 €, €1,234.50). Every chart has a summary in words for a screen reader, a
legend that names its series and its data as a table. js/chart.js draws it again at the width of its
box, shows the values on hover and on the keys (Tab into a chart, then ← →,
Home, End, Enter), and switches a series off from its legend.
| Category | 2025 | 2026 | Plan |
|---|---|---|---|
| Jan | 8.200,00 € | 9.100,00 € | 9.000,00 € |
| Feb | 7.900,00 € | 8.800,00 € | 9.000,00 € |
| Mar | 9.400,00 € | 10.900,00 € | 9.500,00 € |
| Apr | 10.100,00 € | 11.600,00 € | 10.000,00 € |
| May | 9.800,00 € | 12.100,00 € | 10.500,00 € |
| Jun | 11.200,00 € | 12.900,00 € | 11.000,00 € |
| Jul | 12.500,00 € | 13.800,00 € | 11.500,00 € |
| Aug | 11.900,00 € | 13.100,00 € | 12.000,00 € |
| Sep | 10.400,00 € | 12.200,00 € | 12.500,00 € |
| Oct | 12.800,00 € | — | 13.000,00 € |
| Nov | 14.100,00 € | — | 13.500,00 € |
| Dec | 16.900,00 € | — | 14.000,00 € |
(new Chart('demo-revenue'))
->type('bar')
->title('Revenue per month')
->labels(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])
->series('2025', [8200, 7900, 9400, 10100, 9800, 11200, 12500, 11900, 10400, 12800, 14100, 16900])
->series('2026', [9100, 8800, 10900, 11600, 12100, 12900, 13800, 13100, 12200, null, null, null])
->series('Plan', [9000, 9000, 9500, 10000, 10500, 11000, 11500, 12000, 12500, 13000, 13500, 14000],
['hidden' => true]) // starts switched off; the legend switches it on
->format('money', ['currency' => 'EUR', 'locale' => 'de'])
->height(280)
->render();What the page hears — gk:chartselect (click a bar, or
Enter on the keys) and gk:charttoggle (the legend):
Click a bar or a name in the legend.
| Category | Customers | Trial users | Partners |
|---|---|---|---|
| W1 | 41.2% | 28.4% | 52% |
| W2 | 43.5% | 30.1% | 49.5% |
| W3 | 39.8% | 33.6% | 51.3% |
| W4 | 44.1% | 31.2% | — |
| W5 | 46.3% | 35.8% | 54.2% |
| W6 | 45% | 34.4% | 55.8% |
| W7 | 47.2% | 37.1% | 53.9% |
| W8 | 48.9% | 36.5% | 57.4% |
(new Chart('demo-open-rates'))
->type('line')
->title('Newsletter open rate')
->labels(['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8'])
->series('Customers', [41.2, 43.5, 39.8, 44.1, 46.3, 45.0, 47.2, 48.9])
->series('Trial users', [28.4, 30.1, 33.6, 31.2, 35.8, 34.4, 37.1, 36.5])
->series('Partners', [52.0, 49.5, 51.3, null, 54.2, 55.8, 53.9, 57.4])
->format('percent', ['locale' => 'en'])
->zero(false) // the axis starts near the data
->markers() // a point shape per series
->dashes() // a dash pattern per series
->render();| Category | Search | Direct | Social | Total |
|---|---|---|---|---|
| Mon | 1,820 | 640 | 310 | 2,770 |
| Tue | 1,940 | 700 | 290 | 2,930 |
| Wed | 2,010 | 690 | 350 | 3,050 |
| Thu | 1,890 | 720 | 420 | 3,030 |
| Fri | 1,760 | 680 | 510 | 2,950 |
| Sat | 980 | 410 | 620 | 2,010 |
| Sun | 860 | 380 | 580 | 1,820 |
(new Chart('demo-visits'))
->type('area')
->stacked()
->title('Visits by channel')
->labels(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'])
->series('Search', [1820, 1940, 2010, 1890, 1760, 980, 860])
->series('Direct', [640, 700, 690, 720, 680, 410, 380])
->series('Social', [310, 290, 350, 420, 510, 620, 580])
->format('number', ['locale' => 'en'])
->height(240)
->render();| Category | Change |
|---|---|
| /pricing | 18.5% |
| /blog/how-we-cut-our-invoice-processing-time-in-half | 42% |
| /features/reports | -7.5% |
| /contact | -12% |
| /docs/getting-started | 9% |
(new Chart('demo-pages'))
->type('bar')
->horizontal()
->title('Change in visits since last month')
->labels(['/pricing', '/blog/how-we-cut-our-invoice-processing-time-in-half', '/features/reports',
'/contact', '/docs/getting-started'])
->series('Change', [18.5, 42.0, -7.5, -12.0, 9.0])
->format('percent', ['locale' => 'en'])
->height(240)
->render();| Category | Orders | Share |
|---|---|---|
| Online shop | 1.240 | 39,7 % |
| Marketplace | 860 | 27,5 % |
| Phone | 410 | 13,1 % |
| Retail partners | 380 | 12,2 % |
| Trade fairs | 150 | 4,8 % |
| 60 | 1,9 % | |
| Other | 25 | 0,8 % |
| Total | 3.125 | 100 % |
(new Chart('demo-sources'))
->type('donut')
->title('Where the orders came from')
->labels(['Online shop', 'Marketplace', 'Phone', 'Retail partners', 'Trade fairs', 'E-mail', 'Other'])
->series('Orders', [1240, 860, 410, 380, 150, 60, 25]) // from the sixth part on: "Other"
->format('number', ['locale' => 'de'])
->height(220)
->render();| Product | Sales | Last 7 weeks |
|---|---|---|
| Starter | 412 | |
| Business | 268 | |
| Enterprise | 57 |
(new StatCards('demo-chart-stats'))
->card('Revenue', 16900, ['format' => 'currency', 'icon' => 'euro', 'trend' => '+12%',
'sparkline' => [8200, 7900, 9400, 10100, 9800, 11200, 12500, 11900, 10400, 12800, 14100, 16900]])
->card('Open rate', 48.9, ['format' => 'percent', 'icon' => 'mail',
'sparkline' => ['values' => [41.2, 43.5, 39.8, 44.1, 46.3, 45.0, 47.2, 48.9], 'color' => 3, 'area' => true]])
->render();
(new Table('demo-chart-table'))
->setData([
['product' => 'Starter', 'sales' => 412, 'trend' => Chart::sparkline([30, 32, 35, 33, 38, 41, 44], ['label' => 'Starter'])],
['product' => 'Business', 'sales' => 268, 'trend' => Chart::sparkline([22, 21, 25, 24, 23, 27, 26], ['label' => 'Business', 'color' => 2])],
['product' => 'Enterprise', 'sales' => 57, 'trend' => Chart::sparkline([9, 8, 8, 7, 6, 7, 5], ['label' => 'Enterprise', 'color' => 4])],
])
->column('product', 'Product')
->column('sales', 'Sales', ['format' => 'number'])
->column('trend', 'Last 7 weeks', ['format' => 'html'])
->render();No values at all, a single point, nothing but zeros (bars and a donut), and values below zero: each still draws a chart that says what it holds, and never an empty frame.
| Category | Sign-ups |
|---|---|
| Jan | — |
| Feb | — |
| Mar | — |
(new Chart('demo-empty'))->type('line')->title('Sign-ups')
->labels(['Jan', 'Feb', 'Mar'])->series('Sign-ups', [null, null, null])
->height(160)->render();| Category | Orders |
|---|---|
| Nov | 37 |
(new Chart('demo-one'))->type('line')->title('First month')
->labels(['Nov'])->series('Orders', [37])
->height(160)->render();| Category | Refunds |
|---|---|
| Q1 | $0.00 |
| Q2 | $0.00 |
| Q3 | $0.00 |
| Q4 | $0.00 |
(new Chart('demo-zero'))->type('bar')->title('Refunds')
->labels(['Q1', 'Q2', 'Q3', 'Q4'])->series('Refunds', [0, 0, 0, 0])
->format('money', ['locale' => 'en', 'currency' => 'USD'])
->height(160)->render();| Category | Returns | Share |
|---|---|---|
| Damaged | 0 | — |
| Wrong size | 0 | — |
| Changed mind | 0 | — |
| Total | 0 | — |
(new Chart('demo-nothing'))->type('donut')->title('Returns by reason')
->labels(['Damaged', 'Wrong size', 'Changed mind'])->series('Returns', [0, 0, 0])
->height(140)->render();| Category | In | Out | Total |
|---|---|---|---|
| Q1 | 5.200,00 € | -4.100,00 € | 1.100,00 € |
| Q2 | 6.100,00 € | -6.900,00 € | -800,00 € |
| Q3 | 4.800,00 € | -3.900,00 € | 900,00 € |
| Q4 | 7.300,00 € | -5.200,00 € | 2.100,00 € |
(new Chart('demo-negative'))->type('bar')->stacked()->title('Cash flow')
->labels(['Q1', 'Q2', 'Q3', 'Q4'])
->series('In', [5200, 6100, 4800, 7300])
->series('Out', [-4100, -6900, -3900, -5200])
->format('money', ['locale' => 'de'])
->height(160)->render();Type a few letters, jump to a page, a customer, an invoice, or run a command. GridKit\CommandPalette writes a closed dialog; js/command-palette.js opens it with Ctrl+K (⌘+K on a Mac), /, the search button in the header or GK.palette.open(). On this page it knows every section of the sidebar, every heading of the demo, a few commands and the demo's customers and invoices, fetched as you type.
Type tre for the tree, dark for dark mode, mueller or muller for Müller & Söhne, inv 02 for invoices. The best match comes first: a name that starts with what you typed, then a word that does, then a word that holds it, then its letters in order. ↑ ↓, Home, End, Page Up and Page Down move, Enter opens, Ctrl+Enter opens a link in a new tab, Esc closes and gives the focus back. What you chose comes first next time. slow shows the server thinking, fail a server that failed.
Events appear here.
// The page's palette, built before the header (demo/index.php):
$palette = new CommandPalette('demo');
$palette->item('Toggle dark mode', '', ['icon' => 'dark_mode', 'action' => 'demo-dark', 'keywords' => ['night', 'light', 'theme']])
->item('Show a toast', '', ['icon' => 'notifications', 'action' => 'demo-toast', 'keywords' => 'message']);
foreach (['indigo' => 'Indigo', 'ocean' => 'Ocean', 'forest' => 'Forest', 'rose' => 'Rose', 'amber' => 'Amber', 'slate' => 'Slate'] as $key => $name) {
$palette->item("Theme: $name", '', ['icon' => 'palette', 'group' => 'Themes', 'action' => "demo-theme:$key", 'keywords' => 'colour color']);
}
$palette->item($lang === 'en' ? 'Show the demo in German' : 'Show the demo in English', '?lang=' . ($lang === 'en' ? 'de' : 'en'),
['icon' => 'translate', 'group' => 'Links', 'keywords' => ['language', 'deutsch', 'english']])
->item('GitHub repository', 'https://github.com/mmollay/gridkit', ['icon' => 'code', 'group' => 'Links', 'hint' => 'github.com/mmollay/gridkit'])
->item('The agent skill', '../GRIDKIT_SKILL.md', ['icon' => 'smart_toy', 'group' => 'Links', 'hint' => 'GRIDKIT_SKILL.md', 'keywords' => 'docs documentation'])
->item('GridKit home page', '../', ['icon' => 'home', 'group' => 'Links'])
->search('api/palette.php', ['minLength' => 2])
->slash();
return $palette;
// In the header:
->action($palette->trigger())
// Once, anywhere in <body>:
$palette->render();search('api/palette.php'): after two letters and a quarter of a second of quiet the palette asks GET api/palette.php?q=… — on the page's own origin, never another — and drops an answer a newer question has overtaken. The answer is the shape GK.search reads, so an endpoint written for it works unchanged. Every label is put in as text.
<?php
/**
* Records for the demo's command palette (1.122.0): GET api/palette.php?q=… — customers and invoices.
*
* Stateless: the records are written here, nothing is stored. The answer is the shape GK.search reads,
* which CommandPalette::search() reads too:
*
* { "groups": [ { "title": "Customers", "items": [ { "title", "subtitle", "url", "icon", "amount" } ] } ] }
*
* The query arrives as it was typed. It is folded the way the palette folds it — case, accents, and the
* German umlauts both ways — so "muller", "mueller" and "Müller" find the same customer. Two words on
* purpose: "fail" answers 500 (the palette says so and offers to ask again), "slow" waits a second
* and a half (the palette says it is searching; typing on drops the late answer).
*/
declare(strict_types=1);
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store');
/** Lower case, accents off, ß → ss; with $german the umlauts become ae, oe, ue. No mbstring needed. */
function paletteFold(string $s, bool $german): string
{
$map = ['ß' => 'ss', 'ẞ' => 'ss', 'æ' => 'ae', 'Æ' => 'ae', 'œ' => 'oe', 'Œ' => 'oe', 'ø' => 'o', 'Ø' => 'o',
'á' => 'a', 'à' => 'a', 'â' => 'a', 'å' => 'a', 'é' => 'e', 'è' => 'e', 'ê' => 'e', 'ë' => 'e', 'í' => 'i',
'ì' => 'i', 'î' => 'i', 'ï' => 'i', 'ó' => 'o', 'ò' => 'o', 'ô' => 'o', 'ú' => 'u', 'ù' => 'u', 'û' => 'u',
'ç' => 'c', 'ñ' => 'n', 'Á' => 'a', 'É' => 'e', 'Í' => 'i', 'Ó' => 'o', 'Ú' => 'u', 'Ç' => 'c', 'Ñ' => 'n'];
$map += $german
? ['ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'Ä' => 'ae', 'Ö' => 'oe', 'Ü' => 'ue']
: ['ä' => 'a', 'ö' => 'o', 'ü' => 'u', 'Ä' => 'a', 'Ö' => 'o', 'Ü' => 'u'];
return strtolower(strtr($s, $map));
}
$q = $_GET['q'] ?? '';
$q = is_string($q) ? trim((string) preg_replace('/\s+/u', ' ', $q)) : '';
if (strlen($q) > 100) $q = substr($q, 0, 100);
if (paletteFold($q, false) === 'fail') {
http_response_code(500);
echo json_encode(['error' => 'The demo fails on purpose for "fail".']);
return;
}
if (paletteFold($q, false) === 'slow') usleep(1500000);
$records = [
'Customers' => [
['title' => 'Ecklund & Partner', 'subtitle' => 'Vienna · Customer no. 1042', 'url' => '#palette&record=c1042', 'icon' => 'business'],
['title' => 'Müller & Söhne GmbH', 'subtitle' => 'Graz · Customer no. 1050', 'url' => '#palette&record=c1050', 'icon' => 'business'],
['title' => 'Bäckerei Groß', 'subtitle' => 'Linz · Customer no. 1061', 'url' => '#palette&record=c1061', 'icon' => 'storefront'],
['title' => 'Nordlicht Media', 'subtitle' => 'Salzburg · Customer no. 1088', 'url' => '#palette&record=c1088', 'icon' => 'business'],
['title' => 'Café Central KG', 'subtitle' => 'Vienna · Customer no. 1093', 'url' => '#palette&record=c1093', 'icon' => 'local_cafe'],
['title' => 'Ørsted Wind Services', 'subtitle' => 'Innsbruck · Customer no. 1120', 'url' => '#palette&record=c1120', 'icon' => 'business'],
],
'Invoices' => [
['title' => 'INV-2026-0184', 'subtitle' => 'Ecklund & Partner · Mar 12, 2026', 'amount' => '€1,240.00', 'url' => '#palette&record=i184', 'icon' => 'receipt_long'],
['title' => 'INV-2026-0201', 'subtitle' => 'Nordlicht Media · Mar 28, 2026', 'amount' => '€890.50', 'url' => '#palette&record=i201', 'icon' => 'receipt_long'],
['title' => 'INV-2026-0207', 'subtitle' => 'Müller & Söhne GmbH · Apr 2, 2026', 'amount' => '€4,312.80', 'url' => '#palette&record=i207', 'icon' => 'receipt_long'],
['title' => 'INV-2026-0215', 'subtitle' => 'Bäckerei Groß · Apr 9, 2026', 'amount' => '€96.00', 'url' => '#palette&record=i215', 'icon' => 'receipt_long'],
],
];
$groups = [];
if ($q !== '') {
$needles = array_unique([paletteFold($q, false), paletteFold($q, true)]);
foreach ($records as $title => $items) {
$found = array_values(array_filter($items, static function (array $r) use ($needles): bool {
$text = $r['title'] . ' ' . $r['subtitle'];
foreach ([paletteFold($text, false), paletteFold($text, true)] as $hay) {
foreach ($needles as $n) {
if (str_contains($hay, $n)) return true;
}
}
return false;
}));
if ($found) $groups[] = ['title' => $title, 'items' => $found];
}
}
echo json_encode(['groups' => $groups], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
The headings of this demo are registered by the script below with GK.palette.register(), asked again each time the palette opens; choosing one fires gk:paletteaction, and the page scrolls to it. The commands of the page answer the same event.
document.addEventListener('DOMContentLoaded', function () {
// Every heading of the demo, under the name of its section.
GK.palette.register({
group: 'Demo headings',
items: function () {
return Array.prototype.map.call(document.querySelectorAll('.demo-section h3'), function (h) {
var section = h.closest('.demo-section').getAttribute('data-section');
var link = document.querySelector('.gk-sidebar a[href="#' + section + '"] .gk-sidebar-label');
return { label: h.textContent, hint: link ? link.textContent : section, icon: 'short_text',
action: 'demo-heading', heading: h, section: section };
}).filter(function (e) { return e.label.trim() !== ''; });
}
});
document.addEventListener('gk:paletteaction', function (e) {
var action = e.detail.action;
if (action === 'demo-heading') {
var h = e.detail.item.data.heading;
if (location.hash.split('&')[0] !== '#' + e.detail.item.data.section) location.hash = '#' + e.detail.item.data.section;
setTimeout(function () {
window.scrollTo({ top: h.getBoundingClientRect().top + window.scrollY - 80 });
h.setAttribute('tabindex', '-1');
h.focus({ preventScroll: true });
}, 30);
} else if (action === 'demo-dark') {
GK.theme.toggleMode();
} else if (action.indexOf('demo-theme:') === 0) {
GK.theme.set(action.slice(11));
} else if (action === 'demo-toast') {
GK.toast.success('Hello from the command palette.');
}
});
// What the page hears, in the log above.
var log = document.getElementById('demo-palette-log');
var lines = [];
['gk:paletteopen', 'gk:paletteselect', 'gk:paletteaction'].forEach(function (name) {
document.addEventListener(name, function (e) {
var d = e.detail, what = d.source || (d.item ? d.item.label + (d.newTab ? ' (new tab)' : '') : '');
if (d.action) what += ' → ' + d.action;
lines.unshift(name + ' ' + what);
log.textContent = lines.slice(0, 6).join('\n');
});
});
document.getElementById('demo-palette-inv').addEventListener('click', function () { GK.palette.open('inv'); });
});A modal dialog that keeps the focus — Tab goes round inside it — and gives it back when it closes; the field is a combobox, the list a listbox in groups named by their headings, and the entry you are on is aria-activedescendant. Once the list has settled, a live region says how many results there are, or that there are none, or that the server failed. On a phone the palette covers the screen and nothing scrolls sideways; the trigger is its symbol. Without script the trigger is hidden — or, with fallback('/search'), a plain link to a search page.
Conditions a person combines freely: Status is any of Open, Overdue AND Amount > 500,
or a group of OR conditions inside. GridKit\FilterBuilder writes a plain form that works without
script — nested fieldsets, submit buttons that add, duplicate and remove; js/filter-builder.js makes the
same form instant and sends the state as compact JSON in one parameter (?f=["and",…]). The page
reads it with FilterBuilder::fromRequest() or ->tree(), checked against the fields, and queries
with FilterBuilder::toSql() (placeholders only) or filters rows in memory with FilterBuilder::matches().
| Invoice | Customer | Status | Amount | Due | Tags | Reminded |
|---|---|---|---|---|---|---|
| INV-2026-0182 | Café Crème | overdue | €755.00 | reverse | — | |
| INV-2026-0184 | Nordlicht Media | open | €1,428.50 | — | ||
| INV-2026-0186 | Ecklund & Partner | overdue | €2,102.00 | vip | — | |
| INV-2026-0190 | Nordlicht Media | overdue | €1,050.50 | — | ||
| INV-2026-0192 | Ecklund & Partner | open | €1,724.00 | vip, reverse | — | |
| INV-2026-0194 | Café Crème | overdue | €2,399.00 | — | ||
| INV-2026-0196 | Nordlicht Media | open | €672.50 | — | ||
| INV-2026-0198 | Ecklund & Partner | overdue | €1,346.00 | vip | — | |
| INV-2026-0200 | Café Crème | open | €2,021.00 | — | ||
| INV-2026-0204 | Ecklund & Partner | open | €968.00 | vip | — |
FilterBuilder::toSql($tree, $fields, $columnMap): column names only from the page's map (or the
field key), every value a placeholder. Text is compared with LIKE ? ESCAPE '!', a date column may hold times,
a multiselect is the page's own callable — here a tag table.
WHERE (status IN (?, ?) AND i.total > ?) params: ["open","overdue",500]
$fb = (new FilterBuilder('f'))
->field('status', 'Status', ['type' => 'select', 'options' => $statuses])
->field('amount', 'Amount', ['type' => 'money'])
->field('customer', 'Customer')
->field('due', 'Due', ['type' => 'date'])
->field('tags', 'Tags', ['type' => 'multiselect', 'options' => $tags])
->field('reminded', 'Reminded', ['type' => 'bool'])
->views($savedViews) // the page stores them
->localViews(); // and this browser too
$tree = $fb->tree(); // checked: unknown fields, operators, values left out
['sql' => $where, 'params' => $params] = FilterBuilder::toSql($tree, $fb, ['amount' => 'i.total', 'tags' => $tagCallable]);
// or, in memory:
$rows = array_filter($rows, fn ($r) => FilterBuilder::matches($tree, $r, $fb));
$fb->render();What comes back from Apply with a value missing: the condition stays in the form, is marked and
said in words — not by the red alone — and is not applied. A group joins its conditions the other way (OR inside
AND); maxRows(3) is reached, so “Condition”, “Group” and duplicate are disabled and the limit is said.
No conditions: every row is shown, and the builder says so. localViews() keeps a saved
view in localStorage when the page has no saveUrl(); each one comes with a button that removes it.
Apply fires gk:filterchange (cancelable — a page can filter live instead of loading),
Save view gk:filtersave; here the views are kept in this browser. GK.filterBuilder.get('f'),
set(), reset(), json() and summary() reach it from a script.
Events appear here.
Columns with cards for tasks, orders, campaigns and support tickets. GridKit\Kanban writes a labelled region of columns — a heading, a count and a list of cards — that works without any script: every card is in view, and a card that may move has a small Move form that posts. js/kanban.js adds dragging with the mouse or a finger, moving with the keyboard, counts and limits that follow every move, and a save to a URL that gives the card back when the server says no.
Drag a card by its handle (or, with a mouse, by the card itself) into another column; held at the edge, the board scrolls. With the keyboard: Tab to a handle, Space lifts the card, ↑ ↓ move it in its column, ← → to the next column, Home and End to the ends, Space puts it down, Esc cancels — every step is spoken. In progress takes three cards (wipLimits('block')): a fourth is refused. Every move is posted to api/kanban-move.php, which refuses one on purpose: Refund for order 1043 cannot go to Done, so it goes back and a toast says why. Password policy is locked ('draggable' => false).
Not looked at yet
Since this morning nobody can print; the queue shows 14 jobs.
No cards
addAdd card to NewNo cards
addAdd card to In progressWaits for the auditor; it stays where it is.
No cards
addAdd card to ReviewNo cards
addAdd card to Done$tickets = [
['id' => 'T-101', 'subject' => 'Printer on floor 2 offline', 'status' => 'new', 'priority' => ['High', 'red'],
'body' => 'Since this morning nobody can print; the queue shows 14 jobs.', 'owner' => 'Anna Huber',
'due' => date('Y-m-d', strtotime('-2 days')), 'tags' => ['Hardware', ['Office', 'blue']], 'comments' => 3],
['id' => 'T-102', 'subject' => 'New laptop for Jonas', 'status' => 'new', 'owner' => 'Ben Ortner',
'due' => date('Y-m-d'), 'tags' => ['Purchase']],
['id' => 'T-103', 'subject' => 'VPN drops every hour', 'status' => 'new', 'priority' => 'Normal',
'due' => date('Y-m-d', strtotime('+9 days'))],
['id' => 'T-104', 'subject' => 'Refund for order 1043', 'status' => 'doing', 'priority' => ['Billing', 'orange'], 'owner' => 'Clara Wimmer'],
['id' => 'T-105', 'subject' => 'Mail signature for the sales team', 'status' => 'doing', 'tags' => [['Mail', 'green']]],
['id' => 'T-106', 'subject' => 'Backup restore test', 'status' => 'doing', 'owner' => 'Ben Ortner', 'comments' => 7],
['id' => 'T-107', 'subject' => 'Password policy', 'status' => 'review', 'priority' => 'Locked', 'locked' => true,
'body' => 'Waits for the auditor; it stays where it is.'],
['id' => 'T-108', 'subject' => 'Wi-Fi in the meeting room', 'status' => 'done', 'owner' => 'Anna Huber'],
];
foreach ($tickets as &$t) {
$t['href'] = '#kanban-ticket-' . $t['id'];
$t['draggable'] = empty($t['locked']);
}
unset($t);
(new Kanban('demo-tickets'))
->label('Support tickets')
->column('new', 'New', ['color' => 'blue', 'description' => 'Not looked at yet'])
->column('doing', 'In progress', ['color' => 'orange', 'limit' => 3])
->column('review', 'Review', ['limit' => 4])
->column('done', 'Done', ['color' => 'green'])
->cards($tickets, ['title' => 'subject', 'column' => 'status', 'text' => 'body', 'badge' => 'priority',
'assignee' => 'owner', 'labels' => 'tags', 'count' => 'comments'])
->moveUrl('api/kanban-move.php', ['headers' => ['X-CSRF-Token' => 'demo-token'], 'fields' => ['_token' => 'demo-token']])
->wipLimits('block')
->addUrl('#kanban-new-{column}')
->render();Events appear here.
<?php
/**
* The move endpoint of the demo's ticket board (GridKit\Kanban::moveUrl(), 1.124.0).
*
* js/kanban.js posts every move as JSON {"id", "column", "index"} — index counted from 0 among the
* cards of the new column — with the headers given to moveUrl(). Without the script the card's
* "Move to" form posts id and column (and the hidden fields of moveUrl()) as a plain form.
* Kanban::readMove() reads either. A 2xx is saved unless the JSON says {"ok": false}; anything else
* puts the card back, and "message" is what the person reads.
*
* The demo stores nothing (a reload shows the board as it was) and refuses one move on purpose, so
* the way back can be seen: a refund ticket is closed by accounting, never from the board.
*/
declare(strict_types=1);
require __DIR__ . '/../../autoload.php';
use GridKit\Kanban;
$move = Kanban::readMove();
$form = $move !== null ? $move['form'] : !str_contains(strtolower((string) ($_SERVER['CONTENT_TYPE'] ?? '')), 'json');
// After a form, back to the page (the board shows what the server holds); after JSON, JSON.
$answer = static function (int $status, array $body) use ($form): never {
if ($form) {
$back = (string) ($_SERVER['HTTP_REFERER'] ?? '../index.php');
$back = preg_replace('/[?#].*$/', '', $back) . '?kanban=' . ($body['ok'] ? 'saved' : 'refused') . '#kanban';
header('Location: ' . $back, true, 303);
exit;
}
http_response_code($status);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($body, JSON_UNESCAPED_UNICODE);
exit;
};
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
$answer(405, ['ok' => false, 'message' => 'Moves are posted.']);
}
// The token the page gave moveUrl(): in a header from the script, in a hidden field from the form.
// A real application compares it with the session's.
$token = $form ? (string) ($_POST['_token'] ?? '') : (string) ($_SERVER['HTTP_X_CSRF_TOKEN'] ?? '');
if ($token !== 'demo-token') {
$answer(403, ['ok' => false, 'message' => 'The page is out of date. Reload it and try again.']);
}
if ($move === null) {
$answer(400, ['ok' => false, 'message' => 'The move could not be read.']);
}
$columns = ['new', 'doing', 'review', 'done'];
if (!in_array($move['column'], $columns, true)) {
$answer(422, ['ok' => false, 'message' => 'The board has no such column.']);
}
// The server checks the limits too: the page can be old, or another person faster.
// (A real board counts the column in its database; the demo trusts the page.)
if ($move['id'] === 'T-104' && $move['column'] === 'done') {
$answer(409, ['ok' => false, 'message' => 'A refund is closed by accounting, not on the board — the ticket went back.']);
}
usleep(250000);
$answer(200, ['ok' => true]);
movable() without moveUrl(): the board fires the cancelable gk:kanbanmove and the page decides. compact() leaves a card's text out and sets the cards closer. Live has a limit of one and the default 'warn': it holds two campaigns and says it is over its limit — move one on, and the mark goes. This page refuses to end a campaign that has not run — try Black Friday to Ended.
No campaigns
No campaigns
No campaigns
No campaigns
No campaigns
(new Kanban('demo-campaigns'))
->label('Campaigns')
->compact()
->movable()
->column('idea', 'Ideas')
->column('planned', 'Planned', ['color' => 'blue'])
->column('live', 'Live', ['color' => 'green', 'limit' => 1])
->column('paused', 'Paused', ['color' => 'red'])
->column('ended', 'Ended', ['color' => 'gray'])
->card('c-spring', 'Spring newsletter', 'idea', ['labels' => ['Mail']])
->card('c-bf', 'Black Friday', 'planned', ['due' => date('Y') . '-11-27', 'labels' => [['Shop', 'orange']]])
->card('c-xmas', 'Christmas vouchers', 'planned', ['labels' => ['Shop']])
->card('c-autumn', 'Autumn sale', 'live', ['assignee' => 'Clara Wimmer'])
->card('c-loyalty', 'Loyalty points', 'live', ['labels' => [['App', 'blue']]])
->card('c-summer', 'Summer sale', 'ended')
->empty('No campaigns')
->render();Rows × columns, the colour is the value: when posts get the most views, which pages are read on which days. GridKit\Heatmap writes a real table — a header cell per row and column, every cell spoken in words by its title and aria-label — so the colour is never the only way to read a figure. Five steps are mixed from the design tokens (light, dark and the six themes follow). It is markup and CSS only: no script.
Most hours hold nothing, so they are hatched and read "No data". A cell with 'weak' => true keeps its number but is dotted and left out of the scale — two posts say little, and one lucky post would flatten everything else. counts() writes the number of observations under the figure. Narrower than the table, it scrolls inside its own frame (Tab reaches the frame, arrow keys scroll it); the row headers stay.
| 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Mon | – | – | – | – | – | – | 410n = 6 | – | – | – | – | – | 520n = 5 | – | – | – | – | – |
| Tue | – | – | – | – | – | – | 380n = 4 | – | – | – | – | – | 610n = 6 | – | – | – | – | – |
| Wed | – | – | – | – | – | – | 450n = 5 | – | – | – | – | – | 480n = 3 | – | – | – | – | – |
| Thu | – | – | – | – | – | – | 330n = 4 | – | – | – | – | – | 700n = 5 | – | – | – | – | – |
| Fri | – | – | – | – | – | – | 290n = 3 | – | – | – | – | – | 560n = 4 | – | – | – | – | – |
| Sat | – | – | – | – | – | – | 240n = 2 | – | – | – | – | – | 880n = 1 | – | – | – | – | – |
| Sun | – | – | – | 150n = 1 | – | – | 180n = 3 | – | – | – | – | – | 350n = 4 | – | – | – | – | – |
$days = ['mon' => 'Mon', 'tue' => 'Tue', 'wed' => 'Wed', 'thu' => 'Thu', 'fri' => 'Fri', 'sat' => 'Sat', 'sun' => 'Sun'];
$hours = [];
for ($h = 6; $h <= 23; $h++) $hours[sprintf('%02d', $h)] = sprintf('%02d', $h);
// [weekday, hour, median of the views, posts behind it]
$posts = [
['mon', '12', 410, 6], ['mon', '18', 520, 5], ['tue', '12', 380, 4], ['tue', '18', 610, 6],
['wed', '12', 450, 5], ['wed', '18', 480, 3], ['thu', '12', 330, 4], ['thu', '18', 700, 5],
['fri', '12', 290, 3], ['fri', '18', 560, 4], ['sat', '12', 240, 2], ['sat', '18', 880, 1],
['sun', '09', 150, 1], ['sun', '12', 180, 3], ['sun', '18', 350, 4],
];
$map = (new Heatmap('demo-times'))
->label('Median views in the first 24 hours after posting, by weekday and hour')
->rows($days)
->cols($hours)
->unit('views')
->counts();
foreach ($posts as [$day, $hour, $median, $n]) {
$map->cell($day, $hour, $median, ['count' => $n, 'weak' => $n < 3]);
}
$map->render();scale(0, 10) fixes the ends so two heatmaps read alike; values beyond them take the end steps. decimals(1) sets the places, and title lets a cell say it its own way.
| W1 | W2 | W3 | W4 | W5 | W6 | |
|---|---|---|---|---|---|---|
| Home | 0.0 | 5.3 | 0.5 | 5.8 | 1.0 | 6.3 |
| Pricing | 3.7 | 0.0 | 6.4 | 2.7 | 9.1 | 5.4 |
| Docs | 7.4 | 4.8 | 12.4 | 9.7 | 7.1 | 4.5 |
| Blog | 1.0 | 9.6 | 8.1 | 6.6 | 5.1 | 3.6 |
| Contact | 4.7 | 4.3 | 3.9 | 3.5 | 3.1 | 2.7 |
$pages = ['Home', 'Pricing', 'Docs', 'Blog', 'Contact'];
$weeks = ['W1', 'W2', 'W3', 'W4', 'W5', 'W6'];
$map = (new Heatmap('demo-pages'))
->label('Average time on page in minutes, by page and week')
->rows($pages)
->cols($weeks)
->unit('min')
->scale(0, 10)
->decimals(1);
foreach ($pages as $r => $page) {
foreach ($weeks as $c => $week) {
if ($page === 'Docs' && $week === 'W3') continue; // set below with its own words
$minutes = (($r * 37 + $c * 53 + $r * $c * 11) % 101) / 10;
$map->cell($page, $week, $minutes);
}
}
$map->cell('Docs', 'W3', 12.4, ['title' => 'Docs, W3: 12.4 min — a conference link sent readers here']);
$map->render();A media library and a drawer for receipts. GridKit\FileManager draws folders, a breadcrumb, thumbnails or a list, a search, a filter by type, the order, the selection with its actions and a details panel — from rows the page hands it; it never reads a directory and never deletes or moves a file itself: it posts to the page's URLs. js/file-manager.js uploads many files at once with a progress bar each, takes files dropped on the manager and pictures pasted with Ctrl+V, and puts what the server took into the listing without a reload. On the server, FileManager::receive() checks every upload by what it holds, not by what the browser says.
Choose, drop or paste files: each one is checked here first (type, size, at most ten at once), then sent — three at the same time — to api/files.php, which checks it again with receive() and stores nothing: a picture comes back as a data URL so it can be shown. Try a file larger than 5 MB, a .docx, or a text file renamed to .png. Click a name for the details (on a phone they cover the screen); tick files for Move and Delete — Framework contract cannot be deleted, so a refusal can be seen. Keys in the listing: ← → ↑ ↓, Home, End, Space ticks, Shift+arrow ticks a range, Ctrl+A all, Enter opens the details, Delete deletes, Esc lets go.
$folders = [
['id' => 'receipts', 'name' => 'Receipts', 'parent' => null, 'count' => 2],
['id' => 'receipts-2026', 'name' => '2026', 'parent' => 'receipts', 'count' => 4],
['id' => 'receipts-2025', 'name' => '2025', 'parent' => 'receipts', 'count' => 1],
['id' => 'marketing', 'name' => 'Marketing', 'parent' => null, 'count' => 2],
['id' => 'photos', 'name' => 'Photos', 'parent' => null, 'count' => 3],
];
(new FileManager('demo-media'))
->label('Media')
->folders($folders)
->files(demoFiles(), ['name' => 'filename', 'size' => 'bytes', 'mime' => 'type', 'modified' => 'changed', 'thumbUrl' => 'thumb'])
->param('media')->anchor('files') // ?media[folder]=photos#files — links that work without script
->fromQuery() // folder, view, sort, type, search, details from the request
->uploadUrl('api/files.php')
->accept(['image/*', 'application/pdf', 'text/csv', '.csv', '.txt'])
->maxSize('5M')->maxFiles(10)
->actions(['delete' => 'api/files.php', 'move' => 'api/files.php', 'rename' => 'api/files.php',
'folder' => 'api/files.php', 'download' => true])
->csrf('demo-token')
->render();Events appear here.
select('single') and view('list'), newest first, no upload and no actions: a drawer to choose a receipt from for a booking. The choice posts ids[] with a form, and the page hears gk:filesselect.
$receipts = array_values(array_filter(demoFiles(), fn (array $f): bool => str_starts_with((string) $f['folder'], 'receipts')));
(new FileManager('demo-receipts'))
->label('Receipts')
->files($receipts, ['name' => 'filename', 'size' => 'bytes', 'mime' => 'type', 'modified' => 'changed', 'thumbUrl' => 'thumb'])
->param('receipts')->anchor('files')
->select('single')->selected(['f-r2'])
->view('list')->sort('date', 'desc')
->render();What arrives in $_FILES is the visitor's: the name, the type and the size are claims. FileManager::receive(), given the manager's rules() and a directory to store in, takes only a file PHP received in this request, reads its real size and its type from its content, wants the name's extension to fit that type, refuses names with .php anywhere in them, PHP code in any file, page markup in a picture, an SVG with script, and a picture so large in pixels that opening it would eat the server's memory — and stores what passes under a random name of its own, outside the web root unless told otherwise. This demo's endpoint is below; it moves nothing.
<?php
/**
* The endpoint of the demo's file manager (GridKit\FileManager, 1.125.0). It STORES NOTHING: this is a
* public site, and an endpoint that keeps what it is handed is a file drop for the whole internet.
*
* GET ?picture=<n> one of the demo's sample pictures, drawn here (an SVG without script, served with a
* Content-Security-Policy that would stop one anyway)
* POST files[] an upload: checked by FileManager::receive() with the manager's rules() — the type by
* its content, the name, the size, the dimensions — and answered as js/file-manager.js
* expects: {"ok":true,"file":{…}} or {"ok":false,"message":"…"}. A picture comes back
* as a data: URL so the listing can show it; nothing is moved anywhere, and PHP removes
* its temporary file when this request ends.
* POST action=… delete, move, rename, folder: answered as if done, and nothing is changed.
*
* Without the script the forms post here as plain forms, and the answer is a short page that says what the
* server would have done, with a link back.
*/
declare(strict_types=1);
require_once __DIR__ . '/../../autoload.php';
use GridKit\{FileManager, Lang};
$lang = $_GET['lang'] ?? $_COOKIE['gk_lang'] ?? 'en';
Lang::set(in_array($lang, ['en', 'de'], true) ? $lang : 'en');
// ── A sample picture ────────────────────────────────────────────────────────
if (isset($_GET['picture'])) {
$n = max(0, min(99, (int) $_GET['picture']));
$hue = ($n * 47) % 360;
$hue2 = ($hue + 38) % 360;
header('Content-Type: image/svg+xml; charset=utf-8');
header("Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox");
header('X-Content-Type-Options: nosniff');
header('Cache-Control: public, max-age=86400');
printf('<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="800" viewBox="0 0 1200 800">'
. '<defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="hsl(%d 58%% 66%%)"/>'
. '<stop offset="1" stop-color="hsl(%d 54%% 40%%)"/></linearGradient></defs>'
. '<rect width="1200" height="800" fill="url(#g)"/><circle cx="860" cy="230" r="170" fill="#fff" opacity=".18"/>'
. '<path d="M0 640 L300 420 L520 600 L760 380 L1200 700 L1200 800 L0 800Z" fill="#000" opacity=".16"/></svg>', $hue, $hue2);
exit;
}
$ajax = ($_SERVER['HTTP_X_REQUESTED_WITH'] ?? '') === 'XMLHttpRequest';
$e = static fn (string $s): string => htmlspecialchars($s, ENT_QUOTES, 'UTF-8');
/** The answer: JSON for the script, a short page for a plain form. */
$answer = static function (int $status, array $body) use ($ajax, $e): never {
http_response_code($status);
header('Cache-Control: no-store');
if ($ajax) {
header('Content-Type: application/json; charset=utf-8');
echo json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_SUBSTITUTE);
exit;
}
header('Content-Type: text/html; charset=utf-8');
$lines = $body['lines'] ?? [(string) ($body['message'] ?? '')];
echo '<!DOCTYPE html><html lang="' . $e(Lang::locale()) . '"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">'
. '<meta name="robots" content="noindex"><title>File manager — GridKit Demo</title>'
. '<style>body{font:15px/1.5 system-ui,sans-serif;max-width:720px;margin:32px auto;padding:0 16px}li{margin:4px 0}</style></head><body>'
. '<p><a href="../#files">← Back to the demo</a></p><h1>' . $e($body['ok'] ?? false ? 'Checked' : 'Not taken') . '</h1><ul>';
foreach ($lines as $line) echo '<li>' . $e((string) $line) . '</li>';
echo '</ul><p>The demo stores nothing. In your application this is where the file is moved (out of the web root) and recorded.</p></body></html>';
exit;
};
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
$answer(405, ['ok' => false, 'message' => 'This address takes uploads and actions as POST.']);
}
// Larger than post_max_size: PHP dropped the whole request, the token too.
if ($_POST === [] && $_FILES === [] && (int) ($_SERVER['CONTENT_LENGTH'] ?? 0) > 0) {
$answer(413, ['ok' => false, 'message' => 'The upload is larger than this server takes.']);
}
// The token the page gave csrf(). A real application compares it with the one in its session (hash_equals).
if (!hash_equals('demo-token', (string) ($_POST['_token'] ?? $_SERVER['HTTP_X_CSRF_TOKEN'] ?? ''))) {
$answer(403, ['ok' => false, 'message' => 'The page is out of date. Reload it and try again.']);
}
// ── An upload ───────────────────────────────────────────────────────────────
if (isset($_FILES['files'])) {
// The same rules the browser was told: the manager of the page, built the same way.
$rules = ['accept' => ['image/*', 'application/pdf', 'text/csv', '.csv', '.txt'], 'maxSize' => 5 * 1024 * 1024, 'maxFiles' => 10];
$results = FileManager::receive($_FILES['files'], $rules); // no target directory: nothing is moved anywhere
if ($results === []) {
$answer(400, ['ok' => false, 'message' => Lang::t('files.err_no_file')]);
}
if (!$ajax) {
$answer(200, ['ok' => true, 'lines' => array_map(static fn (array $r): string => (string) $r['message'], $results)]);
}
$r = $results[0];
if (!$r['ok']) {
$answer(422, ['ok' => false, 'message' => $r['message']]);
}
$file = [
'id' => 'up-' . substr((string) $r['sha256'], 0, 12),
'name' => $r['name'],
'size' => $r['size'],
'mime' => $r['mime'],
'modified' => time(),
'folder' => is_string($_POST['folder'] ?? null) && $_POST['folder'] !== '' ? $_POST['folder'] : null,
'width' => $r['width'],
'height' => $r['height'],
];
// A small raster picture travels back as a data: URL, so the listing shows it — nothing is kept here.
if (in_array($r['mime'], ['image/png', 'image/jpeg', 'image/gif', 'image/webp'], true) && $r['size'] <= 400 * 1024) {
$file['url'] = 'data:' . $r['mime'] . ';base64,' . base64_encode((string) file_get_contents((string) $r['tmp']));
}
$answer(200, ['ok' => true, 'file' => $file]);
}
// ── An action ───────────────────────────────────────────────────────────────
$action = is_string($_POST['action'] ?? null) ? $_POST['action'] : '';
$ids = array_values(array_filter((array) ($_POST['ids'] ?? []), 'is_string'));
$name = is_string($_POST['name'] ?? null) ? trim($_POST['name']) : '';
switch ($action) {
case 'delete':
case 'move':
if ($ids === []) $answer(400, ['ok' => false, 'message' => Lang::t('files.none_selected')]);
if ($action === 'delete' && in_array('f-contract', $ids, true)) {
// Refused on purpose, so the way a refusal looks can be seen.
$answer(409, ['ok' => false, 'message' => 'The contract is kept for ten years and cannot be deleted. Nothing was deleted.']);
}
$answer(200, ['ok' => true, 'lines' => [count($ids) . ' files would be ' . ($action === 'delete' ? 'deleted.' : 'moved.')]]);
case 'rename':
if (count($ids) !== 1 || $name === '' || mb_strlen($name) > 255 || preg_match('~[/\\\\\x00-\x1f]~', $name)) {
$answer(422, ['ok' => false, 'message' => 'That name cannot be used.']);
}
$answer(200, ['ok' => true, 'file' => ['id' => $ids[0], 'name' => $name], 'lines' => ["Renamed to $name."]]);
case 'folder':
if ($name === '' || mb_strlen($name) > 120 || preg_match('~[/\\\\\x00-\x1f]~', $name)) {
$answer(422, ['ok' => false, 'message' => 'That name cannot be used for a folder.']);
}
$answer(200, ['ok' => true, 'folder' => ['id' => 'new-' . bin2hex(random_bytes(4)), 'name' => $name], 'lines' => ["Folder $name would be created."]]);
case 'download':
$answer(200, ['ok' => true, 'lines' => [count($ids) . ' files would be sent as a ZIP archive.']]);
}
$answer(400, ['ok' => false, 'message' => 'Unknown action.']);
Every component added or changed in the last releases — the newest first.
| Component | What | Version | In the demo |
|---|---|---|---|
| Heatmap | New | 1.137.0 | Heatmap |
| Loading states | Update | 1.135.0 | Navigation |
| TableHeader | Update | 1.134.0 | Navigation |
| Image picker | Update | 1.133.0 | Gallery |