By default, the main navigation in Theme-Cosmos is collapsed and only icons are visible. Navigation expands on mouse hover or when any of the elements inside the navigation is focused.
In some cases, there may be a reasonable need to keep the navigation expanded at all times. This can be achieved by adding additional CSS styling to the application.
Although, there is one thing to be aware of when using this solution: the expanded navigation will take up screen space, which means that the rest of the content will have less space to fit in.
Styling needed to keep main navigation expanded
In Theme-Cosmos portal can be displayed in two ways:
With “Display application header” option enabled
With “Display application header” option disabled
CSS styling needed for portal with the “Display application header” option enabled:
To add the proposed CSS styling to the application use “py-cosmos-custom-css” file. Simply override this file to your application and add custom CSS code there.
And create a custom Javascript function in “py-cosmos-custom-js” file to toggle this styling class (based on the existence of the class Navigation will be pinned or not). Something like this:
var togglePinnedNavigation = function() {
var page = document.querySelector('.screen-layout-header_left');
if (page) {
if (page.classList.contains('pinned-navigation')) {
page.classList.remove('pinned-navigation'); // Remove the class if it exists
} else {
page.classList.add('pinned-navigation'); // Add the class if it doesn't exist
}
}
};
Then add a button and set its “Click” action to be “Run script” with "“togglePinnedNavigation”.
Clicking on the button will now pin/unpin the navigation.
Something to consider:
navigation would be unpinned be default
pinned state would not be “remembered” in new tabs or on browser refresh