Search Docs
Loading...
Skip to content

Reorder Components

Rearrange UI components using getComponentOrder() to inspect the current layout and setComponentOrder() to define custom arrangements.

Reorder Components example showing a customized editor interface

5 mins
estimated time
Download
StackBlitz
GitHub

The Component Order API lets you customize the layout of all five UI areas by getting and setting the component order array. Each area maintains an ordered list of components that determines their visual arrangement.

This guide covers how to get the current component order, set a custom order, use component objects for inline configuration, set edit mode-specific orders, and move individual components programmatically.

UI Areas#

CE.SDK provides five customizable UI areas.

AreaLocationPurpose
'ly.img.navigation.bar'TopNavigation and actions
'ly.img.dock'SideAsset library access
'ly.img.inspector.bar'SideProperty controls
'ly.img.canvas.menu'CanvasContext menu
'ly.img.canvas.bar'Above/below canvasContextual controls

The canvas bar requires the at option specifying 'top' or 'bottom'.

Get Current Order#

Use getComponentOrder() to inspect the current arrangement of components in any UI area.

// Get the current order of components in the navigation bar
const defaultOrder = cesdk.ui.getComponentOrder({
in: 'ly.img.navigation.bar'
});
console.log('Default navigation bar order:', defaultOrder);

The method returns an array of component objects, each with an id property and optional configuration. This is useful for understanding the default layout before making changes.

Set Custom Order#

Use setComponentOrder() to define a new component arrangement. Pass an array of component IDs or component objects.

// Set a custom order with title centered and actions grouped
cesdk.ui.setComponentOrder({ in: 'ly.img.navigation.bar' }, [
'ly.img.back.navigationBar',
'ly.img.spacer',
'ly.img.title.navigationBar',
'ly.img.spacer',
'ly.img.undoRedo.navigationBar',
'ly.img.actions.navigationBar'
]);
console.log('Navigation bar reordered with centered title');

The component array completely replaces the existing order. Components not included in the array will not appear in that area.

Canvas Bar Positioning#

The canvas bar is unique in requiring a position parameter. Use at: 'top' or at: 'bottom' for both get and set operations.

// Canvas bar requires the 'at' option for top or bottom positioning
const canvasBarOrder = cesdk.ui.getComponentOrder({
in: 'ly.img.canvas.bar',
at: 'top'
});
console.log('Canvas bar (top) order:', canvasBarOrder);
// Set a custom canvas bar order
cesdk.ui.setComponentOrder({ in: 'ly.img.canvas.bar', at: 'top' }, [
'ly.img.page.add.canvasBar',
'ly.img.spacer',
'ly.img.zoom.canvasBar'
]);

Using Component Objects#

Pass component objects instead of string IDs when you need inline configuration. This is useful for components like the asset library that accept additional options.

// Use component objects for inline configuration
cesdk.ui.setComponentOrder({ in: 'ly.img.dock' }, [
'ly.img.spacer',
{
id: 'ly.img.assetLibrary.dock',
entries: ['ly.img.image', 'ly.img.text', 'ly.img.shape']
}
]);
console.log('Dock reordered with custom asset library entries');

The entries property specifies which asset categories appear in the dock’s asset library button.

Edit Mode Specific Orders#

Set different orders for specific edit modes using the when context. This lets you show different controls based on what the user is editing.

// Set different orders for specific edit modes
cesdk.ui.setComponentOrder(
{ in: 'ly.img.inspector.bar', when: { editMode: 'Text' } },
[
'ly.img.text.typeFace.inspectorBar',
'ly.img.text.fontSize.inspectorBar',
'ly.img.separator',
'ly.img.text.bold.inspectorBar',
'ly.img.text.italic.inspectorBar'
]
);
console.log('Inspector bar customized for Text edit mode');

Common edit modes include Transform, Crop, Trim, and Text. The order only applies when the specified edit mode is active.

Moving Components#

Combine getComponentOrder() and setComponentOrder() to move individual components. Get the current order, modify the array, and set it back.

// Move a specific component to the beginning
const navOrder = cesdk.ui.getComponentOrder({
in: 'ly.img.navigation.bar'
});
const actionsIndex = navOrder.findIndex(
(c) => c.id === 'ly.img.actions.navigationBar'
);
if (actionsIndex > 0) {
const [actions] = navOrder.splice(actionsIndex, 1);
navOrder.unshift(actions);
cesdk.ui.setComponentOrder({ in: 'ly.img.navigation.bar' }, navOrder);
console.log('Moved actions to the beginning of navigation bar');
}

Use standard array methods like splice, unshift, and push to rearrange components.

Troubleshooting#

Components not rendering — Ensure all component IDs in the array are valid and registered. Invalid IDs are silently ignored.

Canvas bar error — Remember to include at: 'top' or at: 'bottom' for canvas bar operations.

Order not persisting — Component orders are in-memory only. Persist to your own storage if needed across sessions.

API Reference#

MethodCategoryPurpose
cesdk.ui.getComponentOrder()UIGet current component order for an area
cesdk.ui.setComponentOrder()UISet complete component order for an area

Next Steps#