# Best practice to hide UI elements and Views based on roles?

**URL:** https://community.appfarm.io/t/best-practice-to-hide-ui-elements-and-views-based-on-roles/1803
**Category:** Ask the community
**Created:** [April 22, 2025, 7:56am UTC](https://community.appfarm.io/t/best-practice-to-hide-ui-elements-and-views-based-on-roles/1803 "2025-04-22T07:56:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![torstro](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@torstro](https://community.appfarm.io/u/torstro)
#### Post date: [April 22, 2025, 7:56am UTC](https://community.appfarm.io/t/best-practice-to-hide-ui-elements-and-views-based-on-roles/1803/1 "2025-04-22T07:56:55Z")

</div>

Hello!

What is the best practice to hide access to parts of your app for certain roles? I am mostly thinking visually. The data is blocked using permissions.

---

<div class="post-metadata">

### Author: ![emma](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/emma/32/1649_2.png) [@emma](https://community.appfarm.io/u/emma)
#### Post date: [April 22, 2025, 8:12am UTC](https://community.appfarm.io/t/best-practice-to-hide-ui-elements-and-views-based-on-roles/1803/2 "2025-04-22T08:12:46Z")

</div>

Hi!

Hiding UI elements based on roles can be done under the property “Visible” on the right sidebar when editing a component.

![Skjermbilde 2025-04-22 kl. 10.05.49](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/d/da914c9e19d22289a441ec25f403d5e8668f6423.png)

There, you can add a condition for when the element should be visible - e.g. when the current user’s role is “owner”:

 ![Skjermbilde 2025-04-22 kl. 10.22.58](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/d/da5054db4a13ba3ca1ecada521314ab94e42ec4f.png)

---

<div class="post-metadata">

### Author: ![torstro](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@torstro](https://community.appfarm.io/u/torstro)
#### Post date: [April 22, 2025, 8:33am UTC](https://community.appfarm.io/t/best-practice-to-hide-ui-elements-and-views-based-on-roles/1803/3 "2025-04-22T08:33:07Z")

</div>

Thank you. Is there any way to give a UI element a tag/id/group to ease the administration of these visibility conditions?

What about views? Is there any way to restrict access to them or do I need to use visibility on their outermost container? It would be nice if some views appeared not to exist for certain roles.

---

<div class="post-metadata">

### Author: ![emma](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/emma/32/1649_2.png) [@emma](https://community.appfarm.io/u/emma)
#### Post date: [April 22, 2025, 10:49am UTC](https://community.appfarm.io/t/best-practice-to-hide-ui-elements-and-views-based-on-roles/1803/4 "2025-04-22T10:49:50Z")

</div>

Unfortunately, there’s no straightforward way to manage visibility conditions in groups.

However, when working with views, there are several workarounds:

- **Redirect using “On view load”** : You can set up an action in the “On view load” event handler to redirect users with specific roles to another view.
- **Hide navigation buttons** : Another option is to hide the button that leads to the restricted view for certain user roles.
- **Hide the container** : You can also hide the outermost container of the view and, for example, display a restricted access message using a visibility group based on the user’s role.

Hope this helps!
