Back to Mjml

README

packages/mjml-navbar/README.md

5.1.010.9 KB
Original Source

mj-navbar

Displays a navigation menu with an optional hamburger mode for mobile devices.

xml
<mjml>
  <mj-body>
    <mj-section background-color="#ef6451">
      <mj-column>
        <mj-navbar base-url="https://mjml.io" hamburger="hamburger" ico-color="#ffffff">
            <mj-navbar-link href="/gettings-started-onboard" color="#ffffff">Getting started</mj-navbar-link>
            <mj-navbar-link href="/try-it-live" color="#ffffff">Try it live</mj-navbar-link>
            <mj-navbar-link href="/templates" color="#ffffff">Templates</mj-navbar-link>
            <mj-navbar-link href="/components" color="#ffffff">Components</mj-navbar-link>
        </mj-navbar>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>
<figure> <figcaption>Standard Desktop</figcaption> </figure> <figure> <figcaption>Standard Mobile</figcaption> </figure> <figure> <figcaption>Mode hamburger enabled:</figcaption> </figure> <div class="alert alert-note" role="alert"> <p>Note</p> <p>The hamburger feature works only on Apple Mail clients, when the width is below the specified (or default) breakpoint. For other email clients, the links are displayed inline and the hamburger icon is not visible.</p> </div> <div class="alert alert-note" role="alert"> <p>Note</p> <p>All attributes prefixed with <code>ico-</code> help to customize the hamburger icon, hence they only work with the hamburger mode enabled.</p> </div>

Attributes

attributeacceptsdescriptiondefault value
alignleft
center
rightalign contentcenter
base-urlstringbase URL for child componentsnull
css-classstringclass name, added to the root HTML element created
hamburgerstringactivate the hamburger navigation on mobile if the value is hamburgernull
ico-alignleft
center
righthamburger icon alignment
(hamburger="hamburger" required)center
ico-closestringchar code for a custom close icon, e.g. ASCII code decimal
(hamburger="hamburger" required)&#8855;
ico-colorCSS color formatshamburger icon color
(hamburger="hamburger" required)#000000
ico-font-familystringhamburger icon font
(hamburger="hamburger" required)Ubuntu, Helvetica, Arial, sans-serif
ico-font-sizepx %hamburger icon size
(hamburger="hamburger" required)30px
ico-line-heightpx %hamburger icon line height
(hamburger="hamburger" required)30px
ico-openstringchar code for a custom open icon, e.g. ASCII code decimal
(hamburger="hamburger" required)&#9776;
ico-paddingpx %hamburger icon padding, supports up to 4 parameters
(hamburger="hamburger" required)10px
ico-padding-bottompx %hamburger icon bottom padding
(hamburger="hamburger" required)
ico-padding-leftpx %hamburger icon left padding
(hamburger="hamburger" required)
ico-padding-rightpx %hamburger icon right padding
(hamburger="hamburger" required)
ico-padding-toppx %hamburger icon top padding
(hamburger="hamburger" required)
ico-text-decorationstringhamburger icon text decoration e.g. none underline overline line-through
(hamburger="hamburger" required)none
ico-text-transformstringhamburger icon text transformation none capitalize uppercase lowercase
(hamburger="hamburger" required)uppercase
paddingpx %navbar padding, supports up to 4 parameters
padding-bottompx %navbar bottom padding
padding-leftpx %navbar left padding
padding-rightpx %navbar right padding
padding-toppx %navbar top padding
<p class="cta-container"><a class="cta" href="https://mjml.io/try-it-live/components/navbar">Try it live</a></p>

mj-navbar-link

Used to display an individual link in the navbar. Individual links of the menu should be wrapped inside mj-navbar.

<div class="alert alert-important" role="alert"> <p>Important</p> <p>The <code>mj-navbar-link</code> component must be used inside an <code>mj-navbar</code> component only.</p> </div> <div class="alert alert-note" role="alert"> <p>Note</p> <p><code>mj-navbar-link</code> is an "ending tag", which means that it can contain HTML code but it cannot contain other MJML components.</p> <p>More information about ending tags <a href="#ending-tags">in this section</a>.</p> </div>

Attributes

attributeacceptsdescriptiondefault value
colorCSS color formatstext color#000000
css-classstringclass name, added to the root HTML element created
font-familystringfontUbuntu, Helvetica, Arial, sans-serif
font-sizepxtext size13px
font-stylestringCSS values, i.e. normal italic oblique
font-weightstringtext thickness
hrefstringlink to redirect to on click, in URL format
letter-spacingpx emletter-spacing
line-heightpx %space between the lines22px
namestringspecify the link name attribute
paddingpx %navbar link padding, supports up to 4 parameters15px 10px
padding-bottompx %bottom padding
padding-leftpx %left padding
padding-rightpx %right padding
padding-toppx %top padding
relstringspecify the rel attribute
targetstringlink target on click
text-decorationstringCSS values, i.e. underline overline nonenone
text-transformstringCSS values, i.e. capitalize uppercase lowercase noneuppercase