add OutboundLink (#504)

* feat(link): add OutboundLink

* fix(outbound-link): forward Link events
This commit is contained in:
Eric Liu 2021-02-03 05:27:24 -08:00 committed by GitHub
commit 251f986304
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 85 additions and 7 deletions

View file

@ -1,5 +1,5 @@
<script>
import { Link } from "carbon-components-svelte";
import { Link, OutboundLink } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";
</script>
@ -9,14 +9,18 @@
### Target _blank
Setting `target` to `"_blank"` opens the link in a new tab.
If `target="_blank"`, the `Link` component will automatically set `rel="noopener noreferrer"` to guard against [potential cross-origin security exploits](https://web.dev/external-anchors-use-rel-noopener/).
If setting `target` to `"_blank"`, the `Link` component will automatically set `rel="noopener noreferrer"` to guard against [potential cross-origin security exploits](https://web.dev/external-anchors-use-rel-noopener/).
You can override the `rel` attribute with a custom value.
<Link href="https://www.carbondesignsystem.com/" target="_blank">Carbon Design System</Link>
### Outbound link
An alternative to manually setting `target` to `"_blank"` is to use the `OutboundLink`.
<OutboundLink href="https://www.carbondesignsystem.com/">Carbon Design System</OutboundLink>
### Inline variant
<div>