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)
Topics on this Page
| Topic | Summary |
|---|---|
| Button properties | AdaptableButton fields |
| Where buttons appear | Dashboard, forms, exports |
| Button contexts | Handler context per surface |
Find Out More
Pairs with Adaptable Forms · UI Guides.
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):
- the button itself (with a generic ButtonContext)
- an appropriate ButtonContext (matching the one of the Button)
Button Properties
The Adaptable Button has a number of properties and is defined as follows:
A button on a form, alert or toolbar.
label is the text. onClick runs when it is clicked and receives the button and the form or event context. buttonStyle and icon are optional. disabled and hidden are functions that return whether the button is disabled or hidden.
| Property | Type | Description | Default |
|---|---|---|---|
| buttonStyle | ButtonStyle| ((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) => boolean | Function that disables / enables the button based on its evaluation result | |
| hidden | (button:AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => boolean | Function which sets whether Button is hidden | |
| icon | AdaptableIcon| ((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' |
| label | string | ((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) => void | Function to invoke when button is clicked | |
| tooltip | string | ((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';| Value | Layout |
|---|---|
start | Icon, then label (default) |
end | Label, then icon |
Note
- Applies to inline button rendering only.
- In an Action Column Menu, items use the Control's own
labelandicon. 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.
| Surface | Typical use | Default variant / tone when buttonStyle omits them |
|---|---|---|
| Dashboard buttons | Home / module shortcuts | text / none |
Custom Toolbar toolbarButtons | Toolbar actions | outlined / neutral |
| Tool Panel / Custom ToolPanel | Panel actions | text / none |
| Action Column Button | Row actions | text / none (set via style) |
| Adaptable Form footers | OK / Cancel / custom | From 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:
Appearance of an AdapTable button.
variant is 'text', 'outlined' (the default) or 'raised'. tone is the colour: 'neutral' (the default), 'success', 'error', 'warning', 'info', 'accent' or 'none'. className adds a CSS class.
| Property | Type | Description | Default |
|---|---|---|---|
| className | string | CSS 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_TYPEThere are 8 Context Types - for 8 different use cases where Adaptable Buttons are provided:
| Class | Module | When Used | Base Class |
|---|---|---|---|
ActionColumnContext | Action Column | In the generated buttons | BaseContext |
AlertFormContext | Alert | When a Notification is displayed | FormContext |
ExportFormContext | Export | In Custom Destination Forms | FormContext |
DashboardButtonContext | Dashboard | In Dashboard Buttons | BaseContext |
CustomToolbarButtonContext | Custom Toolbar | Buttons in Custom Toolbars | BaseContext |
ToolPanelButtonContext | ToolPanel | In ToolPanel Buttons | BaseContext |
CustomToolPanelButtonContext | Custom ToolPanel | Buttons in Custom ToolPanels | BaseContext |
DataSetFormContext | DataSet | When a DataSet displays a Form | FormContext |
Deep Dive
Understanding Button Context
FAQ
Button vs Form? Forms contain fields and optional buttons; standalone buttons appear on Dashboard, toolbars, and action columns without a full form wrapper.
Do buttons support icons?
Yes — via Adaptable Icon on the icon property.