Share via

Bootstrap 5 sidebar problem

Cenk 1,051 Reputation points
2022-08-09T13:19:24.44+00:00

Hi,

I am working on a Blazor Server Application. I have this Radzen menu (NavMenu.razor);

<RadzenPanelMenu>  
    <RadzenPanelMenuItem Text="General" Icon="line_weight">  
        <RadzenPanelMenuItem Text="Home" Path="/" Icon="home"></RadzenPanelMenuItem>  
    </RadzenPanelMenuItem>  
    <RadzenPanelMenuItem Text="Orders" Icon="add_shopping_cart">  
        <RadzenPanelMenuItem Text="Orders List" Path="orders" Icon="receipt_long"></RadzenPanelMenuItem>  
        <RadzenPanelMenuItem Text="Orders Upload" Path="upload" Icon="file_upload"></RadzenPanelMenuItem>  
        <RadzenPanelMenuItem Text="Orders Export" Path="export" Icon="post_add"></RadzenPanelMenuItem>  
    </RadzenPanelMenuItem>  
    <RadzenPanelMenuItem Text="Vendors" Icon="face">  
        <RadzenPanelMenuItem Text="Vendor List" Path="vendors" Icon="account_box"></RadzenPanelMenuItem>  
    </RadzenPanelMenuItem>  
    <RadzenPanelMenuItem Text="Customers" Icon="paid">  
        <RadzenPanelMenuItem Text="Customer List" Path="customers" Icon="add_cart"></RadzenPanelMenuItem>  
    </RadzenPanelMenuItem>  
    <RadzenPanelMenuItem Text="Administration" Icon="paid">  
        <RadzenPanelMenuItem Text="User Management" Path="administration" Icon="security"></RadzenPanelMenuItem>  
    </RadzenPanelMenuItem>  
</RadzenPanelMenu>  

But I want to use https://getbootstrap.com/docs/5.0/examples/sidebars/# collapsible for the sidebar. I copied sidebars.css and the related HTML tags but there are some problems with the outcome.

229601-sidebar.png

Can you please help me?

I forgot to mention that clicking the menu items, triggers the toggler to hide and show. How can I only trigger the sidebar hide and show only with the toggler icon?

Thank you.

Developer technologies | .NET | Blazor

Answer accepted by question author

Anonymous
2022-08-16T02:59:14.7+00:00

Hi,@ Cenk-1028
I checked your codes and

main {  
    display: flex;  
    flex-wrap: nowrap;  
    height: 100vh;  
    height: -webkit-fill-available;  
    max-height: 100vh;  
    overflow-x: auto;  
    overflow-y: hidden;  
}  

in your sidebar.css affected your former codes
So I modified the codes and added class attribute to your main tag in sidebar page as below:

.sidebarmain {  
    display: flex;  
    flex-wrap: nowrap;  
    height: 100vh;  
    height: -webkit-fill-available;  
    max-height: 100vh;  
    overflow-x: hidden;  
    overflow-y: hidden;  
}  

in your NavMenu.razor:

......  
<main class="sidebarmain">  
.......  

then I added the codes in your MainLayout.razor:

<style>  
.pb-3,  
.py-3 {  
  padding-bottom: 0.65rem !important;  
}  
</style>  

231294-816-qa.png

----------

If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards
RuikaiFeng

Was this answer helpful?

0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Cenk 1,051 Reputation points
    2022-08-25T05:34:53.657+00:00

    @Anonymous Here is how it is now, the problems I mentioned continue.

    234718-sidebar.png

    Was this answer helpful?

    0 comments No comments

  2. Cenk 1,051 Reputation points
    2022-08-16T11:19:02.647+00:00

    @Anonymous thanks for your help. I guess I need to make some more adjustments, it seems to me that the line is a little lower for sidebar. And the main problem is that every time I click on the sidebar menu items, toggler closes. How can I get the menu to open and close only when pressing the hamburger menu icon?

    231458-sidebar.png

    This works for the line but still, I need to solve sidebar open/close only with the icon.

    <style>  
        .pb-3,  
        .py-3 {  
            padding-bottom: 0.56rem !important;  
        }  
    </style>  
    

    Was this answer helpful?


  3. Cenk 1,051 Reputation points
    2022-08-16T05:31:44.163+00:00

    @Anonymous thank you for your help, where exactly did you make changes? I had a hard time following :)

    Was this answer helpful?


  4. Bruce (SqlWork.com) 84,061 Reputation points
    2022-08-09T17:59:04.163+00:00

    as this is a 3rd part library you should use their support.

    https://blazor.radzen.com/support

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.