Buttons
It's possible to add custom coded buttons to Shopstory. Custom buttons are a special kind of custom components. The differences from standard components are:
You can connect actions to the buttons.
Buttons can be used as links.
Only buttons can be added to button groups.
How to make my custom Button compatible with Shoptory?
Custom Button is compatible with Shopstory when it satisfies following conditions.
It understands as
property
as
propertyThe custom buttons will be compatible with Shopstory only when they properly interpret as
property. There are 3 possible values for as
:
as="button"
- you must display your button as a semantic<button>
.as="a"
- you must display your button as<a>
(so it's not a button in a semantic meaning, only visual)as=undefined
- no action connected to button. You should leave it as<button>
or<div>.
Pass onClick, href, target, etc.
All standard a
or button
properties like onClick
, href
, target
, etc must be passed to the underlying DOM button
or a
elements.
Understands label
property
Custom buttons have a built-in label
property.
Example
Below you can see a properly defined custom coded Shopstory button:
We register buttons in the config using buttons
property:
As with components, we must pass the component instance to ShopstoryProvider
:
Let's see our button in action:
Last updated