
Add this line to your application's Gemfile:
gem "simple_navbar"
And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_navbar
with stimulus execute:
$ rails generate simple_navbar:install --stimulus
no stimulus:
$ rails generate simple_navbar:install
os legacy mode with assets/javascripts
$ rails generate simple_navbar:install --legacy
This will generate for you js files, css and include the helper SimpleNavba on ApplicationController.rb and javascript include tags with no stimulus
with stimulus use
<%= simple_navbar_s( brand: { logo: "/icon.png", url: root_path },
links: [
{ label: "About", url: about_path },
{ label: "Posts", url: posts_path }]) %>
no stimulus simple_navbar with no "s"
<%= simple_navbar( brand: { logo: "/icon.png", url: root_path },
links: [
{ label: "About", url: about_path },
{ label: "Posts", url: posts_path }]) %>
with dropdown menus
<%= simple_navbar_s(
brand: { logo: "/icon.png", url: root_path },
links: [
{ label: "About", url: about_path },
{ label: "Posts", url: posts_path }
{ dropdown: { label: "More", links: [
{ label: "Hello", url: root_path },
{ label: "World", url: root_path }
]
}
}
]) %>
you can set a title instead of a logo on the brand
<%= simple_navbar( brand: { title: "Fumo", url: root_path },
links: [
{ label: "About", url: about_path },
{ label: "Posts", url: posts_path }]) %>
Fell free to open issues and pr to contribute.
The gem is available as open source under the terms of the MIT License.