PHPackages                             wbrowar/adminbar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. wbrowar/adminbar

Abandoned → [wbrowar/craft-admin-bar](/?search=wbrowar%2Fcraft-admin-bar)Craft-plugin[Admin Panels](/categories/admin)

wbrowar/adminbar
================

Front-end shortcuts for clients logged into Craft CMS.

5.8.1(3mo ago)3282.4k↓29.4%9[1 issues](https://github.com/wbrowar/craft-admin-bar/issues)1MITPHP

Since Feb 7Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/wbrowar/craft-admin-bar)[ Packagist](https://packagist.org/packages/wbrowar/adminbar)[ RSS](/packages/wbrowar-adminbar/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (55)Used By (1)

Admin Bar for Craft CMS 5
=========================

[](#admin-bar-for-craft-cms-5)

[![Screenshot](resources/screenshots/screenshot-bar.png)](resources/screenshots/screenshot-bar.png)

Admin Bar is made up of two parts:

- [Admin Bar Component](https://github.com/wbrowar/admin-bar-component) is a standalone web component that can be added to the front end of any project.
- Admin Bar (this plugin) provides plugin settings, a Twig tag, and checks to see if the user is logged in to determine if the Admin Bar Component should be displayed on the page.

If you are creating a Craft CMS site with a Twig front end, you can use this plugin to add Admin Bar to your front end.

If you are creating a headless site, or a site that is statically cached, you may not need this plugin, and in that case you can add [Admin Bar Component](https://github.com/wbrowar/admin-bar-component) directly into your site’s JavaScript (via a bundler or a `` tag).

Requirements
------------

[](#requirements)

- Craft 5.8.0

Editions
--------

[](#editions)

The LITE edition of Admin Bar gives you quick links to frequently-used pages in the Craft CMS Control Panel. You can also use settings to add custom links or rebrand Admin Bar with CSS.

The PRO edition adds interactive menus, statuses, and other information relevant to the page your users are on. Admin Bar PRO integrates Admin Bar with third-party plugins and Craft CMS features.

The LITE edition is free and the PRO edition can be purchased on the [Craft CMS Plugin Store](https://plugins.craftcms.com/admin-bar).

Installation
------------

[](#installation)

> ⚠️ Admin Bar’s composer package name has changed from `wbrowar/adminbar` to `wbrowar/craft-admin-bar`. Update your composer.json to point to [the new package on Packagist.](https://packagist.org/packages/wbrowar/craft-admin-bar)

To install the plugin, you can find it in the [Craft Plugin Store](https://plugins.craftcms.com/admin-bar), or follow these instructions:

1. Open your terminal and go to your Craft project:

    ```
    cd /path/to/project
    ```
2. Then tell Composer to require the plugin:

    ```
    composer require wbrowar/craft-admin-bar
    ```
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Admin Bar.
4. Once installed, Admin Bar can be added to our site by enabling the **Auto Render** setting in the Admin Bar plugin settings or by adding Admin Bar to your Twig template.

Add Admin Bar to Your Twig Template
-----------------------------------

[](#add-admin-bar-to-your-twig-template)

To add Admin Bar to your website add the `{{ adminBar() }}` function within your Twig template. Admin Bar will be displayed on any page that includes this tag when someone—who has the permission to view the CP—is logged into your website.

You may pass in an array of arguments to make some changes on how Admin Bar looks and functions. In this example, you may pass in the entry that you'd like to edit when someone clicks the "Edit" link.

```
{{ adminBar({
  entry: entry,
  editLinkLabel: entry ?? false ? entry.section.name : null,
}) }}
```

Admin Bar Widgets will also use this entry value to change their content and functionality.

Here is a list of available arguments:

ArgumentDefaultDescription`customWidgets`*null*Use Twig to add custom widgets to Admin Bar.`editLinkLabel`*null*Set a custom label for the Edit Link when `editLinkUrl` is set to a custom URL.`editLinkUrl`*null*Override the Edit Link with a custom URL or URI (this will be run through the `url()` Twig function).`entry`*null*Pass in an entry object to add an edit link for that entry. This value will also be used in Admin Bar Widgets.`fixed`*false*Use CSS `position: fixed` instead of `position: sticky;` to pin Admin Bar to the top or bottom of your page.`force`*false*Bypasses the default check that `{{ adminBar() }}` does to see if Admin Bar can be rendered. This is intended to be used on the Admin Bar plugin settings page, or for edge cases.`id`*'admin-bar'*Set the `id` attribute on the Admin Bar wrapper element.`position`*'top'*When set to `'bottom'` and used with `fixed: true`, Admin Bar will be fixed to the bottom of the page. Accepts: `'bottom'`, `'top'``returnUrl`*'{url}'*Sets the URL that you are taken to after saving an entry. Set this to `null` to redirect to the default `returnUrl` for the entry type. Variables in `{}` are replaced based on the entry values after save.`rtl`*false*Changes the reading direction from `ltr` to `rtl` in situations where you need to manually set it. Admin Bar Component will automatcally switch to RTL if your page is set to RTL or if you have the CSS set to `direction: rtl`.`sticky`*true*Uses CSS to `position: sticky;` Admin Bar to the top of the page.`textElements`*\[\]*Add text elements to Admin Bar using an array of objects.`useCss`*true*Add the default styles to Admin Bar or leave them out to load the stylesheet with your project’s CSS.`useJs`*true*Use the Admin Bar's default Javascript or set this to `false` to import the [Admin Bar Component](https://github.com/wbrowar/admin-bar-component) into your project’s JS bundle.### Adding Text Elements to Admin Bar

[](#adding-text-elements-to-admin-bar)

Plain text and labels can be added to Admin Bar by adding objects into the `textElements` argument. Object properties can include any property accepted by `` elements, [as documented here](https://github.com/wbrowar/admin-bar-component#adding-text-elements-to-admin-bar). Each object will add a new text element and the properties in each object will be added using Craft’s `attr()` method.

For example, this will add a line of text that will display the number of entries in the current entry’s section:

```
{{ adminBar({
    entry: entry ?? null,
    textElements: [
        { 'badge-content': craft.entries.section(entry.section.handle).count(), 'text-content': 'Entries in this section' },
    ],
}) }}
```

Configuration settings
----------------------

[](#configuration-settings)

The config file gives you the ability to adjust how Admin Bar looks and functions in multiple environments. It also allows you to create additional links for the Admin Bar, and allows for plugin actions to be called through these additional links.

To add a config file to your site, create a file at `/config/admin-bar.php` that returns an array of settings:

```
