Social sharing links can be added to the Article page using the Social sharing setting in the Article page elements theme setting group. The links are provided by the Zendesk {{share}}
helper, but changes are possible using HTML and CSS.
Using the Social sharing title theme setting you can add a heading to the social sharing links that can be tranlated into multiple languages:
Button groups
Dropdowns
Fixed position
Social links can be presented in a fixed position on the screen (for example, in the bottom-right hand side).
The links can be revealed on scroll using the following JavaScript code. Use the .hidden
display utility on the social links container to hide it from view:
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
var socialLinks = document.getElementById('social-links');
if (!socialLinks) return;
/**
* Reveals the Back to Top link when the page is scrolled by more than 100px.
*/
var onScroll = function() {
socialLinks.classList.toggle('hidden', window.pageYOffset < 100);
};
// Add event listeners
window.addEventListener('scroll', onScroll);
});
</script>
You could also hide it on small screen sizes and reveal it on medium-sized screens using the class names .hidden .md:block
:
<div class="social-share-links ... hidden md:block">
...
</div>
The HTML for social links is provided by the Zendesk {{share}}
helper and cannot be modified directly. That said, our themes allow you to replace the output of the helper with custom HTML defined in a micro-template.
To create your own HTML using a micro-template simply wrap the {{breadcrumbs}}
helper in an element with a data-element="breadcrumbs"
attribute and a reference to your micro-template:
And then add your custom micro-template to the page or footer theme template.
The micro-template, which can be created manually or sourced from our collection of patterns, receives an array of links, with each object having a title (title
) and URL (html_url
).
Whether you use the standard {{share}}
helper or a custom micro-template, you can use social links patterns by copying and pasting the code into the position you’d like them to appear on the Article page, which is the only page template that supports the {{share}}
helper.
Customizing social link output
Despite the breadcrumb HTML being generated by Zendesk, it is possible to customize the appearance of the element in several ways:
-
Update one or more of the Sass variables described below and recompiling the theme stylesheet.
-
Add your own custom CSS in the theme’s
style.css
file targeting the.share
element. -
Use HTML elements and utilities to wrap the
.share
element, as some of our patterns do.
The following Sass variables are available in the framework:
Variable | Description |
---|---|
$color-facebook | The color used for the Facebook link. |
$color-twitter | The color used for the Twitter link. |
$color-linkedin | The color used for the LinkedIn link. |