Cell Plugins

Cell plugins define how specific properties behave and render in the Notion database.

A CellPlugin is a generic interface that accepts four type parameters:

  • Key: The unique identifier for the plugin.
  • Data: The data type stored in the cell.
  • Config (optional): The configuration type for the plugin.
  • Actions (optional): The actions that can be performed on the cell.

API Reference

CellPlugin

PropTypeDescription
id*KeyUnique identifier of the plugin.
default.name*stringDefault name used when a new column of this plugin is created.
default.icon*React.ReactNodeDefault icon used when a new column of this plugin is created.
default.config*ConfigDefault config used when a new column of this plugin is created.
default.widthnumberDefault width used when a new column of this plugin is created.
default.data*DataDefault data used when a new cell of this plugin is created.
fromReadableValue*(value: string, config: Config) => DataConverts a readable value to the plugin's data type.
toReadableValue*(data: Data) => stringConverts the plugin's data type to a readable value. This is useful for sorting a column.
toTextValue*(data: Data) => stringConverts the plugin's data type to a text value. This is useful for displaying/exporting the data in a compact format.
transferConfig(column: Column<TPlugin>, data: Rows) => stringConverts the given column and rows data to this plugin configuration. This is useful for changing column types.
reducer*React.Reducer<TableViewAtom<TPlugins>, Actions>The reducer function to handle actions related to this plugin. This is useful for updating the table state.
renderCell*(props: CellProps<Data, Config>) => React.ReactNodeRenders the cell for this plugin. This is where you define how the cell should look and behave in the UI.
renderConfigMenu(props: ConfigMenuProps<Config>) => React.ReactNodeRenders the configuration menu for this plugin. This is where you define how the column configuration should look.

CellProps

PropTypeDescription
propId*stringThe ID of the column this cell belongs to. This is useful for identifying the column in the table.
data*DataThe data of the cell. This is the value stored in the cell.
configConfigThe configuration of the cell. This can be used to customize the cell's behavior.
wrappedbooleanWhether the cell should be wrapped. This is useful for long text values that need to be displayed in multiple lines.
onChange(data: Data) => voidA callback function that is called when the cell data changes.

ConfigMenuProps

PropTypeDescription
propId*stringThe ID of the column this configuration menu belongs to. This is useful for identifying the column in the table.
configConfigThe configuration of the column. This can be used to customize the column's behavior.

Type Inference Utilities

TypeDescription
InferKey<TPlugin>Infers the plugin ID from CellPlugin.
InferData<TPlugin>Infers the cell data type.
InferConfig<TPlugin>Infers the column config type.
InferActions<TPlugin>Infers the plugin action type.
InferPlugin<TPlugins>Merges plugin types into a unified CellPlugin.

What's Next?

You can define plugins, columns, and rows in a flexible and strongly-typed way using these abstractions.

On this page