Skip to main content

Anchor

Anchors enable you to show links of different types of in a page.

Use cases:

  • a hyperlink to a different page
  • linking to a specific region of the current page
  • an email link that pre-populates the recipient field

Example

There are three working links in the example below.

External linkInternal linkMail link

Declaration

<rapid-anchor></rapid-anchor>

Usage

@customElement({
name: 'my-element',
template: html`
<rapid-anchor href="https://genesis.global/">External link</rapid-anchor>
<rapid-anchor href="#api">Internal link</rapid-anchor>
<rapid-anchor href="mailto:info@genesis.global">Mail link</rapid-anchor>
`,
})
export class MyElement extends GenesisElement { }

API

Attributes

AttributeTypeDescriptionExample
downloadstring | booleanCauses the browser to treat the linked URL as a download. This attributes only works for same-origin URLs, or when using the blob: and data: schemes. Different browsers behave slightly differently for downloads, such as asking the user where to save the file or automatically saving to a downloads directory.
<rapid-anchor href="files/genesis.pdf" download>
hrefstringThe URL that the hyperlink points to. This is commonly to another page in your app, but it could be to a region of the current page. You can also use schemes such as mailto:, javascript:, tel:, and sms:
<rapid-anchor href="https://genesis.global/">
hreflangstringA hint to the language of the linked document. Doesn't add any functionality itself.
<rapid-anchor href="https://genesis.global/" hreflang="en">
pingstringA space-separated list of URLs to which to send a PING message. This is commonly used for tracking.
<rapid-anchor ping="https://genesis.global/">
referrerstringHow much of the referrer to send when the user clicks the link.
<rapid-anchor href="https://genesis.global/" referrer="no-referrer">
relstringThe relationship of the linked URL to the current page. Examples are the next or previous page, the author's page, or to help documentation.
<rapid-anchor href="https://genesis.global/author" rel="author">
Author's page
</rapid-anchor>
target"_blank" | "_self" | "_parent"Where to display the linked URL. Most common use is to set _blank for making the link open in a new tab or window.
<rapid-anchor href="https://genesis.global/" target="_blank">
typestringA hint to the media type of the linked document. Doesn't add any functionality itself.
<rapid-anchor href="https://genesis.global/" type="application/pdf">

Properties

The properties of this component are all controlled via attributes.

Slots

SlotDescription
DefaultThe elements that are contained in the anchor region, and which trigger the href when clicked.
startOptional content to be placed before the anchor content.
endOptional content to be placed after the anchor content.

Parts

PartDescription
controlThe anchor element.
contentThe element wrapping the anchor content.

Events fired

This component doesn't emit any events.

Events listened to

This component doesn't listen to any events.