Adaptable Buttons

Summary

  • Adaptable Buttons are widely used in AdapTable and are highly configurable and flexible
  • Buttons can appear standalone in AdapTable (e.g in the Dashboard, ToolPanel or Action Columns)
  • Buttons can also appear in an Adaptable Form (e.g. when using Alerts, Custom Export Destinations or DataSets)

An AdapTable Button is designed to be extremely configurable and styleable.

It contains many optional properties which can be provided as required.

The properties that use a function always receive the same 2 parameters when invoked (and returns an appropriate value):

Button Properties

The Adaptable Button has a number of properties and is defined as follows:

PropertyTypeDescriptionDefault
buttonStyleButtonStyle| ((button:AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) =>ButtonStyle)Style for Button - can be object or function that provides a ButtonStyle object
disabled(button:AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => booleanFunction that disables / enables the button based on its evaluation result
hidden(button:AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => booleanFunction which sets whether Button is hidden
iconAdaptableIcon| ((button:AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) =>AdaptableIcon)Icon for Button - can be object or function that provides a AdaptableIcon object
iconPosition'start' | 'end'Where the icon appears relative to the label'start'
labelstring | ((button:AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => string)Label for Button - can be string or function that provides string
onClick(button:AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => voidFunction to invoke when button is clicked
tooltipstring | ((button:AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => string)Tooltip for Button - can be string or function that provides string

onClick

onClick is the function which is called when the Button is clicked and returns void:

onClick?: (button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => void;

Note

Although not mandatory, this function should nearly always be provided in practice

label

The text to show as the Button's caption.

The property can return either a string or a function which returns a string:

label?: string |
  (((button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => string);

buttonStyle

Provides the Button Style for the Button.

The property can return either a ButtonStyle object or a function which returns a ButtonStyle:

buttonStyle?: ButtonStyle |
  ((button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => ButtonStyle);

toolTip

The text to use as the Button's Tooltip.

The property can return either a string or a function which returns a string:

toolTip?: string |
  ((button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => string);

hidden

Function that returns whether or not the Button will display.

Caution

If this property is not provided the Button will always be displayed

The function is invoked when the Button is about to be rendered - allowing you to decide whether it should display - and returns a boolean:

hidden?: (button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => boolean;

disabled

Function that disables / enables the button based on its evaluation result:

disabled?: (button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => boolean;

icon

The property can return either an AdaptableIcon or a function which returns an AdaptableIcon:

icon?: AdaptableIcon | ((button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => AdaptableIcon);

Find Out More

See the Guide to Adaptable Icons for details on how to provide custom icons

iconPosition

Where the icon appears relative to the label when the button is rendered inline (Dashboard, Toolbars, Action Columns, Forms):

iconPosition?: 'start' | 'end';
ValueLayout
startIcon, then label (default)
endLabel, then icon

Note

  • Applies to inline button rendering only.
  • In Action Columns with displayMode: 'dropdown', menu items always show icon then label; buttonStyle and iconPosition on individual buttons are ignored. See the Action Columns handbook for details.

Where buttons appear

All surfaces use the same Adaptable Button type, rendered by a shared internal component so behaviour stays consistent.

SurfaceTypical useDefault variant / tone when buttonStyle omits them
Dashboard buttonsHome / module shortcutstext / none
Custom Toolbar toolbarButtonsToolbar actionsoutlined / neutral
Tool Panel / Custom ToolPanelPanel actionstext / none
Action ColumnRow actionstext / none
Adaptable Form footersOK / Cancel / customFrom each button’s buttonStyle, or the form’s default tone

You can always override via buttonStyle on the button itself.

Serializable click handlers (Alerts)

For buttons whose logic cannot live in JSON state (because onClick is a function), use named handlers in options — the same pattern as Alert commandHandlers:

alertOptions: {
  commandHandlers: [
    {
      name: 'acknowledge',
      handler: (button, context) => { /* ... */ },
    },
  ],
},

Alert form buttons in state reference the handler by name; AdapTable resolves it at runtime. Action Column command values (edit, delete, clone, create) work the same way for row forms.

Note

A general handlerId registry for Action Columns and other surfaces would follow this model; today it is fully implemented for Alerts and Action Column commands.

Button Style

AdapTable provides a ButtonStyle object which defines how a Button will be visually rendered.

The object has 3 properties:

PropertyTypeDescriptionDefault
classNamestringCSS Classname to use for the Button
tone'success' | 'error' | 'neutral' | 'none' | 'warning' | 'info' | 'accent'Button's Tone - values: 'success', 'error', 'neutral', 'none', 'warning', 'info', 'accent''neutral'
variant'text' | 'outlined' | 'raised'How Button appears - values: 'text', 'outlined', 'raised''outlined'
Deep Dive

Understanding Button Style

Button Contexts

All the functions that the Button can receive, include a Context parameter.

Each implementation of the Adaptable Button in AdapTable will be provided with its own, bespoke, context property that contains information relevant to that particular use case.

Note

In addition the button argument is of generic type of the same Context

button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE

There are 8 Context Types - for 8 different use cases where Adaptable Buttons are provided:

ClassModuleWhen UsedBase Class
ActionColumnContextAction ColumnIn the generated buttonsBaseContext
AlertFormContextAlertWhen a Notification is displayedFormContext
ExportFormContextExportIn Custom Destination FormsFormContext
DashboardButtonContextDashboardIn Dashboard ButtonsBaseContext
CustomToolbarButtonContextCustom ToolbarButtons in Custom ToolbarsBaseContext
ToolPanelButtonContextToolPanelIn ToolPanel ButtonsBaseContext
CustomToolPanelButtonContextCustom ToolPanelButtons in Custom ToolPanelsBaseContext
DataSetFormContextDataSetWhen a DataSet displays a FormFormContext
Deep Dive

Understanding Button Context