Search
Loading...
Skip to content

Navigation Bar

Actions that affect browser navigation (e.g. going back or closing the editor), have global effects on the scene (e.g. undo/redo and zoom), or process the scene in some way (e.g. saving and exporting) should be placed in the navigation bar.

Show or Hide the Navigation#

show: boolean is used to show or hide the complete navigation

position: string is used to set the location of the navigation bar to either top or bottom.

import CreativeEditorSDK from 'https://cdn.img.ly/packages/imgly/cesdk-js/1.60.0/index.js';
const config = {
license: 'mtLT-_GJwMhE7LDnO8KKEma7qSuzWuDxiKuQcxHKmz3fjaXWY2lT3o3Z2VdL5twm',
userId: 'guides-user',
ui: {
elements: {
view: 'default',
/* ... */
navigation: {
show: true, // 'false' to hide the navigation completely
position: 'top', // 'top' or 'bottom'
/* ... */
},
panels: {
/* ... */
},
dock: {
/* ... */
},
libraries: {
/* ... */
},
blocks: {
/* ... */
},
},
},
};
CreativeEditorSDK.create('#cesdk_container', config).then(async cesdk => {
// Do something with the instance of CreativeEditor SDK, for example:
// Populate the asset library with default / demo asset sources.
cesdk.addDefaultAssetSources();
cesdk.addDemoAssetSources({ sceneMode: 'Design', withUploadAssetSources: true });
await cesdk.createDesignScene();
});

Configure Navigation Buttons#

Navigation bar components are configured dynamically using the Navigation Bar Order API. The insertNavigationBarOrderComponent method allows you to add or insert components into the navigation bar.

Adding Action Buttons#

Use the actions dropdown component to add action buttons to the navigation bar:

import CreativeEditorSDK from 'https://cdn.img.ly/packages/imgly/cesdk-js/1.60.0/index.js';
const config = {
license: 'mtLT-_GJwMhE7LDnO8KKEma7qSuzWuDxiKuQcxHKmz3fjaXWY2lT3o3Z2VdL5twm',
userId: 'guides-user',
ui: {
elements: {
view: 'default',
/* ... */
navigation: {
show: true, // 'false' to hide the navigation completely
position: 'top', // 'top' or 'bottom'
},
panels: {
/* ... */
},
dock: {
/* ... */
},
libraries: {
/* ... */
},
blocks: {
/* ... */
},
},
},
};
CreativeEditorSDK.create('#cesdk_container', config).then(async cesdk => {
// Configure navigation bar actions after initialization
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
'ly.img.saveScene.navigationBar',
'ly.img.importScene.navigationBar',
'ly.img.exportImage.navigationBar',
'ly.img.exportPDF.navigationBar',
'ly.img.exportScene.navigationBar',
],
});
// Add back button at the beginning
cesdk.ui.insertNavigationBarOrderComponent(
'first',
{
id: 'ly.img.back.navigationBar',
onClick: () => {
// Handle back action
window.history.back();
},
},
'before',
);
// Add close button at the end
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.close.navigationBar',
onClick: () => {
// Handle close action
window.close();
},
});
// Populate the asset library with default / demo asset sources.
cesdk.addDefaultAssetSources();
cesdk.addDemoAssetSources({ sceneMode: 'Design', withUploadAssetSources: true });
await cesdk.createDesignScene();
});

Custom Call-To-Action Buttons#

Custom actions are added using the Navigation Bar Order API. Add custom buttons to the actions dropdown menu with full control over their behavior:

  • label a string, which can be an i18n key that will be looked up in the translation table.
  • icon defines the icon shown on the button. You can use any of the icon ids found within our IMG.LY Icon Set ‘Essentials’ (see full list here), or any icon id that you’ve added yourself using the addIconSet API (see details here).
  • onClick a custom callback function with the signature () => void | Promise<void>. This function is called when the button is clicked. If the function returns a promise, the button is disabled and a spinner is shown on the button until the promise resolves.
