The nav is a grouped set of links that take the user to another page, or tab through parts of a page. It comes in horizontal or vertical with several different variants.
<%= pb_rails("nav", props: {title: "Menu", link: "#"}) do %> <%= pb_rails("nav/item", props: { text: "Photos", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Music", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Video", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { text: "Files", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: {title: "Browse", link: "#"}) do %> <%= pb_rails("nav/item", props: { icon_left: "newspaper", text: "News Feed" }) %> <%= pb_rails("nav/item", props: { icon_left: "comments-alt", link: "#", text: "Messages", active: true }) %> <%= pb_rails("nav/item", props: { icon_left: "calendar-check", icon_right: "angle-down", link: "#", text: "Events" }) %> <%= pb_rails("nav/item", props: { icon_left: "users", link: "#", text: "Friends" }) %> <%= pb_rails("nav/item", props: { icon_left: "users-class", icon_right: "angle-down", link: "#", text: "Groups" }) %> <% end %>
Icon used needs to be square. Icon size is 24px by 24px.
<%= pb_rails("nav", props: {title: "Browse", link: "#"}) do %> <%= pb_rails("nav/item", props: { image_url: "https://upload.wikimedia.org/wikipedia/commons/0/00/Apple_News_icon_%28macOS%29.png", text: "News Feed" }) %> <%= pb_rails("nav/item", props: { image_url: "https://p7.hiclipart.com/preview/928/339/723/messages-iphone-apple-imessage-iphone-thumbnail.jpg", link: "#", text: "Messages", active: true }) %> <%= pb_rails("nav/item", props: { image_url: "https://www.clipartmax.com/png/middle/103-1038653_circle-icons-calendar-svg-event-icon.png", icon_right: "angle-down", link: "#", text: "Events" }) %> <%= pb_rails("nav/item", props: { image_url: "https://www.pngitem.com/pimgs/m/228-2289227_find-friends-icon-png-image-iphone-find-my.png", link: "#", text: "Friends" }) %> <%= pb_rails("nav/item", props: { image_url: "https://img.favpng.com/18/5/20/blue-human-behavior-silhouette-area-communication-png-favpng-wLT3QYknSwc68uu9GAUHGS5FY_t.jpg", icon_right: "angle-down", link: "#", text: "Groups" }) %> <% end %>
<%= pb_rails("nav", props: { highlight: false }) do %> <%= pb_rails("nav/item", props: { text: "All Categories", active: true, link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Food", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Digital", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Design Art", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: {borderless: true}) do %> <%= pb_rails("nav/item", props: { text: "Photos", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Music", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Video", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { text: "Files", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: { variant: "subtle" }) do %> <%= pb_rails("nav/item", props: { text: "Overview", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Albums", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { text: "Similar Artists", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Events", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Discography", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Listeners", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: {variant: "subtle"}) do %> <%= pb_rails("nav/item", props: { icon_left: "city", text: "City", link: "#" }) %> <%= pb_rails("nav/item", props: { icon_left: "user-friends", text: "People", link: "#", icon_right: "angle-down" }) %> <%= pb_rails("nav/item", props: { icon_left: "user-tie", text: "Business", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { icon_left: "theater-masks", text: "Entertainment", link: "#" }) %> <%= pb_rails("nav/item", props: { icon_left: "salad", text: "Food", link: "#", icon_right: "angle-down" }) %> <%= pb_rails("nav/item", props: { icon_left: "sunglasses", text: "Style", link: "#" }) %> <%= pb_rails("nav/item", props: { icon_left: "child", text: "Childern", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: {variant: "subtle", highlight: false}) do %> <%= pb_rails("nav/item", props: { text: "Dashboard", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Statistics", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { text: "Pages", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: { orientation: "vertical", variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { text: "Service ", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %> <% end %>
All Nav variants' navItems accept our global Spacing (padding, margin) props for custom spacing requirements. This example uses paddingY="xxs" and margin="none" on the bold variant to show this in action!
<%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "About", link: "#", padding_y:"xxs", margin:"none" }) %> <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true, padding_y:"xxs", margin:"none" }) %> <%= pb_rails("nav/item", props: { text: "Service", link: "#", padding_y:"xxs", margin:"none" }) %> <%= pb_rails("nav/item", props: { text: "Contacts", link: "#", padding_y:"xxs", margin:"none" }) %> <% end %>
All Nav variants' navItems accept the following props for customizing font:
fontSize
/ font_size
defaults to normal
, also accepts small
fontWeight
/ font_weight
defaults to regular
, also accepts bold
and bolder
<%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "About", link: "#", font_weight:"bolder", font_size:"small" }) %> <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true, font_weight:"bolder", font_size:"small" }) %> <%= pb_rails("nav/item", props: { text: "Service", link: "#", font_weight:"bolder", font_size:"small" }) %> <%= pb_rails("nav/item", props: { text: "Contacts", link: "#", font_weight:"bolder", font_size:"small" }) %> <% end %>
The collapsible
prop allows users to create a nested, collapsible nav. Pass collapsible
to any NavItem and pass that navItem any number of NavItems as children to create a collapsible nav.
The optional collapsed
prop can also be used to set the default state for the collapsed nav on first render of the page. collapsed
takes a boolean value that is set to true (meaning nav is collapsed) by default. Set it to false as shown here to have the nav open on first render.
<%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "Overview", link: "#", collapsible: true, icon_left:"city", collapsed: false }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "City", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "People", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Business", link: "#" }) %> <% end %> <% end %> <%= pb_rails("nav/item", props: { text: "Albums", link: "#", active: true, collapsible: true, icon_left: "theater-masks" }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "Entertainment", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Food", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Style", link: "#" }) %> <% end %> <% end %> <%= pb_rails("nav/item", props: { text: "Similar Artists", link: "#", collapsible: true, icon_left: "city" }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "City", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "People", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Business", link: "#" }) %> <% end %> <% end %> <% end %>
Collapsible Navs optionally accept the following props:
collapsibleTrail
/ collapsible_trail
, enables a vertical guideline to the left of the collapsible nav's childreniconRight
optionally accepts an array of 2 icon values; the first is used as the default icon when the node is collapsed, the second is toggled when the node is expanded. If only 1 icon value is passed, the icon will not toggle between collapsible states.<%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "Overview", link: "#", collapsible: true, icon_left:"city", collapsible_trail: true, font_weight:"bolder", font_size:"small", icon_right:["plus", "minus"] }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "City", link: "#", font_size:"small", margin_y:"none" }) %> <%= pb_rails("nav/item", props: { text: "People", link: "#", font_size:"small", margin_y:"none" }) %> <%= pb_rails("nav/item", props: { text: "Business", link: "#", font_size:"small", margin_y:"none" }) %> <% end %> <% end %> <%= pb_rails("nav/item", props: { text: "Albums", link: "#", active: true, collapsible: true, icon_left: "theater-masks", collapsible_trail: true, font_weight:"bolder", font_size:"small", icon_right:["plus", "minus"] }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "Entertainment", link: "#", font_size:"small", margin_y:"none" }) %> <%= pb_rails("nav/item", props: { text: "Food", link: "#", font_size:"small", margin_y:"none" }) %> <%= pb_rails("nav/item", props: { text: "Style", link: "#", font_size:"small", margin_y:"none" }) %> <% end %> <% end %> <%= pb_rails("nav/item", props: { text: "Similar Artists", link: "#", collapsible: true, icon_left: "city", collapsible_trail: true, font_weight:"bolder", font_size:"small", icon_right:["plus", "minus"] }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "City", link: "#", font_size:"small", margin_y:"none" }) %> <%= pb_rails("nav/item", props: { text: "People", link: "#", font_size:"small", margin_y:"none" }) %> <%= pb_rails("nav/item", props: { text: "Business", link: "#", font_size:"small", margin_y:"none" }) %> <% end %> <% end %> <% end %>
Optionally remove the expand/collapse icon(s) from any collapsible nav item by passing "none" to the icon_right
prop on that nav item.
<%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "Overview", link: "#", collapsible: true, icon_left:"city", collapsed: false, icon_right: "none" }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "City", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "People", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Business", link: "#" }) %> <% end %> <% end %> <%= pb_rails("nav/item", props: { text: "Albums", link: "#", active: true, collapsible: true, icon_left: "theater-masks", icon_right: "none" }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "Entertainment", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Food", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Style", link: "#" }) %> <% end %> <% end %> <%= pb_rails("nav/item", props: { text: "Similar Artists", link: "#", collapsible: true, icon_left: "city", icon_right: "none" }) do %> <%= pb_rails("nav", props: { variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "City", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "People", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Business", link: "#" }) %> <% end %> <% end %> <% end %>
<%= pb_rails("nav", props: { orientation: "horizontal" }) do %> <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { text: "Service ", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: { orientation: "horizontal", variant: "subtle" }) do %> <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { text: "Service ", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: { orientation: "horizontal", variant: "bold" }) do %> <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %> <%= pb_rails("nav/item", props: { text: "Service ", link: "#" }) %> <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %> <% end %>
<%= pb_rails("nav", props: {title: "Users", link: "#"}) do %> <%= pb_rails("nav/item", props: { link: "#", active: true }) do%> <%= pb_rails("user", props: { name: "Anna Black", territory: "PHL", title: "Remodeling Consultant", orientation: "horizontal", align: "left", avatar_url: "https://randomuser.me/api/portraits/women/44.jpg" }) %> <% end %> <%= pb_rails("nav/item", props: { link: "#" }) do%> <%= pb_rails("user", props: { name: "Julie Hamilton", territory: "PHL", title: "Inside Sales Agent", orientation: "horizontal", align: "left", avatar_url: "https://randomuser.me/api/portraits/women/45.jpg" }) %> <% end %> <%= pb_rails("nav/item", props: { link: "#" }) do%> <%= pb_rails("user", props: { name: "Dennis Wilks", territory: "PHL", title: "Senior Remodeling Consultant", orientation: "horizontal", align: "left", avatar_url: "https://randomuser.me/api/portraits/men/44.jpg" }) %> <% end %> <%= pb_rails("nav/item", props: { link: "#" }) do%> <%= pb_rails("user", props: { name: "Ronnie Martin", territory: "PHL", title: "Customer Development Representative", orientation: "horizontal", align: "left", avatar_url: "https://randomuser.me/api/portraits/men/46.jpg" }) %> <% end %> <% end %>
<%= pb_rails("nav") do %> <%= pb_rails("nav/item", props: { icon_left: "newspaper", text: "News Feed" }) %> <%= pb_rails("nav/item", props: { icon_left: "comments-alt", link: "#", text: "Messages", active: true }) %> <%= pb_rails("nav/item", props: { icon_left: "calendar-check", icon_right: "angle-down", link: "#", text: "Events" }) %> <%= pb_rails("nav/item", props: { icon_left: "users", link: "#", text: "Friends" }) %> <%= pb_rails("nav/item", props: { icon_left: "users-class", icon_right: "angle-down", link: "#", text: "Groups" }) %> <% end %>
<%= pb_rails("nav", props: {title: "Popular Websites", link: "#"}) do %> <%= pb_rails("nav/item", props: { text: "Google", link: "https://www.google.com/", target: "_blank" }) %> <%= pb_rails("nav/item", props: { text: "YouTube", link: "https://www.youtube.com/", target: "_blank" }) %> <%= pb_rails("nav/item", props: { text: "Facebook", link: "https://www.facebook.com/", target: "_blank" }) %> <%= pb_rails("nav/item", props: { text: "Amazon", link: "https://www.amazon.com/", target: "_blank" }) %> <% end %>
The Nav kit can also be used to create dynamic tabbing. To do so, use the boolean tabbing
prop as shown here.
All divs you want to use as tabs MUST have an id attached to them. To link the tab to the nav, use the required data attribute pb_tab_target
on each nav/item and pass it the id of the tab you want linked to that specific nav/item. See code example below to see this in action.
<%= pb_rails("nav", props: { orientation: "horizontal", tabbing: true, padding_bottom: "sm" }) do %> <%= pb_rails("nav/item", props: { text: "About", active: true, data: { pb_tab_target: "about" }, cursor: "pointer" }) %> <%= pb_rails("nav/item", props: { text: "Case Studies", data: { pb_tab_target: "case_studies" }, cursor: "pointer" }) %> <%= pb_rails("nav/item", props: { text: "Service", data: { pb_tab_target: "service" }, cursor: "pointer" }) %> <%= pb_rails("nav/item", props: { text: "Contacts", data: { pb_tab_target: "contacts" }, cursor: "pointer" }) %> <% end %> <div id="about"> <%= pb_rails("body", props: { text: "This is about!" }) %> </div> <div id="case_studies"> <%= pb_rails("body", props: { text: "This is case studies!" }) %> </div> <div id="service"> <%= pb_rails("body", props: { text: "This is service!" }) %> </div> <div id="contacts"> <%= pb_rails("body", props: { text: "This is contacts!" }) %> </div> <script> // The script in the code snippet below is for demonstrating the active state and NOT needed for the kit to function. // The active prop can be used to highlight this active state. const navItemClass = "pb_nav_list_kit_item" const navItemActiveClass = "pb_nav_list_kit_item_active" const dataNavItems = "[data-pb-tab-target]" const navItemTabs = document.querySelectorAll(dataNavItems) navItemTabs.forEach(navItemTab => { navItemTab.addEventListener("click", event => { const navItemTabs = document.querySelectorAll(dataNavItems) navItemTabs.forEach(navItemTab => { if (navItemTab === event.target.closest(dataNavItems)) { navItemTab.classList.add(navItemActiveClass) navItemTab.classList.remove(navItemClass) } else { if (navItemTab.classList.contains(navItemActiveClass)) { navItemTab.classList.remove(navItemActiveClass) navItemTab.classList.add(navItemClass) } } }) }) }) </script>
Props | Type | Values |
---|---|---|
max_width |
array
|
0%
xs
sm
md
lg
xl
xxl
0
none
100%
|
min_width |
array
|
0%
xs
sm
md
lg
xl
xxl
0
none
100%
|
z_index |
array
|
1
2
3
4
5
6
7
8
9
10
|
number_spacing |
array
|
tabular
|
shadow |
array
|
none
deep
deeper
deepest
|
line_height |
array
|
tightest
tighter
tight
normal
loose
looser
loosest
|
display |
array
|
block
inline_block
inline
flex
inline_flex
none
|
cursor |
array
|
auto
default
none
contextMenu
help
pointer
progress
wait
cell
crosshair
text
verticalText
alias
copy
move
noDrop
notAllowed
grab
grabbing
eResize
nResize
neResize
nwResize
sResize
seResize
swResize
wResize
ewResize
nsResize
neswResize
nwseResize
colResize
rowResize
allScroll
zoomIn
zoomOut
|
flex_direction |
array
|
row
column
rowReverse
columnReverse
|
flex_wrap |
array
|
wrap
nowrap
wrapReverse
|
justify_content |
array
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
justify_self |
array
|
auto
start
end
center
stretch
|
align_items |
array
|
flexStart
flexEnd
start
end
center
baseline
stretch
|
align_content |
array
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
align_self |
array
|
auto
start
end
center
stretch
baseline
|
flex |
array
|
auto
initial
0
1
2
3
4
5
6
7
8
9
10
11
12
none
|
flex_grow |
array
|
1
0
|
flex_shrink |
array
|
1
0
|
order |
array
|
1
2
3
4
5
6
7
8
9
10
11
12
|
position |
array
|
relative
absolute
fixed
sticky
|
hover |
array
|
|
border_radius |
array
|
none
xs
sm
md
lg
xl
rounded
|
text_align |
array
|
start
end
left
right
center
justify
justify-all
match-parent
|
overflow |
array
|
visible
hidden
scroll
auto
|
truncate |
array
|
1
2
3
4
5
|
left |
array
|
0
xxs
xs
sm
md
lg
xl
auto
initial
inherit
|
top |
array
|
0
xxs
xs
sm
md
lg
xl
auto
initial
inherit
|
right |
array
|
0
xxs
xs
sm
md
lg
xl
auto
initial
inherit
|
bottom |
array
|
0
xxs
xs
sm
md
lg
xl
auto
initial
inherit
|
vertical_align |
array
|
baseline
super
top
middle
bottom
sub
text-top
text-bottom
|
height |
array
|
auto
xs
sm
md
lg
xl
xxl
xxxl
|
min_height |
array
|
auto
xs
sm
md
lg
xl
xxl
xxxl
|
max_height |
array
|
auto
xs
sm
md
lg
xl
xxl
xxxl
|
overflow_x |
array
|
visible
hidden
scroll
auto
|
overflow_y |
array
|
visible
hidden
scroll
auto
|
margin |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_bottom |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_x |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_y |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_bottom |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_x |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_y |
array
|
none
xxs
xs
sm
md
lg
xl
|
classname |
string
|
|
dark |
boolean
|
|
group_hover |
boolean
|
|
id |
string
|
|
data |
hashprop
|
|
aria |
hashprop
|
|
html_options |
hashprop
|
|
children |
proc
|
|
style |
hashprop
|
Props | Type | Values | Default |
---|---|---|---|
link |
string
|
#
|
|
title |
string
|
||
orientation |
enum
|
vertical
horizontal
|
vertical
|
variant |
enum
|
normal
subtle
bold
|
normal
|
highlight |
boolean
|
true
|
|
borderless |
boolean
|
false
|
|
tabbing |
boolean
|
false
|