Skip to content
Calm motion: animations on this site only fade, with no movement

ReadMore ​

Long text cut to some lines, with a button to show all

Keeps a long description, a review, or a biography short until people ask for more. Use it in a card or a list, where many long texts would push the rest down. For a section with a title that opens and closes, use a collapsible. In a chat, the bubble has its own collapsible.

Basic
Tomoya Aki is an otaku who meets a girl under the cherry blossoms on a spring day, and he decides to make a visual novel with her as the heroine. He gathers a team: a famous illustrator who is his childhood friend, a popular novelist who is his senior, and his cousin, who plays in a band. The girl, Megumi Katō, turns out to be so plain that nobody notices her. Tomoya must make her a heroine whom the players love, before the winter market.
This text fits, so there is no button.
  • Put the text in the default slot. lines sets how many lines show while it is closed (default 3). The cut line ends with an ellipsis.
  • The button shows only when the text is cut. The component measures the text in the browser and again when its size changes, so a wider screen can remove the button. The server renders no button.
  • The button says "Read more" and "Show less", and it has aria-expanded and aria-controls. v-model:open holds the state.
  • The whole text is in the page, also while it is cut, so a screen reader and the browser's find can reach all of it.
  • The slot is for text: a paragraph, or inline elements. Lists and headings in it are cut by lines in the same way, but they can read strangely.
  • Change the words with labels or a label pack: more and less.

Usage ​

ts
import { BlessReadMore } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
linesnumber3lines shown while closed
labelsPartial<{ more: string; less: string; }>—
openbooleanfalse

Events

NamePayloadDescription
update:open[value: boolean]

Slots

NameScopeDescription
default—

Released under the MIT License. Character names and artwork belong to their owners.