Back to Mjml

README

packages/mjml-accordion/README.md

5.1.011.2 KB
Original Source

mj-accordion

An interactive MJML component that stacks content in tabs, so the information is collapsed and only the titles are visible.

Readers can interact by clicking on the tabs to reveal the content, providing a better experience for mobile users by reducing the amount of scrolling.

<figure> </figure> <div class="alert alert-note" role="alert"> <p>Note</p> <p><code>mj-accordion-text</code> and <code>mj-accordion-title</code> are "ending tags", which means that they can contain HTML code but they cannot contain other MJML components.</p> <p>More information about ending tags <a href="#ending-tags">in this section</a>.</p> </div>
xml
<mjml>
  <mj-head>
    <mj-attributes>
      <mj-accordion border="none" padding="1px" />
      <mj-accordion-element icon-wrapped-url="https://static.mailjet.com/mjml-website/documentation/accordion-arrow-down.png" icon-unwrapped-url="https://static.mailjet.com/mjml-website/documentation/accordion-arrow-up.png" icon-height="24px" icon-width="24px" />
      <mj-accordion-title font-family="Roboto, Open Sans, Helvetica, Arial, sans-serif" background-color="#fff" color="#031017" padding="15px" font-size="18px" />
      <mj-accordion-text font-family="Open Sans, Helvetica, Arial, sans-serif" background-color="#fafafa" padding="15px" color="#505050" font-size="14px" />
    </mj-attributes>
  </mj-head>

  <mj-body>
    <mj-section padding="20px" background-color="#ffffff">
      <mj-column background-color="#dededd">
        <mj-accordion>
          <mj-accordion-element>
            <mj-accordion-title>Why use an accordion?</mj-accordion-title>
            <mj-accordion-text>
              <span style="line-height:20px">
                Because emails with a lot of content are most of the time a very bad experience on mobile, mj-accordion comes handy when you want to deliver a lot of information in a concise way.
              </span>
            </mj-accordion-text>
          </mj-accordion-element>
          <mj-accordion-element>
            <mj-accordion-title>How it works</mj-accordion-title>
            <mj-accordion-text>
              <span style="line-height:20px">
                Content is stacked into tabs and users can expand them at will. If responsive styles are not supported (mostly on desktop clients), tabs are then expanded and your content is readable at once.
              </span>
            </mj-accordion-text>
          </mj-accordion-element>
        </mj-accordion>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

Attributes

attributeacceptsdescriptiondefault value
borderstringCSS border format2px solid black
container-background-colorCSS color formatsbackground-color of the cell
css-classstringclass name, added to the root HTML element created
font-familystringfontUbuntu, Helvetica, Arial, sans-serif
icon-aligntop middle bottomicon alignmentmiddle
icon-heightpx %icon height32px
icon-positionleft,
rightdisplay icon left or rightright
icon-unwrapped-altstringalt text when accordion is unwrapped-
icon-unwrapped-urlstringicon when accordion is unwrappedhttps://i.imgur.com/w4uTygT.png
icon-widthpx %icon width32px
icon-wrapped-altstringalt text when accordion is wrapped+
icon-wrapped-urlstringicon when accordion is wrappedhttps://i.imgur.com/bIXv1bk.png
paddingpx %accordion padding, supports up to 4 parameters10px 25px
padding-bottompx %accordion bottom padding
padding-leftpx %accordion left padding
padding-rightpx %accordion right padding
padding-toppx %accordion top padding
<p class="cta-container"><a class="cta" href="https://mjml.io/try-it-live/components/accordion">Try it live</a></p>

mj-accordion-element

Creates an accordion title/text pair. An accordion can have any number of these pairs.

<div class="alert alert-note" role="alert"> <p>Note</p> <p>Inheritance applies for attributes supported in both <code>mj-accordion</code> and <code>mj-accordion-element</code> except where the latter overrides.</p> </div>
Attributes
attributeacceptsdescriptiondefault value
background-colorCSS color formatsbackground color
borderstringCSS border format.
affects each horizontal border in the accordion except the top one
css-classstringclass name, added to the root HTML element created
font-familystringfont
icon-aligntop middle bottomicon alignment
icon-heightpx %icon width32px
icon-positionleft rightpostion of icon
icon-unwrapped-altstringalt text when accordion is unwrapped
icon-unwrapped-urlstringicon when accordion is unwrapped
icon-widthpx %icon height32px
icon-wrapped-altstringalt text when accordion is wrapped
icon-wrapped-urlstringicon when accordion is wrapped

mj-accordion-title

Displays the title in a title/text pair.

Attributes
attributeacceptsdescriptiondefault value
background-colorCSS color formatsbackground color
colorCSS color formatstext color
css-classstringclass name, added to the root HTML element created
font-familystringfont family
font-sizepxfont size13px
font-weightstringtext thickness
paddingpx %accordion title padding, supports up to 4 parameters16px
padding-bottompx %accordion title bottom padding
padding-leftpx %accordion title left padding
padding-rightpx %accordion title right padding
padding-toppx %accordion title top padding

mj-accordion-text

Displays the text in a title/text pair.

Attributes
attributeacceptsdescriptiondefault value
background-colorCSS color formatsbackground color
colorCSS color formatstext color
css-classstringclass name, added to the root HTML element created
font-familystringfont family
font-sizepxfont size13px
font-weightstringtext thickness
letter-spacingpx emletter spacing
line-heightpx %space between the lines1
paddingpx %accordion text padding, supports up to 4 parameters16px
padding-bottompx %accordion text bottom padding
padding-leftpx %accordion text left padding
padding-rightpx %accordion text right padding
padding-toppx %accordion text top padding