Sha256: 3718b7bbf87d962885f7f9a17a49ff3e886e8282eb3f581ae0b7880a54e13bf9

Contents?: true

Size: 1.69 KB

Versions: 46

Compression:

Stored size: 1.69 KB

Contents

---
redirect_from: /docs/7-sidebars.html
---
# Sidebar Sections

Sidebars allow you to put whatever content you want on the side the page.

```ruby
sidebar :help do
  "Need help? Email us at help@example.com"
end
```

This will generate a sidebar on every page for that resource. The first
argument is used as the title, and can be a symbol, string, or lambda.

You can also use [Arbre](https://github.com/activeadmin/arbre) to define HTML content.

```ruby
sidebar :help do
  ul do
    li "Second List First Item"
    li "Second List Second Item"
  end
end
```

Sidebars can be rendered on a specific action by passing `:only` or `:except`.

```ruby
sidebar :help, only: :index do
  "Need help? Email us at help@example.com"
end
```

If you want to conditionally display a sidebar section, use the :if option and
pass it a proc which will be rendered within the view context.

```ruby
sidebar :help, if: proc{ current_admin_user.super_admin? } do
  "Only for super admins!"
end
```

You can access your model as resource in the sidebar too:

```ruby
sidebar :custom, only: :show do
  resource.a_method
end
```

You can also render a partial:

```ruby
sidebar :help                    # app/views/admin/posts/_help_sidebar.html.erb
sidebar :help, partial: 'custom' # app/views/admin/posts/_custom.html.erb
```

It's possible to add custom class name to the sidebar parent element by passing
`class` option:

```ruby
sidebar :help, class: 'custom_class'
```

By default sidebars are positioned in the same order as they defined, but it's also
possible to specify their position manually:

```ruby
# will push Help section to the top (above default Filters section)
sidebar :help, priority: 0
```

Default sidebar priority is `10`.

Version data entries

46 entries across 46 versions & 4 rubygems

Version Path
activeadmin-2.13.1 docs/7-sidebars.md
activeadmin-2.13.0 docs/7-sidebars.md
activeadmin-2.12.0 docs/7-sidebars.md
activeadmin-2.11.2 docs/7-sidebars.md
activeadmin-rb-1.6.0 docs/7-sidebars.md
activeadmin-2.11.1 docs/7-sidebars.md
activeadmin-2.11.0 docs/7-sidebars.md
activeadmin-2.10.1 docs/7-sidebars.md
activeadmin-2.10.0 docs/7-sidebars.md
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/docs/7-sidebars.md
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/docs/7-sidebars.md
activeadmin-rb-1.5.2 docs/7-sidebars.md
activeadmin-2.9.0 docs/7-sidebars.md
activeadmin-2.8.1 docs/7-sidebars.md
activeadmin-2.8.0 docs/7-sidebars.md
activeadmin-rb-1.5.1 docs/7-sidebars.md
activeadmin-2.7.0 docs/7-sidebars.md
activeadmin-2.6.1 docs/7-sidebars.md
activeadmin-2.6.0 docs/7-sidebars.md
activeadmin-2.5.0 docs/7-sidebars.md