# Sidebar toggle

**URL:** <https://forum.radzen.com/t/sidebar-toggle/798>\
**Category:** Uncategorized\
**Created:** [January 1, 2019, 4:13am UTC](https://forum.radzen.com/t/sidebar-toggle/798 "2019-01-01T04:13:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmhdev](https://forum.radzen.com/letter_avatar_proxy/v4/letter/c/c0e974/32.png) [@cmhdev](https://forum.radzen.com/u/cmhdev)\
**Post date:** [January 1, 2019, 4:13am UTC](https://forum.radzen.com/t/sidebar-toggle/798/1 "2019-01-01T04:13:35Z")

</div>

is there a way when the page loads to have the sidebar hidden until the toggle is clicked ?

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [January 1, 2019, 9:21am UTC](https://forum.radzen.com/t/sidebar-toggle/798/2 "2019-01-01T09:21:28Z")

</div>

This is doable by following these steps:

1. Exclude the main layout from code generation. Go to the application settings page (... item in the top right corner of Radzen) and type `client\src\app\main-layout` in the **Code generation ignore list** textbox. Click **Save**. ![47](https://forum.radzen.com/uploads/default/original/1X/50f76cea9909a32bea5123049ed72e4c6f89b356.png)
2. Open the `client\src\app\main-layout\main-layout.component.html` with your favourite text editor program. Set the `open` property of the Angular component to `false`:

`<rz-sidebar #sidebar0 [open]="false">`

---

<div class="post-metadata">

**Author:** ![cmhdev](https://forum.radzen.com/letter_avatar_proxy/v4/letter/c/c0e974/32.png) [@cmhdev](https://forum.radzen.com/u/cmhdev)\
**Post date:** [January 2, 2019, 5:34pm UTC](https://forum.radzen.com/t/sidebar-toggle/798/3 "2019-01-02T17:34:34Z")

</div>

That worked great. Thanks!

---

<div class="post-metadata">

**Author:** ![Moo](https://forum.radzen.com/user_avatar/forum.radzen.com/moo/32/1627_2.png) [@Moo](https://forum.radzen.com/u/Moo)\
**Post date:** [August 12, 2020, 9:48am UTC](https://forum.radzen.com/t/sidebar-toggle/798/4 "2020-08-12T09:48:20Z")

</div>

I've tried to put a condition in there but I failed.  
Could I make this behaviour dependent on the users role?  
Like  
`<rz-sidebar #sidebar0 [open]="security?.user?.roles?.indexOf('role.manager.admin') == 1">`

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [August 12, 2020, 10:49am UTC](https://forum.radzen.com/t/sidebar-toggle/798/5 "2020-08-12T10:49:45Z")

</div>

@Moo, this should work. What's the actual result of this? Also why not use the built-in isInRole method? This will check that the target role is precisely at index 1 which may not always be the case.

---

<div class="post-metadata">

**Author:** ![Moo](https://forum.radzen.com/user_avatar/forum.radzen.com/moo/32/1627_2.png) [@Moo](https://forum.radzen.com/u/Moo)\
**Post date:** [August 12, 2020, 11:27am UTC](https://forum.radzen.com/t/sidebar-toggle/798/6 "2020-08-12T11:27:22Z")

</div>

I will try that (both), thank your for the fast answer 🙂  
Now that I'm looking at it ... your're right the check itself doesn't look good.
