Button
A button shows a provider’s icon and name, and links wherever you choose, such as your own profile on that platform. Whenever you’re dealing with a button in your template, you’re working with a Button object. Get one with craft.socialShare.getButton(), or render it straight away with craft.socialShare.renderButton(). For a button that shares the current page, use a Share Button instead.
{% set button = craft.socialShare.getButton('instagram', { url: 'https://www.instagram.com/example' }) %}
<a href="{{ button.url }}" style="color: {{ button.primaryColor }}">
{{ button.icon | raw }} {{ button.name }}
</a>
Properties
The provider’s name, such as Instagram, used as the button’s label.
The provider’s handle, such as instagram.
The provider’s brand colour as a hex value, or null when it has none.
The markup passed in the icon render option, or the provider’s icon as SVG markup when none was passed. Returns null when the provider has no icon and no icon option was passed.
The link passed in the url render option, or null when none was passed.
Methods
Returns the render options passed in when the button was created.
Returns the Provider the button is for.
Returns the HTML attributes for the button’s link, including href, aria-label, target and rel.
Returns the HTML for the button, using its render options and the plugin’s attribute settings.