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
Prop | Type | Default | Description |
---|---|---|---|
<Navbar> properties | |||
title | string | Navbar title | |
subtitle | string | Navbar sub title | |
backLink | boolean string | Adds back-link with text (if string value is specified) | |
backLinkUrl | string | Custom back link URL | |
backLinkForce | boolean | false | Force page to load and ignore previous page in history |
backLinkShowText | boolean | By default back link text disable for MD theme | |
sliding | boolean | true | Enables "sliding" effect for nav elements |
noShadow | boolean | false | Disable shadow rendering for Material theme |
noHairline | boolean | false | Disable navbar bottom thin border (hairline) for iOS theme |
hidden | boolean | false | Makes navbar hidden |
innerClass | string | Adds additional class to navbar-inner element | |
innerClassName | string | Alias for innerClass prop | |
large | boolean | Enables navbar with large title | |
transparent | boolean | Makes navbar transparent. Can be used in addition to large prop to make large navbar transparent. | |
titleLarge | string | Navbar large title text. If not specified then will be equal to title prop | |
<NavLeft> properties | |||
backLink | boolean string | Adds back-link with text (if string value is specified) | |
backLinkUrl | string | Custom back link URL | |
backLinkForce | boolean | false | Force page to load and ignore previous page in history |
backLinkShowText | boolean | By default back link text disable for MD theme | |
sliding | boolean | Enables "sliding" effect. By default inherits sliding prop of parent Navbar | |
<NavTitle> properties | |||
title | string | Specifies element inner title text (affects if there is no child elements) | |
subtitle | string | Sub title text | |
sliding | boolean | Enables "sliding" effect. By default inherits sliding prop of parent Navbar | |
<NavRight> properties | |||
sliding | boolean | Enables "sliding" effect. By default inherits sliding prop of parent Navbar |
Navbar Methods
<Navbar> methods | |
---|---|
.hide(animate) | Hide navbar |
.show(animate) | Show navbar |
.size() | Size navbar |
Navbar Events
Event | Description |
---|---|
<Navbar> events | |
backClick clickBack | Event will be triggered after click on navbar back link |
navbarHide | Event will be triggered when Navbar becomes hidden |
navbarShow | Event will be triggered when Navbar becomes visible |
navbarCollapse | Event will be triggered when Navbar with large title collapsed (from large navbar to usual navbar) |
navbarExpand | Event 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">
elementbefore-inner
- element will be inserted right before<div class="navbar-inner">
elementafter-inner
- element will be inserted right after<div class="navbar-inner">
elementleft
- element will be inserted in navbar's left elementright
- element will be inserted in navbar's right elementtitle
- element will be inserted in navbar's title elementtitle-large
- element will be inserted in navbar's large title text element
<Navbar title="My App">
<a href="#" slot="left">Left Link</a>
<a href="#" slot="right">Right Link</a>
<div slot="before-inner">Before Inner</div>
<div slot="after-inner">After Inner</div>
<div>Default slot</div>
</Navbar>
<!-- Renders to: -->
<div class="navbar">
<div class="navbar-bg"></div>
<div>Before Inner</div>
<div class="navbar-inner">
<div class="left">
<a href="#">Left Link</a>
</div>
<div class="title">My App</div>
<div class="right">
<a href="#">Right Link</a>
</div>
<div>Default slot</div>
</div>
<div>After Inner</div>
</div>
Examples
Minimal layout
<Navbar title="My App"></Navbar>
Minimal layout with back link
<Navbar title="My App" backLink="Back"></Navbar>
Without "sliding" transition effect (affects iOS theme only)
<Navbar title="My App" backLink="Back" sliding="{false}"></Navbar>
With additional right link to open right panel
<Navbar title="My App" backLink="Back">
<NavRight>
<Link icon="icon-bars" panelOpen="right"></Link>
</NavRight>
</Navbar>
With large title
<Navbar title="My App" backLink="Back" large></Navbar>
<!-- with different large title text -->
<Navbar title="My App" backLink="Back" large titleLarge="Large Title"></Navbar>
All three parts
<Navbar>
<NavLeft backLink="Back"></NavLeft>
<NavTitle>My App</NavTitle>
<NavRight>
<Link icon="icon-bars" panelOpen="right"></Link>
</NavRight>
</Navbar>
Full custom layout
<Navbar>
<NavLeft>
<Link>Left Link</Link>
</NavLeft>
<NavTitle>My App</NavTitle>
<NavRight>
<Link>Right Link</Link>
</NavRight>
</Navbar>