Reference

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

name

The provider’s name, such as Instagram, used as the button’s label.

handle

The provider’s handle, such as instagram.

primaryColor

The provider’s brand colour as a hex value, or null when it has none.

icon

The provider’s icon as SVG markup, or null when it has none.

url

The link passed in the url render option, or null when none was passed.

Methods

getRenderOptions()

Returns the render options passed in when the button was created.

getProvider()

Returns the Provider the button is for.

getButtonAttributes()

Returns the HTML attributes for the button’s link, including href, aria-label, target and rel.

render()

Returns the HTML for the button, using its render options and the plugin’s attribute settings.

Last updated: Nov 13, 2026, 3:12:20 PM