import CreativeEditorSDK from 'https://cdn.img.ly/packages/imgly/cesdk-js/1.60.0/index.js';
const config = {
license: 'mtLT-_GJwMhE7LDnO8KKEma7qSuzWuDxiKuQcxHKmz3fjaXWY2lT3o3Z2VdL5twm',
userId: 'guides-user',
ui: {
elements: {
view: 'default',
/* ... */
navigation: {
show: true, // 'false' to hide the navigation completely
position: 'top', // 'top' or 'bottom'
},
panels: {
/* ... */
},
dock: {
/* ... */
},
libraries: {
/* ... */
},
blocks: {
/* ... */
},
},
},
};
CreativeEditorSDK.create('#cesdk_container', config).then(async cesdk => {
// Add actions dropdown with custom buttons
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
// Default save button with custom behavior
{
id: 'ly.img.saveScene.navigationBar',
onClick: async () => {
const scene = await cesdk.engine.scene.saveToString();
console.log('Scene ready to save:', scene.length, 'characters');
// Production:
// await saveToBackend(scene);
cesdk.ui.showNotification('Scene saved successfully');
},
},
// Custom action button
{
id: 'ly.img.action.navigationBar',
key: 'custom-action', // Required for custom actions
label: 'common.custom', // string or i18n key
icon: '@imgly/Download', // icon id from our 'Essentials' set, or a custom icon id
onClick: () => {
// callback signature is `() => void | Promise<void>`
// place custom functionality here
},
},
// Share button
{
id: 'ly.img.shareScene.navigationBar',
onClick: () => {
// Custom share logic
navigator.share({
title: 'My Design',
text: 'Check out my design!',
url: window.location.href,
});
},
},
],
});
// Populate the asset library with default / demo asset sources.
cesdk.addDefaultAssetSources();
cesdk.addDemoAssetSources({ sceneMode: 'Design', withUploadAssetSources: true });
await cesdk.createDesignScene();
});

Rearrange Components#

There are 6 APIs for getting, setting, updating, removing, and inserting components in the Navigation Bar.

The content of the Navigation Bar changes based on the current edit mode ('Transform' (the default), 'Text', 'Crop', 'Trim', or a custom value), so all APIs accept an orderContext argument to specify the mode.

For example usage of similar APIs, see also Moving Existing Buttons or Adding New Buttons in the Guides section.

Note that the Navigation Bar is also configurable using our UI configuration.

Get the Current Order#

getNavigationBarOrder(
orderContext: OrderContext = { editMode: 'Transform' }
)

When omitting the orderContext parameter, the order for the 'Transform' edit mode is returned, e.g.

cesdk.ui.getNavigationBarOrder();
// => [
// {id: 'ly.img.back.navigationBar'},
// {id: 'ly.img.undoRedo.navigationBar'},
// ...
// ]

Set a new Order#

setNavigationBarOrder(
navigationBarOrder: (NavigationBarComponentId | OrderComponent)[],
orderContext: OrderContext = { editMode: 'Transform' }
)

When omitting the orderContext parameter, the order is set for the default edit mode ('Transform'), e.g.:

// Sets the order for transform mode by default
cesdk.ui.setNavigationBarOrder(['my.component.for.transform.mode']);

Update Components#

updateNavigationBarOrderComponent(
matcher: OrderComponentMatcher<OrderComponent<NavigationBarComponentId>>,
update: NavigationBarComponentId | Partial<OrderComponent<NavigationBarComponentId>> | ((component: OrderComponent<NavigationBarComponentId>) => Partial<OrderComponent<NavigationBarComponentId>>),
orderContext?: OrderContext
)

Updates existing components in the navigation bar. The matcher can be:

  • 'first' or 'last' - matches the first or last component
  • A number - matches the component at that index
  • A component ID string
  • A partial object describing the component to match
  • A function that receives the component and index, returning true if it matches

The update can be:

  • A new component ID string
  • A partial object with updated properties
  • A function that receives the current component and returns the updated one

Returns an object with the number of updated components and the updated order array.

// Change the save button label and style for a specific context
cesdk.ui.updateNavigationBarOrderComponent(
'ly.img.saveScene.navigationBar',
component => ({
...component,
label: 'Save Draft',
color: 'accent',
}),
);
// Disable export buttons when user doesn't have export permissions
cesdk.ui.updateNavigationBarOrderComponent(
{ id: 'ly.img.exportImage.navigationBar' },
{ isDisabled: true },
);
// Replace the default actions with a custom action button
cesdk.ui.updateNavigationBarOrderComponent(
component => component.id === 'ly.img.actions.navigationBar',
{
id: 'ly.img.customAction.navigationBar',
label: 'Publish',
icon: '@imgly/Share',
},
);

Remove Components#

removeNavigationBarOrderComponent(
matcher: OrderComponentMatcher<OrderComponent<NavigationBarComponentId>>,
orderContext?: OrderContext
)

Removes components from the navigation bar. The matcher can be:

  • 'first' or 'last' - matches the first or last component
  • A number - matches the component at that index
  • A component ID string
  • A partial object describing the component to match
  • A function that receives the component and index, returning true if it matches

Returns an object with the number of removed components and the updated order array.

// Remove PDF export option for mobile users
cesdk.ui.removeNavigationBarOrderComponent('ly.img.exportPDF.navigationBar');
// Remove all export buttons for users without export permissions
cesdk.ui.removeNavigationBarOrderComponent(component =>
component.id.includes('export'),
);
// Remove the close button in embedded mode
cesdk.ui.removeNavigationBarOrderComponent({
id: 'ly.img.close.navigationBar',
});

