Appearance
Nav Element
Provides a responsive page navigation menu which handles positioning and social links
Usage
Basic Usage
The <page-nav>
element is intended to act as the page's primary navigation menu. It does not provide any content of its own, instead wrapping supplied content with a native <nav>
element, as well as responsive styling that rolls content behind a hamburger menu on smaller viewports.
With Social Links
It is common for a page's primary navigation menu to also include links to other sources of content, such as social networks like LinkedIn, or hosted services like GitHub. To facilitate this, the <page-nav>
element provides a socials
slot.
Links placed in the socials
slot will be automatically transformed into logo images for the site they link to, based on the contents of the href
attribute of the link, and can be placed in any order.
BYO Socials
It's also possible to include your own icon for links to sources that aren't already handled. This is done either by including an <img>
element in the link, or with inline SVG markup.
Where the <page-nav>
element detects an <img>
element whose source is an SVG file, it will attempt to fetch the SVG file for inline rendering, so that styling can be applied consistently across all icons.
Responsive Sizing
For container widths typical of smaller viewports, the <page-nav>
element will automatically fold behind a "hamburger menu". This means that navigation links need only be specified once in a page's markup.
The appearance of the <page-nav>
element and its contents for variable container widths is demonstrated in the example below.
html
<page-nav>
<a href="#link1">Link 1</a>
<a href="#link2">Link 2</a>
<a slot="socials" href="https://www.twitter.com">Twitter</a>
<a slot="socials" href="https://www.npmjs.com">NPM</a>
<a slot="socials" href="https://github.com/sleelin/portfolito">GitHub</a>
</page-nav>
CSS Parts
Name | Description |
---|---|
container | Responsive container element |
content | Wrapper for native nav element |
links | Wrapper for non-social page links |
socials | Wrapper for social page links |
CSS Variables
Name | Description | Type | Default |
---|---|---|---|
--container-textColor | Color of the links and social logos, and hamburger menu button | color |
|
--container-textColor-sm | Color of the links and social logos when hidden behind hamburger menu | color |
|
--container-hoverColor | Color of the links and social logos on hover | color |
|
--link-shadowColor | Color of the radial shadow of links on hover | color |
|
Slots
Name | Description | Type |
---|---|---|
none | In-page navigation links to content with specific IDs | <a> |
socials | Links to social networks, displayed with relevant logo | <a> |