# Tabbed column menu

Opt into the tabbed header menu with columnMenuTabs: General / Filter / Columns tabs on the ⋮ menu. OFF by default (flat actions + Choose columns submenu). Toggle the switch to compare.

Uses `@svgrid/grid` (MIT). Category: Columns. Live demo: https://svgrid.com/demos/185-column-menu-tabs/

Install: `npm i @svgrid/grid` (Svelte 5).

## About this example

A tabbed column header menu for the Svelte 5 data grid, opt-in with columnMenuTabs. The menu on any header then has three tabs: General with sort, pin, autosize, group and reset; Filter with the column's operator, value and value checklist; and Columns with a visibility checklist. It is off by default, where the flat menu has a Choose columns submenu, and a switch in the demo compares both.

Opt into the tabbed header menu with `columnMenuTabs`. The column menu (the ⋮ button on any header) then has three tabs: General - sort / pin / autosize / group / reset Filter  - the column's filter UI (operator + value + value checklist) Columns - a quick visibility checklist It is OFF by default (the flat menu with a "Choose columns" submenu). Toggle the switch below to compare.

## Imports, features and API used

- Imports: `@svgrid/grid`, `../shared/seed`
- Table features registered: `rowSortingFeature`, `columnFilteringFeature`, `columnGroupingFeature`
- Columns: `firstName` (First name), `lastName` (Last name), `department` (Department), `country` (Country), `status` (Status), `age` (Age)

## Frequently asked questions

### How do I enable the tabbed menu?

Set columnMenuTabs on <SvGrid>. The header menu switches from the flat action list to General, Filter and Columns tabs.

### What is in the Filter tab?

The column's operator and value editor plus a checklist of distinct values with search, the same filter surface the flat menu opens, kept in sync with the filter row when showColumnFilters is on.

### Which is the default?

The flat menu. It keeps the actions one click away and puts column visibility in a Choose columns submenu; the tabbed layout suits grids with heavy filtering.

## Related documentation

- [Column menu](https://svgrid.com/docs/help/columns/column-menu.md)

## Related articles

- [A Custom Column Header Menu in SvGrid](https://svgrid.com/blog/custom-column-header-menu/) - Build a per-column header menu for sort, hide, pin, and custom actions using header snippets and your own dropdown component.

## Source code (185-column-menu-tabs.svelte)

```svelte
<!-- Documented in: docs/help/columns/column-menu.md -->
<script lang="ts">
  /**
   * 185. Tabbed column menu (columnMenuTabs)
   * ----------------------------------------
   * Opt into the tabbed header menu with `columnMenuTabs`. The
   * column menu (the ⋮ button on any header) then has three tabs:
   *   General - sort / pin / autosize / group / reset
   *   Filter  - the column's filter UI (operator + value + value checklist)
   *   Columns - a quick visibility checklist
   * It is OFF by default (the flat menu with a "Choose columns" submenu). Toggle
   * the switch below to compare.
   */
  import {
    SvGrid,
    tableFeatures,
    rowSortingFeature,
    columnFilteringFeature,
    columnGroupingFeature,
    type GridColumns,
  } from '@svgrid/grid'
  import { makePeople, type Person } from '../shared/seed'

  const features = tableFeatures({ rowSortingFeature, columnFilteringFeature, columnGroupingFeature })
  const rows = makePeople(150)
  let tabbed = $state(true)

  const columns: GridColumns<Person> = [
    { field: 'firstName', header: 'First name', width: 140 },
    { field: 'lastName', header: 'Last name', width: 140 },
    { field: 'department', header: 'Department', width: 150 },
    { field: 'country', header: 'Country', width: 120 },
    { field: 'status', header: 'Status', width: 110 },
    { field: 'age', header: 'Age', width: 90, cellDataType: 'number' },
  ]
</script>

<section class="flex flex-col flex-1 min-h-0 gap-3">
  <div class="flex items-center gap-3 shrink-0">
    <label class="cmt-switch">
      <input type="checkbox" bind:checked={tabbed} />
      <span><code>columnMenuTabs</code> {tabbed ? 'on' : 'off'}</span>
    </label>
    <span class="text-xs" style="color: var(--sg-muted);">
      Open any column's <strong>⋮</strong> menu. {tabbed
        ? 'Tabbed: General / Filter / Columns.'
        : 'Flat: actions list + Choose columns submenu.'}
    </span>
  </div>

  <div class="flex-1 min-h-0">
    {#key tabbed}
      <SvGrid responsive={true}
      columnResize
        data={rows}
        columns={columns}
        features={features}
        columnMenuTabs={tabbed}
        showColumnFilters={true}
        selectionMode="none"
        showRowNumbers={true}
        rowHeight={36}
        containerHeight="100%"
        fitColumns={true}
      />
    {/key}
  </div>
</section>

<style>
  .cmt-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sg-fg); cursor: pointer; }
  .cmt-switch input { accent-color: var(--sg-accent, #2563eb); width: 16px; height: 16px; }
</style>
```

[View this example on GitHub](https://github.com/sv-grid/sv-grid/blob/main/examples/src/demos/185-column-menu-tabs.svelte)
