Read More
Collapses long text or rich content to a short preview with a Read more button. The button appears only when the content is taller than the height you set, and the fade blends into any background. It works with the keyboard and screen readers, in Etch loops and with content loaded by AJAX. You set it up in the Etch props panel and style it with CSS variables.
Stay up to date. Etch won’t update a pasted component for you. Subscribe and get one email when a new version is out.
11 examples in real layouts
Click Read more, use Tab and Enter, or try Expand all in the FAQ. Mobile switches the frame to phone width, where one more example collapses.
What it does
One pasted component with its own CSS and script. There is no library behind it and nothing loads from a CDN.
A button only when it’s needed
The button shows up only when the content is taller than the collapsed height plus a small margin. It measures again when the width, fonts, images or content change, so short text never gets a pointless toggle.
Text or nested elements
Show the Text prop with its line breaks, including dynamic data such as an excerpt. Or switch to Nested elements and put headings, images, lists, tables and other components into the slot.
Any CSS height
Use 12rem, 180px, clamp() or 4lh for about four lines. A CSS variable can set none in a media query, so the content collapses on phones and shows in full on wider screens.
A fade for any background
The fade is a transparency mask, so it blends into a flat color, a gradient or a photo, and there is no color to match. Two props set where it starts and ends.
Accessible by default
A native button with aria-expanded and aria-controls and a focus ring in the text color. Keyboard focus that lands in clipped content opens it. Checked with NVDA, VoiceOver and TalkBack.
37 styling variables
Colors, fonts, the button frame, hover, focus, the icon and the motion, set on any parent class. Button style switches to Text only. ACSS 4 tokens with plain fallbacks, so it also works without Automatic.css.
Control it with or without code
Command events expand, collapse or refresh one instance, a section or the whole page. A button or link with two data attributes does the same with no code at all, for example Expand all in a FAQ.
Ready for loops and AJAX
Each instance keeps its own state and IDs, so it works in Etch loops. Instances that arrive later by AJAX, for example from a Load more button, start within a frame.
Add it in four steps
The CSS and the script travel inside the component, so there is no plugin to install and no library to load. It works with or without Automatic.css 4.
Shows without its styles? It was pasted but not saved, and pasting again won’t repair it. Delete ED Read More from your components, paste it again and click Save.
- Copy the componentUse Copy component at the top of this page, or download the .json file.
- Paste it on the Etch canvasSelect where it should go, press Ctrl+V or ⌘V, then click Save. Etch adds the component to your list right away but stores its CSS only when you save.
- Add your contentReplace the sample Text, or set Content source to Nested elements and put headings, images and lists into the content slot.
- Set the height and the labelsChoose a Collapsed height and the button texts. Every prop edit shows in the canvas at once, without saving. The canvas keeps the content open for editing; Builder preview shows the collapsed view.
22 settings in the Etch props panel
In the order of the Etch props panel, where each setting has help text too. Numbers are typed as plain text, because Etch has no number prop.
Before you place it
Details that are easy to miss when the component goes onto a real site.
- Screen readers get the whole text. The collapsed height is visual only. Clipped content stays in the accessibility tree, so no paragraph is cut in half for screen reader users and nothing is duplicated.
- Rich text needs Nested elements. Text mode escapes HTML, so a WYSIWYG field shows its tags. Set Content source to Nested elements and put a div with the Etch HTML element into the content slot.
- No percentage heights. The component’s own height depends on the collapsed height, so a percentage can’t work. Use rem, px, lh, clamp() or a spacing variable.
- Text only keeps its own frame. Button style Text only sets padding, minimum size, background, border, shadow and the hover underline on the button itself. Frame values you set on a wrapper for the outline button don’t reach it.
- A filled button needs its own focus color. The ring takes the label color, so white text on a fill would draw a white ring. Set
--ed-read-more-focus-colorto the fill or a darker shade, and check 3:1 against the page. - Sticky header? Add scroll padding. When a collapse scrolls the button back into view, it can land under a sticky header. Set
scroll-padding-topon html to the header height. - Find in page can’t open it. Browsers fire no event when Ctrl+F finds text under the fade, so the match stays clipped. Links to an id or a text fragment and keyboard focus do expand the content.
- Without JavaScript, everything shows. The content shows in full and the button stays hidden. Printing also shows the full content, without the button and the fade.
- Some content is out of scope. Fixed or sticky elements, areas that scroll on their own, autoplay media and vertical writing modes inside the content are not supported.
- Not tested yet: VoiceOver on a physical iPhone, and JAWS. It was checked in Chrome, Firefox, Safari, Microsoft Edge and WebKit, with VoiceOver on macOS, NVDA with Chrome and Firefox, TalkBack on an Android emulator and Safari in the iOS Simulator.
Free to use. Not for resale.
Licensed under FSL-1.1-MIT, the Functional Source License with an MIT future license. Each version becomes MIT-licensed two years after its release.
- Use it on unlimited personal, client and commercial websites
- Modify and adapt it however you like
- Use it in paid design and development work for your clients
- Sell it, or a modified version, as a component: in a library, bundle, template kit, plugin or marketplace listing
- Offer it in another commercial product or service that competes with it
Keep the copyright and license notices in the code, and link to this page instead of re-hosting the download, so everyone gets fixes and updates. Read the full license
Third-party code
None. This component is all my own code under FSL-1.1-MIT. It bundles no library and loads no icon font or external script.
How to update
Etch has no update button for pasted components. Pasting a newer version over an installed one changes nothing: Etch keeps the component and the CSS it already has. To update, reinstall in five steps.
- Note what you setWrite down the settings and slot content of each instance, and copy any CSS you changed in the component’s own styles.
- Delete the componentIn Etch, delete ED Read More from your components. Every instance disappears from every page that used it.
- Delete its stylesIn the Style Manager, search for ed-read-more and delete the 11 styles listed below. Only the first one holds CSS; the others are empty class names.
- Paste the new versionCopy or download the new JSON from this page, paste it on the canvas and click Save. Etch creates the component and its CSS fresh.
- Put your instances backInsert an instance wherever one was, re-enter its settings and slot content, and save. Reload any other open builder tab.
Styles to delete in step 3
.ed-read-more.ed-read-more__viewport.ed-read-more__content.ed-read-more__slot.ed-read-more__text.ed-read-more__button.ed-read-more__label.ed-read-more__icon.ed-read-more__chevron.ed-read-more__custom-icon.ed-read-more__measure
Trade-offs
- Placements are not kept. Etch doesn’t link old instances to the new component, so you insert each one again and re-enter its settings.
- Edits inside the component’s CSS are replaced. Keep overrides on a parent class with the
--ed-read-more-*variables; those survive an update. - Skipping a step leaves a mix. Without step 2, Etch keeps the old component. Without step 3, the new version runs on the old CSS.
- Your trigger buttons stay as they are. Expand all and Collapse all buttons with data-ed-rm-action are ordinary page elements, so an update doesn’t touch them.
Nothing to update yet. This is the first version on etchdeveloper.com. Subscribe and you’ll get one email when the next one is out.
What changed
Versions follow semantic versioning. When an update changes how existing options behave, its entry says so.
1.0.0-beta.4Latest
- ReleasedFirst version on etchdeveloper.com. It stays a beta until VoiceOver on a physical iPhone and JAWS are tested.
Tell me what this component needs
A bug, a missing option, or anything that made the component awkward to use in a real build — it all belongs here. The versions above are the ones it was tested on; if yours differ, say so.