Skip to main content

ReadMore

The DhlReadMore component is used on a page to make a long text expand and collapsable based on number of lines to be visible by default.

Import

// with @dhl-official/react-library:
import { DhlReadMore } from "@dhl-official/react-library"
// with @dhl-official/ui-libraries/react-library:
import { DhlReadMore } from "@dhl-official/ui-libraries/react-library"

Code

<DhlReadMore>Some long text be here.</DhlReadMore>

Interactive Demo

Readme

Properties

PropertyAttributeDescriptionTypeDefault
dataAriaControlsdata-aria-controlsAn optional ariaControls prop that is used as a 'relationship attribute' which denotes which elements in a page an interactive element or set of elements has control over and affects. It's commonly used to describe a relationship between a button and the expandable region revealed by that button.stringundefined
dataClassNamedata-class-nameAn optional class name prop for the component.stringundefined
dataIddata-idAn optional prop. Gives a valid HTML ID attribute value for the component.stringdhl-read-more-${getRandomString()}
dataTestiddata-testidAn optional prop. The test id attached to the component as a data-testid attribute.stringundefined
dataTitledata-titleAn optional prop used to set the title for the text component.stringundefined
dataTrackingdata-trackingAn optional data tracking prop for the component.stringundefined
fontStylefont-styleAn optional prop used to set the font-style property of the text component."italic" \| "normal"undefined
isExpandedis-expandedAn optional prop used to set if the text be expanded or collapsedbooleanfalse
isParagraphis-paragraphAn optional prop used to set if ReadMore should use a <p> instead of a <span> tag.booleanundefined
lesslessAn optional prop used to set the text to display on the show less button.string"Read Less"
lineslinesAn optional prop used to set the amount of lines of text that should be preserved until truncating. Any integer < 1 will not clip at allnumber3
moremoreAn optional prop used to set the text to display on the show more button.string"Read More"
sizesizeAn optional size prop for the component."10xl" \| "11xl" \| "2xl" \| "2xs" \| "3xl" \| "4xl" \| "5xl" \| "6xl" \| "7xl" \| "8xl" \| "9xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"undefined
stretchstretchAn optional prop used to set the font-stretch property of the component."condensed" \| "normal"undefined
weightweightAn optional prop used to set the font-weight property of the text component.200 \| 400 \| 700 \| 800undefined

Slots

SlotDescription
"unnamed"unnamed children slot for ReadMore text

Dependencies

Depends on

Graph


Built by DHL User Interface Library Team!