Usage
The Button component is defined incomponents/button.html.
This enables the <x-button> tag, which you can use like this:
emails/example.html
<div>.
Customization
You can align the Button to the left, center or right, change its CSS styling, and adjust padding for Outlook on Windows.Href
Default:undefined
If you want the Button to link somewhere, you need to pass it the href prop:
emails/example.html
Align
Default:undefined
You can align the Button to the left, center or right, through the align prop:
emails/example.html
text-center class to the button’s wrapper <div>, which will align the <a> inside it to the center.
Styling
You may style the Button as needed through props or with Tailwind CSS utilities. The button includes abg-indigo-700 background and text-slate-50 text color by default, which you can change through props.
For example, let’s make the button blue-themed:
emails/example.html
emails/example.html
components/button.html.
MSO padding
Top and bottom padding for Outlook on Windows is controlled throughletter-spacing and mso-text-raise, a proprietary Outlook CSS property.
This technique is based on the Link Button from goodemailcode.com.
MSO top padding
Default:16px
Adjust the top padding for Outlook on Windows with the mso-pt prop:
emails/example.html
MSO bottom padding
Default:31px
Adjust the bottom padding for Outlook on Windows with the mso-pb prop:
emails/example.html
Other attributes
You may pass any other HTML attributes to the component, such asdata-* or id - they will all be added to the <a> tag.
Note that non-standard attributes will be ignored by default - you’ll need to define them as props in the component if you need them preserved. Alternatively, you can safelist them in your build.components config.
Responsive
To override Button styling on small viewports, use Tailwind CSS utilities. For example, let’s make the button full-width on small viewports:emails/example.html
Alternatives
There are other ways to create buttons in your HTML emails, such as by using a<table>. Check out our Button examples for more ideas.