Adding navigation to application

UI Bakery supports both in-app and external navigation. In this article, we'll explore these options in more details.

In-App Navigation

There are a number of ways to configure navigation inside the application:

You can configure navigation both to an internal application page as well as to an external website.

You can configure navigation using the Menu and Horizontal menu components.

To do so, simply add the component to the working area. In its Items property resource selector, your existing app pages will be selected by default. You can add more pages to the app, select custom icons for them, and edit existing ones - all changes will be synced instantly.

If you need a manual setup, you can switch to the JS mode and map the {{app.menuItems}} to configure the Menu exactly how you want it.

You can also add an item to your menu that will redirect users to an external link.

Another way to configure custom navigation in the app is by using our reusable header and sidebar options. You can select either of them in the right side panel, place a Menu component inside, and that's it. You don't have to add them to each page separately since they save their state across all app pages.

Check out the pages below to learn more👇

Reusable headerReusable sidebar

When using Link or Button components, you can pass dynamic parameters to a Detail page configuring the Query params property of the component. As an example, we'll review the case when you want to display the selected object on a child page on button click.

Check out the instruction below👇

As a prerequisite, you already have a Table and Button components added to your working area.

  1. First, navigate to the Pages tab in the left side panel and create a new page (we'll name it Customer since it will display customer details).

  2. Add a Detail component on this page to display customer details.

  3. Now, go back to the Home page, select the Button component and set the Customer page as the URL in the right side panel.

  4. Next, in the Query params property, switch to JS mode and configure the primary key of the object:

{
  id: {{ui.customersTable.selectedRow.data.customer_id}}
}

In our example, the currently selected customer id will be sent as an id query parameter to the Customer page.

  1. Next, create a new action of the Load Row type for your current Table.

  2. In the Filters section, for customer_id specify the following variable to receive the URL query parameter on the child page:

{{activeRoute.queryParams.id}}

  1. Assign the Load Row action to the Detail component on the Customer page.

That's it! Now, if you select a row in the Table and then click the Show customer button, you will navigate to the child page with the selected customer displayed in the Detail component.

External navigation

External navigation can be also configured using components like Button, Menu, etc. Here, we'll review two use cases of configuring redirect to an external page.

Use case: Redirect following a trigger

  1. Add a Button component to your working area.

  2. Create a JavaScript Code action and specify the following code adding your external link:

const a = document.createElement('a');
a.href = 'https://google.com';
a.target = '_top';
a.click();

or the following code to open the link in a new tab:

window.open('https://google.com');
return 1;
  1. Assign this action to the button's On Click trigger.

Use case: Menu item external redirect

  1. Select your Menu component and switch to JS mode in the Items property.

  2. Now, modify this property and add a new item that will redirect to an external page:

{
    title: 'Documents',
    link: '/docs'
  }
  1. Next, navigate to the Triggers section of the component and create a new action for the On Item Click trigger.

  2. Select a JavaScript Code action step and add the following code:

if (data.link === '/docs') {
	window.open('https://docs.uibakery.io/');
}
return {{data}}

In this code, we use UI Bakery Docs as an example. Replace the URL with the one you want to open on clicking the new menu item.

Now, when clicking the new menu item, the external link will open in a new tab.

  1. (Optional) If you want the external link to open in the same tab, you need to add the '_parent' parameter to the following function:

window.open('https://docs.uibakery.io/', '_parent')

Last updated

Was this helpful?