How can I display a page element based upon security?
If you want to make a button only available to users who are admins, put this property in the form element:

'#access' =&gt; \Drupal::currentUser()-&gt;hasPermission('access administration pages'),