Skip to main content
Interactive components for creating clickable elements in your emails.

Button

A call-to-action button with automatic MSO (Microsoft Outlook) support for consistent rendering across email clients.

Props

href
string
default:"#"
The URL the button links to
target
string
default:"_blank"
Link target attribute
pX
number
default:"0"
Horizontal padding in pixels (left and right)
pY
number
default:"0"
Vertical padding in pixels (top and bottom)
style
string
Inline CSS styles
class
string
Tailwind CSS classes or custom CSS classes
children
snippet
required
Button text content
All standard HTML anchor attributes are supported via HTMLAnchorAttributes.

Features

  • MSO Support: Automatically includes conditional comments for Outlook compatibility
  • Padding Props: Use pX and pY for precise padding that works in Outlook
  • Display: Renders as inline-block for proper sizing
  • Text Decoration: None by default for clean appearance

Usage

<Button 
  href="https://example.com/action"
  class="rounded bg-blue-600 px-6 py-3 text-white"
>
  Click Me
</Button>
<Button 
  href="https://example.com"
  class="bg-blue-600 text-white"
  pX={20}
  pY={12}
>
  Get Started
</Button>

A styled hyperlink for inline text links and secondary actions.

Props

href
string
required
The URL to link to
target
string
default:"_blank"
Link target attribute
style
string
Inline CSS styles (merged with defaults)
class
string
Tailwind CSS classes or custom CSS classes
children
snippet
required
Link text content
All standard HTML anchor attributes are supported via HTMLAnchorAttributes.

Default Styles

  • text-decoration-line: none - No underline by default
  • color: #067df7 - Blue link color

Usage

<Link href="https://example.com" class="text-blue-600">
  Click here
</Link>
When to use each component:
  • Primary calls-to-action
  • Important actions (Sign Up, Buy Now, Confirm)
  • Standalone clickable elements
  • Actions that need visual prominence
<Section class="text-center">
  <Button 
    href="https://example.com/checkout"
    class="rounded bg-green-600 px-8 py-4 text-white"
  >
    Complete Purchase
  </Button>
</Section>

Complete Example

<script lang="ts">
  import {
    Html,
    Head,
    Body,
    Container,
    Section,
    Heading,
    Text,
    Button,
    Link,
    Hr
  } from 'better-svelte-email';
</script>

<Html>
  <Head />
  <Body class="bg-gray-50 font-sans">
    <Container class="mx-auto my-10 rounded bg-white p-8 shadow-lg">
      <!-- Header -->
      <Section class="mb-8">
        <Heading as="h1" class="text-center text-3xl font-bold text-gray-900">
          Welcome to Our Service!
        </Heading>
      </Section>

      <!-- Main content -->
      <Section class="mb-8">
        <Text class="text-gray-700">
          We're excited to have you on board. Click the button below to
          get started with your account setup.
        </Text>
      </Section>

      <!-- Primary CTA -->
      <Section class="mb-8 text-center">
        <Button 
          href="https://example.com/setup"
          class="rounded bg-blue-600 px-8 py-4 text-lg font-semibold text-white"
        >
          Complete Setup
        </Button>
      </Section>

      <!-- Alternative action -->
      <Section class="mb-6">
        <Text class="text-center text-sm text-gray-600">
          or <Link href="https://example.com/learn-more">learn more about our features</Link>
        </Text>
      </Section>

      <Hr class="my-6" />

      <!-- Footer links -->
      <Section>
        <Text class="text-center text-xs text-gray-500">
          <Link href="https://example.com/help" class="text-gray-600">
            Help Center
          </Link>
          {' • '}
          <Link href="https://example.com/privacy" class="text-gray-600">
            Privacy Policy
          </Link>
          {' • '}
          <Link href="mailto:[email protected]" class="text-gray-600">
            Contact Support
          </Link>
        </Text>
      </Section>
    </Container>
  </Body>
</Html>

Best Practices

Use the pX and pY props on Button for precise padding control that works reliably in Outlook.
Always provide an href attribute for buttons and links. Using # as a placeholder is acceptable for testing.
The Button component automatically includes MSO conditional comments for Outlook compatibility. No additional configuration needed.
For the best user experience, make button text clear and action-oriented (“Get Started”, “Download Now”, “Confirm Order”).
Avoid using target="_self" on buttons/links in emails, as it can cause navigation issues in webmail clients. Stick with the default _blank.
When using Link inside Text components, the link will inherit the text color unless you override it with a class.

Build docs developers (and LLMs) love