Presets

Generated by website/scripts/generate-api.ts from packages/gridla/src. Do not edit by hand; run bun run generate in website/.

Arrange items into rows, columns, or a grid that fills the canvas.

import { applyPreset } from 'gridla'
import type { LayoutPreset, PresetOptions } from 'gridla'
ExportKindSummary
applyPresetfunctionRebuild layout.items so the given ids tile the canvas as rows, columns, or a grid.
LayoutPresettypeArrangement produced by applyPreset: full-width rows stacked vertically, full-height columns side by side, or a grid with a fixed column count.
PresetOptionstypeOptions for applyPreset.

Functions

applyPreset

function · core/presets.ts:42

Rebuild layout.items so the given ids tile the canvas as rows, columns, or a grid. Ids keep their constraints; new ids use defaultSize.

export function applyPreset<T = unknown>(
  layout: GridLayout<T>,
  preset: LayoutPreset,
  ids: readonly string[] = layout.items.map((item) => item.id),
  options: PresetOptions = {},
): GridLayout<T>

Types

LayoutPreset

type · core/presets.ts:13

Arrangement produced by applyPreset: full-width rows stacked vertically, full-height columns side by side, or a grid with a fixed column count.

export type LayoutPreset = 'rows' | 'columns' | 'grid'

PresetOptions

type · core/presets.ts:16

Options for applyPreset.

export type PresetOptions = {
  /** Spacing between cells. Defaults to the smallest gap already in the layout. */
  gap?: number
  /** Column count for `grid`. Defaults to 2. */
  columns?: number
  /** Fallback size for ids that are not in the layout yet. */
  defaultSize?: GridItemSize
}
MemberTypeDescription
gap?numberSpacing between cells. Defaults to the smallest gap already in the layout.
columns?numberColumn count for grid. Defaults to 2.
defaultSize?GridItemSizeFallback size for ids that are not in the layout yet.