BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/tablecn/data-grid-view-menu

Data Grid View Menu

tablecn/data-grid-view-menu
FreeComponent

A view menu component for the data grid to toggle column visibility

Install it

npx shadcn@latest add https://tablecn.com/r/data-grid-view-menu.json

Source

src/components/data-grid/data-grid-view-menu.tsxtablecn.com/r/data-grid-view-menu.json
1"use client";
2
3import type { Table } from "@tanstack/react-table";
4import { Settings2 } from "lucide-react";
5import * as React from "react";
6import { Button } from "@/components/ui/button";
7import {
8 Command,
9 CommandEmpty,
10 CommandGroup,
11 CommandInput,
12 CommandItem,
13 CommandList,
14} from "@/components/ui/command";
15import { useDirection } from "@/components/ui/direction";
16import {
17 Popover,
18 PopoverContent,
19 PopoverTrigger,
20} from "@/components/ui/popover";
21import { cn } from "@/lib/utils";
22
23interface DataGridViewMenuProps<TData>
24 extends React.ComponentProps<typeof PopoverContent> {
25 table: Table<TData>;
26 disabled?: boolean;
27}
28
29export function DataGridViewMenu<TData>({
30 table,
31 disabled,
32 className,
33 ...props
34}: DataGridViewMenuProps<TData>) {
35 const dir = useDirection();
36
37 const columns = React.useMemo(
38 () =>
39 table
40 .getAllColumns()
41 .filter(
42 (column) =>
43 typeof column.accessorFn !== "undefined" && column.getCanHide(),
44 ),
45 [table],
46 );
47
48 return (
49 <Popover>
50 <PopoverTrigger asChild>
51 <Button
52 aria-label="Toggle columns"
53 role="combobox"
54 dir={dir}
55 variant="outline"
56 className="ms-auto hidden h-8 font-normal lg:flex"
57 disabled={disabled}
58 >
59 <Settings2 className="text-muted-foreground" />
60 View
61 </Button>
62 </PopoverTrigger>
63 <PopoverContent
64 dir={dir}
65 className={cn("w-44 p-0", className)}
66 {...props}
67 >
68 <Command>
69 <CommandInput placeholder="Search columns..." />
70 <CommandList>
71 <CommandEmpty>No columns found.</CommandEmpty>
72 <CommandGroup>
73 {columns.map((column) => (
74 <CommandItem
75 key={column.id}
76 data-checked={column.getIsVisible()}
77 onSelect={() =>
78 column.toggleVisibility(!column.getIsVisible())
79 }
80 >
81 <span className="truncate">
82 {column.columnDef.meta?.label ?? column.id}
83 </span>
84 </CommandItem>
85 ))}
86 </CommandGroup>
87 </CommandList>
88 </Command>
89 </PopoverContent>
90 </Popover>
91 );
92}

What it pulls in

npm packages

  • @tanstack/react-table
  • lucide-react

Other registry items

  • button
  • command
  • popover

Files it writes

  • src/components/data-grid/data-grid-view-menu.tsx
  • src/components/ui/direction.tsx

Facts

Registry
tablecn
Type
registry:component
Access
Free
Files written
2
Licence
MIT
First indexed
2026-08-01
Last confirmed
today

Go to the source

tablecn.com sadmann7/tablecn on GitHub Raw registry item This item as JSON

More from tablecn

All 13 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Data Griddata-gridtablecnComponentsFree4 deps · 21 files
Data Grid Filter Menudata-grid-filter-menutablecnComponentsFree2 deps · 8 files
Data Grid Keyboard Shortcutsdata-grid-keyboard-shortcutstablecnComponentsFree1 dep · 2 files
Data Grid Row Height Menudata-grid-row-height-menutablecnComponentsFree2 deps
Data Grid Select Columndata-grid-select-columntablecnComponentsFree1 dep
Data Grid Skeletondata-grid-skeletontablecnComponentsFreeno deps
Data Grid Sort Menudata-grid-sort-menutablecnComponentsFree2 deps · 4 files
Data Tabledata-tabletablecnComponentsFree3 deps · 17 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex