Etch component

Read More 1

Collapsible content with an animated Read more / Read less trigger, bottom fade mask, overlay trigger modes, and auto-hide when content is short.

Read More 1

Copy Read More 1

Configurator settings

Change a setting in the configurator to include it.

Optional. Copies the component under its own name, such as News Card Alpha for a site.

Documentation

Content cut to a set height, with a fade at the bottom and a "Read more" button that opens the rest. When the content is short enough, the button doesn't show.

How to use it

  • Put the content in the content slot.
  • Collapsed Height sets the closed height in pixels (160 by default).
  • Expand Button Text and Collapse Button Text set the labels, and Start Open shows the content open.
  • The button sits below the content, in the middle, with a fade of 80px at the bottom of the closed content. The button over the fade or in the middle of the content, and at the start, are CSS recipes, below. Try them in the preview's Styles tab, then paste the ones you pick in the site's main stylesheet.

Good to know

  • Opening and closing animate, except for visitors who ask their device for reduced motion.
  • The configurator tries the height and Start Open. Copy the configured JSON once they're set.
  • For your own CSS, the states are data attributes: [data-expanded="true"] on the root while it's open, and [data-toggle="false"] when the content fits and the button is hidden.

CSS recipes

--mac-read-more-1-trigger-position puts the button over the closed content, at its bottom (overlay) or in its middle (overlay-center), instead of below it. --mac-read-more-1-trigger-align aligns the button below the content (center by default, flex-start or flex-end), and --mac-read-more-1-mask-amount sets how far up the fade reaches (80px, or 0px for a hard cut). The script reads the position once, as the page loads. A recipe changes every Read More 1 on the site. Paste it in the site's main stylesheet, which Etch prints after the components' styles.

The button over the fade

For a compact block, the button over the bottom of the closed content, on its fade.

/* Read More 1's button over the fade */
.mac-read-more-1 {
  --mac-read-more-1-trigger-position: overlay;
}

The button in the middle

For a teaser, the button in the middle of the closed content, over a fade that covers all of it. Once the content opens, the button moves to its end.

/* Read More 1's button in the middle of the closed content */
.mac-read-more-1 {
  --mac-read-more-1-trigger-position: overlay-center;
  --mac-read-more-1-mask-amount: 100%;
}

The button at the start

For text aligned to the start, the button under it at the start instead of the middle.

/* Read More 1's button at the start */
.mac-read-more-1 {
  --mac-read-more-1-trigger-align: flex-start;
}

Reference

Read from the component's JSON, so it's always current.

Loading the reference