Insert Components#

insertNavigationBarOrderComponent(
matcher: OrderComponentMatcher<OrderComponent<NavigationBarComponentId>>,
component: NavigationBarComponentId | OrderComponent<NavigationBarComponentId>,
location?: InsertOrderComponentLocation,
orderContext?: OrderContext
)

Inserts new components into the navigation bar. The matcher can be:

  • 'first' or 'last' - matches the first or last component
  • A number - matches the component at that index (e.g., 2)
  • A component ID string (e.g., 'ly.img.saveScene.navigationBar')
  • A partial object describing the component to match (e.g., { id: 'ly.img.saveScene.navigationBar' })
  • A function that receives the component and index, returning true if it matches

The location can be:

  • 'before' - Insert before the matched component
  • 'after' - Insert after the matched component (default)
  • 'replace' - Replace the matched component

Returns the updated navigation bar order array.

// Add actions dropdown at the end of the navigation bar
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
'ly.img.saveScene.navigationBar',
'ly.img.exportImage.navigationBar',
],
});
// Add a back button at the beginning
cesdk.ui.insertNavigationBarOrderComponent(
'first',
{
id: 'ly.img.back.navigationBar',
onClick: () => window.history.back(),
},
'before',
);
// Insert a custom button after the save button
cesdk.ui.insertNavigationBarOrderComponent(
{ id: 'ly.img.saveScene.navigationBar' },
{
id: 'ly.img.custom.navigationBar',
label: 'Custom Action',
onClick: () => console.log('Custom action'),
},
'after',
);

The following lists the default Navigation Bar components available within CE.SDK.

Available Action Components#

These components can be added to the ly.img.actions.navigationBar container:

Component IDDescription
ly.img.saveScene.navigationBarSave scene action - saves the current scene
ly.img.importScene.navigationBarLoad scene action - loads a scene file
ly.img.exportScene.navigationBarDownload scene action - downloads the current scene
ly.img.exportImage.navigationBarExport as image - exports the design as an image file
ly.img.exportPDF.navigationBarExport as PDF - exports the design as a PDF file
ly.img.exportVideo.navigationBarExport as video - exports the design as a video file
ly.img.exportArchive.navigationBarCreate archive - creates an archive of the scene
ly.img.importArchive.navigationBarLoad archive - loads an archive file
ly.img.shareScene.navigationBarShare action - custom share functionality
ly.img.action.navigationBarCustom action button (requires key property)

Layout Helpers#

Component IDDescription
ly.img.separatorAdds a vertical separator (<hr> element) in the Navigation Bar.
Separators follow some special layouting rules:
- If 2 or more separators end up next to each other (e.g. due to other components not rendering), only 1 separator will be rendered.
- Separators that end up being the first or last element in the Inspector Bar will not be rendered.
- Separators directly adjacent to the left side of a spacer (see below) will not be rendered.
ly.img.spacerAdds horizontal spacing in the Navigation Bar.
Spacers will try to fill all available whitespace, by distributing the available space between all spacers found in the Navigation Bar.

Common Controls#

Component IDDescription
ly.img.title.navigationBarTitle:
A section displaying the title of the currently opened scene file.

The title displayed on the UI is set by the config.ui.elements.navigation.title parameter. If this parameter is not specified, the system will instead check the component’s payload. To define a payload, rather than adding the ID directly to the order, insert an object structured like this: { id: 'ly.img.title.navigationBar', title: 'My Scene' }
ly.img.back.navigationBarBack button:
A button used to navigate to the previous page. Note that this button is hidden by default, and can be configured using the UI Elements configuration.
ly.img.close.navigationBarClose button:
A button used to close the editor. Note that this button is hidden by default, and can be configured using the UI Elements configuration.
ly.img.undoRedo.navigationBarUndo/Redo controls:
Two buttons for un-doing and re-doing recent changes.
ly.img.pageResize.navigationBarPage Resize button:
A button used to control the page resize panel.
ly.img.zoom.navigationBarZoom controls:
Two buttons for zooming the view in and out, separated by a third button showing the current zoom level and opening a dropdown offering common zoom operations (Auto-Fit Page, Fit Page, Fit Selection, 200% Zoom, 100% Zoom, 50% Zoom, Zoom In, Zoom Out).
ly.img.preview.navigationBarPreview button:
Toggles Preview mode, which allows viewing and editing the scene like an Adopter would (e.g. with all Placeholder constraints enforced). Changes made in Preview are not saved and will be discarded when leaving Preview.
ly.img.actions.navigationBarCall To Action buttons:
A dropdown container for action buttons. You can customize its children to include any combination of save, export, load, and custom action buttons. The first child appears as a prominent button in the navigation bar, while additional children appear in the dropdown menu.

