← Back


Polymer-based web component for a D2L more-less control




[ This description is mirrored from at on 2019-05-22 ]


Published on Bower version Build status

Polymer-based web component for D2L's more/less control.

For further information on this and other components, refer to The Brightspace UI Guide.


bower install d2l-more-less


Include the webcomponents.js "lite" polyfill (for browsers who don't natively support web components), then import d2l-more-less.html:

  <script src="../webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="../d2l-more-less/d2l-more-less.html">

You can now wrap a d2l-more-less element around any content:

  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ultricies, ligula vulputate mattis aliquam, arcu arcu porttitor urna, ut pretium neque lorem venenatis elit. Fusce rutrum, nunc a tempor dictum, elit est lobortis libero, at lobortis nisl libero id enim. Vestibulum in lorem sed metus ornare faucibus a ac massa. Donec sodales massa vitae lacus blandit, at placerat erat blandit. Aenean consequat sapien ac viverra ornare. Nullam sem felis, ultrices nec egestas ut, mollis ac arcu. Nunc sit amet aliquam neque, fringilla lobortis justo. Sed pharetra, ipsum ut tempor tempor, sem risus tincidunt nisl, vitae feugiat lectus lorem a urna. In sit amet lobortis tellus. Sed suscipit magna et aliquam consequat. Pellentesque rhoncus ut dui at semper. Mauris vel ante euismod, tempus nunc eu, pellentesque lacus. Mauris consectetur ante eget consequat tempus.</p>


height (4em)

The height attribute sets the maximum height of the content when in "less" mode. The d2l-more-less element itself will take up additional vertical space in order to provide the fading effect and the more/less controls themselves. If the content is not at least this height, d2l-more-less will become inactive and add nothing to the page.

<d2l-more-less height="10rem">
    <!-- content -->


The expanded attribute will be present when d2l-more-less is in "more" mode. The element can also be made expanded by default by using this attribute.

<d2l-more-less expanded>
    <!-- content -->

blur-color (#fff)

The blur-color attribute will control the gradient color of the blurring effect. It must be a properly formatted HEX color code, either in shorthand or longform.

<d2l-more-less blur-color="#f00">
    <!-- content -->


The h-align attribute controls the horizontal alignment of the more-less button, as documented in the BrightspaceUI/button component.

<d2l-more-less h-align="text">
    <!-- content -->

Developing, Testing and Contributing

After cloning the repo, run npm install to install dependencies.

If you don't have it already, install the Polymer CLI globally:

npm install -g polymer-cli

To start a local web server that hosts the demo page and tests:

polymer serve

To lint (eslint and Polymer lint):

npm run lint


Commits and PR merges to master will automatically do a minor version bump which will:

  • Update the version in package.json
  • Add a tag matching the new version
  • Create a github release matching the new version

By using either [increment major] or [increment patch] notation inside your merge message, you can overwrite the default version upgrade of minor to the position of your choice.


(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.



Apache License 2.0


Polymer 2.0+
Polymer 1.0+ in 2.2.2
Browser Independent