Tesserae

GridPicker

Description

The GridPicker component creates an interactive grid of buttons, where each cell can have multiple states. It is used for building grid-based state selectors and pickers, such as scheduling interfaces or game boards. The component is part of the Tesserae UI Components group and leverages a fluent interface to configure button appearance and behavior based on the state.

Usage

Create a GridPicker instance by providing arrays of column and row names, the number of states each cell can have, an initial state for every cell, and a function to format each button based on its state. Optionally, you can provide custom column sizes and row heights.

Below is a simple usage example:

API reference

class

GridPicker

public sealed class GridPicker : IComponent

A GridPicker component that allows users to select states across a grid of buttons, supporting drag-to-select functionality.

Constructors

Constructor
GridPicker
public GridPicker(string[] columnNames, string[] rowNames, int states, int[][] initialStates, Action<Button, int, int> formatState, UnitSize[] columns = null, UnitSize rowHeight = null)

Initializes a new instance of the GridPicker class.

Parameters

columnNames
Names of the columns.
rowNames
Names of the rows.
states
Number of available states for each grid cell.
initialStates
Initial state values for each cell.
formatState
An action to format the button based on its state.
columns
Optional column widths.
rowHeight
Optional row height.

Properties

Property
GridPicker.IsDragging
public bool IsDragging

Gets whether the grid picker is currently being dragged.

Methods

Method
GridPicker.GetState
public int[][] GetState()

Gets the current state of the grid picker.

Returns

A 2D array representing the states.

Method
GridPicker.SetState
public GridPicker SetState(int[][] state)

Sets the current state of the grid picker.

Parameters

state
A 2D array representing the new states.

Returns

The current instance of the type.

Method
GridPicker.OnChange
public GridPicker OnChange(ComponentEventHandler<GridPicker, Event> onChange)

Adds a change event handler to the grid picker.

Parameters

onChange
The event handler.

Returns

The current instance of the type.

Method
GridPicker.Render
public HTMLElement Render()

Renders the grid picker.

Returns

The rendered HTMLElement.

Samples

Basic GridPicker Example

The following sample demonstrates how to instantiate a simple GridPicker with two states. Each cell displays different text based on its current state.

Advanced GridPicker for Hourly Schedule

This sample shows how to create an hourly schedule picker by dynamically generating column headers for each hour of the day.

See also

  • Button – Often used in combination with GridPicker for interactive elements.
  • TextBlock – Useful for creating header or descriptive text in grid layouts.
© 2026 Tesserae. All rights reserved.