Css for formatting right-justified hamburger menu

Hello, I am trying to create a title bar with hamburger menu on the far right of the display. So far I've only been able to get the menu to be the width of the hamburger menu header (50px). Can you advise on how to keep the hamburger icon on the far right, but make the menu container the width of its items & submenu items, expanding to the left? Here's a simple example of the title bar layout I'm looking for:

<div class="d-flex justify-content-between">

    <div class="d-flex">Title Text</div>

    <div class="d-flex">

        <SfMenu

            TValue="DataModel"

            Items="@menuItems"

            HamburgerMode="true"

            ShowItemOnClick="true"

            Title="">

        </SfMenu>

    </div>

</div>



@code

{

    private List<DataModel> menuItems = new List<DataModel>

    {

        new DataModel { Id = "parent1", Text = "Appliances" },

        new DataModel { Id = "parent2", Text = "Accessories" },

        new DataModel { Id = "parent6", Text = "Kitchen", ParentId = "parent1" },

        new DataModel { Id = "parent7", Text = "Washing Machine", ParentId = "parent1" },

        new DataModel { Id = "parent8", Text = "Air Conditioners", ParentId = "parent1" }

    };


    private class DataModel

    {

        public string? Text { get; set; }

        public string? Id { get; set; }

        public string? ParentId { get; set; }

    }

}


16 Replies

DA Dave February 13, 2022 02:10 AM UTC

Checking back. Any advice?



GK Gayathri KarunaiAnandam Syncfusion Team February 15, 2022 04:12 PM UTC

 
We have validated your code snippet. You have used the flex class to move the menu to the right. We can move the menu items to the left by using the margin-left property. Please check the below code snippet. 
 
Code: 
<style> 
 .e-menu-container.e-hamburger .e-menu-header:not(.e-vertical){ 
    margin-left : 200px; 
} 
</style> 
  
For your convenience, please check the below sample link. 
 
Sample:  
 
Please check and get back to us, if you need further assistance. 
 
Regards, 
Gayathri K 



DA Dave February 15, 2022 11:05 PM UTC

Gayathri, thank you for your reply. Your solution does make the menu items appear as I would like them to. I'm using a hamburger primarily for phone use and need the div containing the hamburger icon to be as narrow as possible (50 px in the original code). Is there a way to have the menu items appear as your solution does but keep the hamburger icon div width unchanged? Thanks again.



GK Gayathri KarunaiAnandam Syncfusion Team February 18, 2022 04:34 AM UTC

Hi Dave, 
 
We can resolve the reported issue by setting minimum width to hamburger menu. We have prepared a sample based on customer requirement. Please check the below code snippet. 
 
Code snippet: 
 
<style> 
 .e-menu-container.e-hamburger{ 
    min-width: 120px; 
} 
 .e-menu-container.e-hamburger .e-menu-header .e-menu-icon{ 
     float:right; 
 } 
</style> 
 
For your reference, please check the below sample link. 
 
 
Please check and get back to us, if you need further assistance. 
 
Regards, 
Gayathri K 



DA Dave February 19, 2022 12:32 AM UTC

Gayathri, thank you for taking the effort to help me with my problem. I successfully downloaded and ran your sample. It shows the menu items as I would like however I need the <div> for the hamburger icon itself to be as narrow as possible because I will be putting things like title text and an Edit switch across the top row on a small screen. Please see the attached sketch for example. Is there a way to get the hamburger <div> narrow while keeping the menu dropdown wide enough for the menu and submenu items? Thank you.


Attachment: 20220218_0956_5bffcc5.zip


GK Gayathri KarunaiAnandam Syncfusion Team February 22, 2022 04:20 AM UTC

Hi Dave, 
 
We have created the menu hamburger icon  and menu items within menu-container element. So, the width for hamburger icon is also applied to menu items. We have checked your sketch. We will check the feasibility to achieve your requirement by using Dropdown Button component with hamburger menu. So, we will update further details on February 24th,2022. 
 
Regards, 
Gayathri K 



DA Dave March 15, 2022 01:33 AM UTC

Gayathri, Just checking back in on this. Any suggestions or solutions? Thanks.



GK Gayathri KarunaiAnandam Syncfusion Team March 18, 2022 06:41 AM UTC

