Links
Various design treatments for anchor elements.
Contents
Stretchable Links
Make any HTML element or component clickable by “stretching” a nested link via CSS.
Add .link-stretch
to a link to make its containing block clickable via a ::after
pseudo element. In most cases, this means that an element with position: relative;
that contains a link with the .link-stretch
class is clickable.
Examples
Using with Cards
By default, cards have position: relative
, so in this case you can safely add the .link-stretch
class to a link in the card without any other HTML changes.
Card with stretched link
Some quick example text to build on the card title and make up the bulk of the card's content.
Go somewhereUsing with Custom Components
Most custom components do not have position: relative
by default, so we need to add the .position-relative
here to prevent the link from stretching outside the parent element.
Custom component with stretched link
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
Go somewhereUsing with Columns
Columns are also position: relative
by default, so clickable columns only require the .link-stretch
class on a link. However, stretching a link over an entire .row
requires .position-static
on the column and .position-relative
on the row.
Columns with stretched link
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
Go somewhereUsing with Multiple Links
Multiple links and tap targets are not recommended with stretched links. However, some position
and z-index
styles can help should this be required.
Card with stretched link
The 'Unstretched' link will also clickable, and will 'sit' above the stretched link due to its higher z-index
value.
Identifying the Containing Block
If the stretched link doesn’t seem to work, the containing block will probably be the cause. The following CSS properties will make an element the containing block:
- A
position
value other thanstatic
- A
transform
orperspective
value other thannone
- A
will-change
value oftransform
orperspective
- A
filter
value other thannone
or awill-change
value offilter
(only works on Firefox)
Card with stretched links
Some quick example text to build on the card title and make up the bulk of the card's content.
Stretched link will not work here, because position: relative
is added to the link
This stretched link will only be spread over the p
-tag, because a transform is applied to it.
SASS Reference
Variables
The available Customization options, or Sass variables, that can be customized for this grouping of utility classes.
Name | Type | Default | Description |
---|---|---|---|
$enable-utility-link-stretch |
boolean | true |
Enable the generation of the stretchable link utility class. |
$enable-utility-link-stretch |
string | after |
Pseudo element to use for stretched links. |
$enable-utility-link-stretch |
integer | 1 |
Z-index to use for stretched links. |
Mixins
No mixins available.