FunctionsCanopy

cms_button

The cms_button function is used to define a button component which can be edited on the Canopy editor.

{{ cms_button(name, { text: '...', url: '...', class: '...', opens_new_tab: ... }) }}
ArgumentDescriptionData Type
nameThe element identifierString
text (optional)The text content to be displayed within the buttonString
url (optional)The button URLString
class (optional)A space-separated list of CSS classes to style the heading componentString
opens_new_tab (optional)Set to true to open the linked URL in a new tabBoolean
The opens_new_tab only works if you are using a url.

The class variable is only accessible in the code. All other variables are available in the Canopy editor.

Button component template

<a href="{{ url }}" class={{ class }} rel="noopener" {% if opens_new_tab %} target="_blank" {% endif %}>
  {{ text }}
</a>

Rendered HTML output

<a href="https://blutui.ai/" class="bg-pink-500" rel="noopener" target="_blank"> Blutui AI </a>

Example

index.html
{{ cms_button('mybutton', { text: 'Blutui AI Components', url: 'https://blutui.ai/', class: 'bg-blue-500 text-white rounded hover:bg-blue-700', opens_new_tab: true }) }}

Last updated on