Hi Dave, 
 
We have prepared a sample based on your requirement by using DropdownButton component. Please refer the below code example and attached sample for more information. 
 
Code: 
 
<SfDropDownButton CssClass="e-small e-caret-hide e-hamburger-menu" IconCss="e-icons e-menu-icon" IconPosition="SplitButtonIconPosition.Top"> 
        <PopupContent> 
            <SfMenu TValue="DataModel" Items="@menuItems" HamburgerMode="true" ShowItemOnClick="true" Title="" @ref="MenuObj"> </SfMenu> 
            <DropDownButtonEvents  Opened="OnOpen" ></DropDownButtonEvents> 
        </PopupContent> 
    </SfDropDownButton> 
 
@code 
 
{   public async Task OnOpen() 
    { 
        await MenuObj.Open(); 
          
    } 
} 
<style> 
.e-menu-container.e-hamburger .e-menu-header:not(.e-vertical){ 
    display: none !important; 
} 
.e-hamburger-menu .e-menu-icon::before{ 
    content:'\e7cd'; 
    color:black; 
} 
.e-dropdown-popup{ 
        margin: 0px -170px; 
} 
.e-menu-container.e-hamburger ul.e-menu:not(.e-vertical){ 
    width:200px !important; 
} 
.e-small.e-btn.e-top-icon-btn{ 
    line-height: 1; 
    padding: 0px; 
    width: 20px; 
    background: white; 
} 
</style> 
 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Gayathri K 



DA Dave March 20, 2022 03:34 AM UTC

Gayathri, your solution works. Thanks for taking the time to help on this.



GK Gayathri KarunaiAnandam Syncfusion Team March 21, 2022 04:25 AM UTC

Hi Dave, 
 
You are most welcome. 
 
We are happy to hear that your requirement has been fulfilled. Kindly get back to us if you need any further assistance. 
 
Regards, 
Gayathri K 



DA Dave September 13, 2022 11:36 PM UTC

UPDATE: after switching over from Syncfusion.Blazor NuGet package to individual NuGet packages (Navigations and SplitButtons) and  bootstrap5, the sample provided above no longer works. No menu popup appears when the hamburger icon is clicked. Can you recommend how to change the code for these recent changes? Thank you.



YA YuvanShankar Arunagiri Syncfusion Team September 15, 2022 09:14 AM UTC

Hi Dave,


We have checked your reported query and prepared the sample based on your requirement. please refer the below attached sample file and below UG link for referring the individual packages.


UG link: https://blazor.syncfusion.com/documentation/common/adding-script-references, https://blazor.syncfusion.com/documentation/appearance/themes


Please get back to us, if you need any further assistance on this. 


Regards,

YuvanShankar A


Attachment: Server5.020_31270523.zip


DA Dave September 15, 2022 10:07 PM UTC

Thank you, your updated sample file provided the guidance I needed.


Question: If I decide to use static web assets referencing the individual packages, instead of CDN, can you provide a reference for all of the script names for all components? I see that https://blazor.syncfusion.com/documentation/common/adding-script-references has many script names however there are some I could not find, such as for radio button. It would even be better if you had a file containing all of the script references to copy and paste directly into _Host or _Layout files.



YA YuvanShankar Arunagiri Syncfusion Team September 20, 2022 01:26 PM UTC

Hi Dave,


Sorry for the delay. We have prepared the file with all components script of Syncfusion. And there is no script reference for button (button, radio-button, switch and checkbox) package component, it will run with Syncfusion.blazor.buttons along. Please find the below attachment and get back to us, if you need any further assistance on this.


Regards, 

YuvanShankar A


Attachment: Script_3624a2ef.zip


DA Dave September 20, 2022 03:00 PM UTC

Thank you very much. I imagine this file would be a handy download in your "Adding Script References" documentation.



YA YuvanShankar Arunagiri Syncfusion Team September 27, 2022 04:31 AM UTC

Hi Dave,


You're welcome. We have already documented the details in the below documentation.

https://blazor.syncfusion.com/documentation/common/adding-script-references#individual-control-script-reference


Please get back to us, if you need any further assistance on this. 


Regards,

YuvanShankar A


Loader.
Up arrow icon