Navbar Svelte Component

Navbar is a fixed (with Fixed and Through layout types) area at the top of a screen that contains Page title and navigation elements.

Navbar Svelte component represents Navbar component.

Navbar Components

There are following components included:

  • Navbar
  • NavLeft
  • NavRight
  • NavTitle
  • NavTitleLarge

Navbar Properties

PropTypeDefaultDescription
<Navbar> properties
titlestringNavbar title
subtitlestringNavbar sub title
backLinkboolean
string
Adds back-link with text (if string value is specified)
backLinkUrlstringCustom back link URL
backLinkForcebooleanfalseForce page to load and ignore previous page in history
backLinkShowTextbooleanBy default back link text disable for MD theme
slidingbooleantrueEnables “sliding” effect for nav elements
noShadowbooleanfalseDisable shadow rendering for Material theme
noHairlinebooleanfalseDisable navbar bottom thin border (hairline) for iOS theme
hiddenbooleanfalseMakes navbar hidden
innerClassstringAdds additional class to navbar-inner element
largebooleanEnables navbar with large title
transparentbooleanMakes navbar transparent. Can be used in addition to large prop to make large navbar transparent.
titleLargestringNavbar large title text. If not specified then will be equal to title prop
<NavLeft> properties
backLinkboolean
string
Adds back-link with text (if string value is specified)
backLinkUrlstringCustom back link URL
backLinkForcebooleanfalseForce page to load and ignore previous page in history
backLinkShowTextbooleanBy default back link text disable for MD theme
slidingbooleanEnables “sliding” effect. By default inhertis sliding prop of parent Navbar
<NavTitle> properties
titlestringSpecifies element inner title text (affects if there is no child elements)
subtitlestringSub title text
slidingbooleanEnables “sliding” effect. By default inhertis sliding prop of parent Navbar
<NavRight> properties
slidingbooleanEnables “sliding” effect. By default inhertis sliding prop of parent Navbar

Navbar Methods

<Navbar> methods
.hide(animate)Hide navbar
.show(animate)Show navbar
.size()Size navbar

Navbar Events

EventDescription
<Navbar> events
backClick
clickBack
Event will be triggered after click on navbar back link
navbarHideEvent will be triggered when Navbar becomes hidden
navbarShowEvent will be triggered when Navbar becomes visible
navbarCollapseEvent will be triggered when Navbar with large title collapsed (from large navbar to usual navbar)
navbarExpandEvent will be triggered when Navbar with large title expanded (from usual navbar to large navbar)
<NavLeft> events
backClick
clickBack
Event will be triggered after click on navbar back link

Navbar Slots

Navbar Svelte component (<Navbar>) has additional slots for custom elements:

  • default - element will be inserted as a child of <div class="navbar-inner"> element
  • before-inner - element will be inserted right before <div class="navbar-inner"> element
  • after-inner - element will be inserted right after <div class="navbar-inner"> element
  • left - element will be inserted in navbar’s left element
  • right - element will be inserted in navbar’s right element
  • title - element will be inserted in navbar’s title element
  • title-large - element will be inserted in navbar’s large title text element
  1. <Navbar title="My App">
  2. <a href="#" slot="left">Left Link</a>
  3. <a href="#" slot="right">Right Link</a>
  4. <div slot="before-inner">Before Inner</div>
  5. <div slot="after-inner">After Inner</div>
  6. <div>Default slot</div>
  7. </Navbar>
  8. <!-- Renders to: -->
  9. <div class="navbar">
  10. <div class="navbar-bg"></div>
  11. <div>Before Inner</div>
  12. <div class="navbar-inner">
  13. <div class="left">
  14. <a href="#">Left Link</a>
  15. </div>
  16. <div class="title">My App</div>
  17. <div class="right">
  18. <a href="#">Right Link</a>
  19. </div>
  20. <div>Default slot</div>
  21. </div>
  22. <div>After Inner</div>
  23. </div>

Examples

Minimal layout

  1. <Navbar title="My App"></Navbar>

Minimal layout with back link

  1. <Navbar title="My App" backLink="Back"></Navbar>

Without “sliding” transition effect (affects iOS theme only)

  1. <Navbar title="My App" backLink="Back" sliding="{false}"></Navbar>

With additional right link to open right panel

  1. <Navbar title="My App" backLink="Back">
  2. <NavRight>
  3. <Link icon="icon-bars" panelOpen="right"></Link>
  4. </NavRight>
  5. </Navbar>

With large title

  1. <Navbar title="My App" backLink="Back" large></Navbar>
  2. <!-- with different large title text -->
  3. <Navbar title="My App" backLink="Back" large titleLarge="Large Title"></Navbar>

All three parts

  1. <Navbar>
  2. <NavLeft backLink="Back"></NavLeft>
  3. <NavTitle>My App</NavTitle>
  4. <NavRight>
  5. <Link icon="icon-bars" panelOpen="right"></Link>
  6. </NavRight>
  7. </Navbar>

Full custom layout

  1. <Navbar>
  2. <NavLeft>
  3. <Link>Left Link</Link>
  4. </NavLeft>
  5. <NavTitle>My App</NavTitle>
  6. <NavRight>
  7. <Link>Right Link</Link>
  8. </NavRight>
  9. </Navbar>

← Messages

Page →