Skip to main content

Link

The Link component is used to create a hyperlink to a web pages, file, email address, locatios in the same page, or anything else a URL can address.

Import

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

Code

<DhlLink href="#">Click here</DhlLink>
note

Using this component with the text variant will result in the link using the display: inline property, otherwise the link will use the display: inline-flex property.

Interactive Demo

Migrating from DUIL 1.0

  • Remove withButtonStyle prop object: isBlock, size and variant are now directly applicable
  • Add dataTitle

Changelog

v2.4.1-monorepo.8

Breaking changes
  • Deprecating isBlock property.
  • Add isFullWidth property - sets the link to 100% width of the parent container. Does NOT change the button to a block element.

Readme

Properties

PropertyAttributeDescriptionTypeDefault
clickEvent--An optional onClick callback handler.(e: MouseEvent) => voidundefined
dataAriaLabeldata-aria-labelAn optional prop defining the text read by the screen reader to represent the component; use this if you need different text to be read from label.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.stringundefined
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
externalexternalAn optional prop that indicates if link is pointing to outside of current domain. If set to true, the component will render an external link icon.booleanfalse
fontSizefont-sizeAn optional prop that defines the size of the text-variant link"10xl" \| "11xl" \| "2xl" \| "2xs" \| "3xl" \| "4xl" \| "5xl" \| "6xl" \| "7xl" \| "8xl" \| "9xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"undefined
href (required)hrefA REQUIRED href prop that specifies the links destinationstringundefined
isBlockis-block[DEPRECATED] An optional prop that sets whether the component should inherit the width of it's container.

booleanfalse
isFullWidthis-full-widthAn optional prop that sets the component to 100% width of it's parent container.booleanfalse
isStyledis-styledAn optional prop used to set/remove the styling of the component.booleantrue
relrelAn optional prop that specifies the relationship between the current document and the linked documentstringundefined
sizesizeAn optional size prop for the component. Note that size: 'sm' is currently equivalent to size: 'md'. The sm size will be deprecated in a future release."md" \| "sm" \| "xs"undefined
targettargetAn optional prop that specifies where to open the linked documentstringundefined
underlineunderlineAn optional prop that sets the component to have an underline. Works only with the variant text.booleantrue
variantvariantAn optional prop to select a component design variant."outline" \| "primary" \| "text"DHL_LINK.VARIANT.TEXT
weightweightAn optional prop used to set the font-weight property of the text component.200 \| 400 \| 700 \| 800undefined

Slots

SlotDescription
"unnamed"unnamed children slot intended for Link text

Dependencies

Used by

Depends on

Graph


Built by DHL User Interface Library Team!