Column Header Height
LyteNyte Grid lets you customize header height flexibly. The header can contain three components, column groups rows, a column header row, and a floating header row.
Column group rows appear only when you organize columns into groups. The
floating header row appears only when you set the floatingRowEnabled
property to true.
Column Header Height
Set the column header height with the headerHeight property. Pass a
number value representing the height in pixels.
Column Header Height
"use client";import { Grid, useClientRowDataSource } from "@1771technologies/lytenyte-pro";import "@1771technologies/lytenyte-pro/grid.css";import type { Column } from "@1771technologies/lytenyte-pro/types";import { bankDataSmall } from "@1771technologies/sample-data/bank-data-smaller";import { useId } from "react";type BankData = (typeof bankDataSmall)[number];const columns: Column<BankData>[] = [{ id: "age", type: "number" },{ id: "job" },{ id: "balance", type: "number" },{ id: "education" },{ id: "marital" },];export default function ColumnHeaderHeight() {const ds = useClientRowDataSource({ data: bankDataSmall });const grid = Grid.useLyteNyte({gridId: useId(),rowDataSource: ds,columns,headerHeight: 60,columnBase: {widthFlex: 1,},});const view = grid.view.useValue();return (<div style={{ display: "flex", flexDirection: "column" }}><div style={{ display: "flex", gap: 8, alignItems: "center" }} className="py-2"><div>Change Header Height: </div><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.headerHeight.set(30)}>Small</button><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.headerHeight.set(50)}>Medium</button><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.headerHeight.set(80)}>Large</button></div><div className="lng-grid" style={{ height: 500 }}><Grid.Root grid={grid}><Grid.Viewport><Grid.Header>{view.header.layout.map((row, i) => {return (<Grid.HeaderRow key={i} headerRowIndex={i}>{row.map((c) => {if (c.kind === "group") return null;return (<Grid.HeaderCellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 capitalize"/>);})}</Grid.HeaderRow>);})}</Grid.Header><Grid.RowsContainer><Grid.RowsCenter>{view.rows.center.map((row) => {if (row.kind === "full-width") return null;return (<Grid.Row row={row} key={row.id}>{row.cells.map((c) => {return (<Grid.Cellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 text-sm"/>);})}</Grid.Row>);})}</Grid.RowsCenter></Grid.RowsContainer></Grid.Viewport></Grid.Root></div></div>);}
You can change the column header height after setup:
// Set the header height to 24pxgrid.state.headerHeight.set(24);
Column Headers Span Column Group Rows
When using column groups, some columns might not belong to any group or might belong to groups with fewer levels than the deepest group. In such cases, the column header spans multiple group rows, increasing its height based on the rows spanned.
Column Header Group Span
"use client";import { Grid, useClientRowDataSource } from "@1771technologies/lytenyte-pro";import "@1771technologies/lytenyte-pro/grid.css";import type { Column } from "@1771technologies/lytenyte-pro/types";import { bankDataSmall } from "@1771technologies/sample-data/bank-data-smaller";import { useId } from "react";type BankData = (typeof bankDataSmall)[number];const columns: Column<BankData>[] = [{ id: "age", type: "number", groupPath: ["One Group"] },{ id: "job", groupPath: ["One Group", "Second Level"] },{ id: "balance", type: "number" },{ id: "education" },{ id: "marital" },];export default function ColumnHeaderHeightSpans() {const ds = useClientRowDataSource({ data: bankDataSmall });const grid = Grid.useLyteNyte({gridId: useId(),rowDataSource: ds,columns,columnBase: {widthFlex: 1,},});const view = grid.view.useValue();return (<div className="lng-grid" style={{ height: 500 }}><Grid.Root grid={grid}><Grid.Viewport><Grid.Header>{view.header.layout.map((row, i) => {return (<Grid.HeaderRow key={i} headerRowIndex={i}>{row.map((c) => {if (c.kind === "group") {return (<Grid.HeaderGroupCellkey={c.idOccurrence}cell={c}className="flex items-center gap-2 px-2"><div>{c.groupPath.at(-1)}</div></Grid.HeaderGroupCell>);}return (<Grid.HeaderCellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 capitalize"/>);})}</Grid.HeaderRow>);})}</Grid.Header><Grid.RowsContainer><Grid.RowsCenter>{view.rows.center.map((row) => {if (row.kind === "full-width") return null;return (<Grid.Row row={row} key={row.id}>{row.cells.map((c) => {return (<Grid.Cellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 text-sm"/>);})}</Grid.Row>);})}</Grid.RowsCenter></Grid.RowsContainer></Grid.Viewport></Grid.Root></div>);}
Column Group Header Height
Use the headerGroupHeight property to set the height of each column
group header row. Column groups can form multi-level hierarchies.
Column Group Header Height
"use client";import { Grid, useClientRowDataSource } from "@1771technologies/lytenyte-pro";import "@1771technologies/lytenyte-pro/grid.css";import type { Column } from "@1771technologies/lytenyte-pro/types";import { bankDataSmall } from "@1771technologies/sample-data/bank-data-smaller";import { useId } from "react";type BankData = (typeof bankDataSmall)[number];const columns: Column<BankData>[] = [{ id: "age", type: "number", groupPath: ["One Group"] },{ id: "job", groupPath: ["One Group", "Second Level"] },{ id: "balance", type: "number" },{ id: "education" },{ id: "marital" },];export default function ColumnHeaderGroupHeight() {const ds = useClientRowDataSource({ data: bankDataSmall });const grid = Grid.useLyteNyte({gridId: useId(),rowDataSource: ds,columns,headerGroupHeight: 20,columnBase: {widthFlex: 1,},});const view = grid.view.useValue();return (<div style={{ display: "flex", flexDirection: "column" }}><div style={{ display: "flex", gap: 8, alignItems: "center" }} className="py-2"><div>Change Header Group Height: </div><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.headerGroupHeight.set(20)}>Small</button><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.headerGroupHeight.set(50)}>Medium</button><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.headerGroupHeight.set(80)}>Large</button></div><div className="lng-grid" style={{ height: 500 }}><Grid.Root grid={grid}><Grid.Viewport><Grid.Header>{view.header.layout.map((row, i) => {return (<Grid.HeaderRow key={i} headerRowIndex={i}>{row.map((c) => {if (c.kind === "group") {return (<Grid.HeaderGroupCellkey={c.idOccurrence}cell={c}className="flex items-center gap-2 px-2"><div>{c.groupPath.at(-1)}</div></Grid.HeaderGroupCell>);}return (<Grid.HeaderCellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 capitalize"/>);})}</Grid.HeaderRow>);})}</Grid.Header><Grid.RowsContainer><Grid.RowsCenter>{view.rows.center.map((row) => {if (row.kind === "full-width") return null;return (<Grid.Row row={row} key={row.id}>{row.cells.map((c) => {return (<Grid.Cellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 text-sm"/>);})}</Grid.Row>);})}</Grid.RowsCenter></Grid.RowsContainer></Grid.Viewport></Grid.Root></div></div>);}
You can change the column group header height by updating the
headerGroupHeight state:
// Set the column group header height to 30pxgrid.state.headerGroupHeight.set(30);
Floating Row Height
The floating row appears as an extra header row under the column header.
It's useful for showing supplementary info or interactive components
like floating filters. Use the floatingRowHeight property to set its
height.
Floating Row Height
"use client";import { Grid, useClientRowDataSource } from "@1771technologies/lytenyte-pro";import "@1771technologies/lytenyte-pro/grid.css";import type { Column } from "@1771technologies/lytenyte-pro/types";import { bankDataSmall } from "@1771technologies/sample-data/bank-data-smaller";import { useId } from "react";type BankData = (typeof bankDataSmall)[number];const columns: Column<BankData>[] = [{ id: "age", type: "number" },{ id: "job" },{ id: "balance", type: "number" },{ id: "education" },{ id: "marital" },];export default function ColumnHeaderFloatingRowHeight() {const ds = useClientRowDataSource({ data: bankDataSmall });const grid = Grid.useLyteNyte({gridId: useId(),rowDataSource: ds,columns,floatingRowEnabled: true,floatingRowHeight: 20,columnBase: {widthFlex: 1,},});const view = grid.view.useValue();return (<div style={{ display: "flex", flexDirection: "column" }}><div style={{ display: "flex", gap: 8, alignItems: "center" }} className="py-2"><div>Change Floating Row Height: </div><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.floatingRowHeight.set(20)}>Small</button><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.floatingRowHeight.set(50)}>Medium</button><buttonclassName="rounded border border-gray-600 bg-gray-900 px-2 text-white dark:text-black"onClick={() => grid.state.floatingRowHeight.set(80)}>Large</button></div><div className="lng-grid" style={{ height: 500 }}><Grid.Root grid={grid}><Grid.Viewport><Grid.Header>{view.header.layout.map((row, i) => {return (<Grid.HeaderRow key={i} headerRowIndex={i}>{row.map((c) => {if (c.kind === "group") return null;if (c.kind === "floating") {return (<Grid.HeaderCellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 capitalize">Floating Cell</Grid.HeaderCell>);}return (<Grid.HeaderCellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 capitalize"/>);})}</Grid.HeaderRow>);})}</Grid.Header><Grid.RowsContainer><Grid.RowsCenter>{view.rows.center.map((row) => {if (row.kind === "full-width") return null;return (<Grid.Row row={row} key={row.id}>{row.cells.map((c) => {return (<Grid.Cellkey={c.id}cell={c}className="flex h-full w-full items-center px-2 text-sm"/>);})}</Grid.Row>);})}</Grid.RowsCenter></Grid.RowsContainer></Grid.Viewport></Grid.Root></div></div>);}
You can also update the floating row height dynamically:
// Set the floating row height to 24pxgrid.state.floatingRowHeight.set(24);
Column Groups
LyteNyte Grid lets you organize columns into groups to create visual relationships between related columns. Each column belongs to only one group. Groups can contain nested groups to form hierarchies.
Column Autosizing
LyteNyte Grid can automatically size columns to fit their content. Columns do not need to be visible to be autosized. The grid uses custom heuristic functions to determine optimal widths based on content.