Default Order#

The default order of the Navigation Bar is the following:

[
'ly.img.undoRedo.navigationBar',
'ly.img.pageResize.navigationBar',
'ly.img.spacer',
'ly.img.title.navigationBar',
'ly.img.spacer',
'ly.img.zoom.navigationBar',
'ly.img.preview.navigationBar',
];

Integration with Callbacks API#

Action buttons in the navigation bar automatically trigger the corresponding callbacks registered with the Callbacks API when used as string IDs. You can also provide custom onClick handlers to override the default behavior.

Using Registered Callbacks#

// Register callbacks with the Callbacks API
cesdk.actions.register('saveScene', async () => {
const scene = await cesdk.engine.scene.saveToString();
console.log('Scene ready to save:', scene.length, 'characters');
// Production:
// await fetch('/api/scenes', {
// method: 'POST',
// body: JSON.stringify({ scene }),
// headers: { 'Content-Type': 'application/json' },
// });
cesdk.ui.showNotification('Scene saved successfully');
});
cesdk.actions.register('exportDesign', async (options) => {
const { blobs, options: exportOptions } = await cesdk.utils.export(options);
console.log('Export ready:', blobs[0].size, 'bytes');
// Production:
// await uploadToCDN(blobs[0]);
cesdk.ui.showNotification('Export successful');
});
// Add navigation buttons that will use registered callbacks
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
'ly.img.saveScene.navigationBar', // Uses registered saveScene callback
'ly.img.exportImage.navigationBar', // Uses registered exportDesign callback
],
});

Custom onClick Override#

// Override default callback with custom onClick handler
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
{
id: 'ly.img.saveScene.navigationBar',
onClick: async () => {
// Custom logic that overrides the registered callback
const scene = await cesdk.engine.scene.saveToString();
console.log('Scene ready for custom save:', scene.length, 'characters');
// Production:
// await customSaveLogic(scene);
},
},
],
});

Default Behaviors#

The following action components trigger their corresponding callbacks when used as string IDs:

Component IDCallback TriggeredDefault Behavior
ly.img.saveScene.navigationBarsaveSceneDownloads the scene as a .scene file to the user’s device
ly.img.importScene.navigationBarimportSceneOpens a file picker to load a .scene file from the user’s device
ly.img.exportScene.navigationBarexportSceneDownloads the current scene as a .scene file
ly.img.exportImage.navigationBarexportDesignExports and downloads the design as an image file (PNG/JPEG)
ly.img.exportPDF.navigationBarexportDesignExports and downloads the design as a PDF file
ly.img.exportVideo.navigationBarexportDesignExports and downloads the design as a video file (MP4)
ly.img.exportArchive.navigationBarexportSceneCreates and downloads an archive of the scene with all assets
ly.img.importArchive.navigationBarimportSceneOpens a file picker to load an archive file
ly.img.shareScene.navigationBarshareSceneNo default behavior - requires callback registration

Using Default vs Custom Behaviors#

Example 1: Default Behavior#

When using just the string ID without registering a custom callback, the default behavior is triggered (downloads the file to the user’s device):

// Using default behavior - downloads scene file to user's device
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
'ly.img.saveScene.navigationBar', // Uses default download behavior
],
});

Example 2: Custom Behavior via Registered Callback#

Register a custom callback to override the default behavior for all instances of the button:

// Register custom saveScene callback
cesdk.actions.register('saveScene', async () => {
const scene = await cesdk.engine.scene.saveToString();
console.log('Scene ready to save:', scene.length, 'characters');
// Production:
// await fetch('/api/scenes', {
// method: 'POST',
// body: JSON.stringify({ scene }),
// headers: { 'Content-Type': 'application/json' },
// });
cesdk.ui.showNotification('Scene saved to cloud');
});
// String ID now uses the registered callback instead of default
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
'ly.img.saveScene.navigationBar', // Triggers registered saveScene callback
],
});

Example 3: Custom Behavior via onClick Handler#

Provide a custom onClick handler directly in the component configuration to override both default and registered callbacks:

// Override with custom onClick handler
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
{
id: 'ly.img.saveScene.navigationBar',
onClick: async () => {
// This custom onClick overrides any registered callback
const scene = await cesdk.engine.scene.saveToString();
console.log('Scene ready for alternative save:', scene.length, 'characters');
// Production:
// await alternativeSaveLogic(scene);
cesdk.ui.showNotification('Saved with alternative method');
},
},
],
});