Expandable text
ProText cut to a few lines with "See more", shown only when it is cut, that expands it in place: posts, comments, reviews and bios. Not an M3 component (@windmorph/react-pro).
import { ExpandableText } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Purpose
Long text cut to a few lines, with "See more" at the end of the last line that expands it in place: posts, comments, reviews, listing descriptions and bios. Clamping is one line of CSS, but showing the button only when the text is actually cut needs measuring, again whenever the width changes, and expanding has to keep focus where the reader is. It is not an M3 component, so it comes from @windmorph/react-pro.
To hide whole sections behind a heading, use a list or a disclosure instead; to open the full text somewhere else, use a Link to its page.
Behaviour
linessets how many lines show (5 by default). Line breaks in the text are kept, and it can hold inline content such as links and mentions.- "See more" shows only when the text is cut, measured again when the width changes, the text changes or web fonts arrive. The end of the last line fades out under it, so it works on any container colour.
- Expanding is instant, with no height animation, so the text never moves under the reader. There is no "See less" by default;
collapsibleadds one. - "See less" never jumps the page: focus returns to "See more" without scrolling, and the text's start is brought back into view only when it is above the window (smoothly, at once under reduced motion).
expandedandonExpandedChangecontrol it, for example to keep a post open when a virtualised feed mounts it again;defaultExpandedstarts it open.- Server-rendered pages show the text clamped from the first paint, with no layout shift. Without JavaScript the full text shows.
When not to use
For whole sections behind a heading use a list or a disclosure; to open the full text on its own page, a Link.
See also
- Card: A container for related content in three forms: static, pressable or a link.
- Link: Navigation written as text: in a sentence, as a name, or on its own line. Underlined in text, routed like every library link, with new-tab handling. Not an M3 component (@windmorph/react-pro).
- List: Rows with headline, overline, supporting text and leading or trailing content (icons, avatars, images, video thumbnails); items can be links, switches, checkboxes or radio buttons, and put in order by drag or a menu.