Skip to content
This repository was archived by the owner on May 17, 2026. It is now read-only.

gavink97/tailwind-inline

Repository files navigation

Archiving Project for now

Archiving this project to focus on other things. Should work with Tailwindcss v3 unsure about v4.

Mission

Tailwind Inline aims to create a cohesive development experience, whether you’re using templates to build a web application or an HTML email.

Why

Because most email clients block external and internal CSS, it’s essential to use inline style CSS when developing HTML email templates.

Getting Started

Installation

go get github.com/gavink97/tailwind-inline

Using Tailwind Inline with Templ

import(
    "os"
    "log"
    "context"

    "github.com/a-h/templ"
    twi "github.com/gavink97/tailwind-inline"
)

path := "./public/styles.css"
styles, err := os.ReadFile(path)
if err != nil {
    log.Fatal(err)
}

ctx := context.Background()
component := yourTemplComponent
s, err := templ.ToGoHTML(ctx, component)
if err != nil {
    log.Fatal(err)
}

c := twi.Convert(string(s), styles)

Using Tailwind Inline with html/template

import(
    "os"
    "io"
    "log"
    "bytes"
    "html/template"

    twi "github.com/gavink97/tailwind-inline"
)

path := "./public/styles.css"
styles, err := os.ReadFile(path)
if err != nil {
    log.Fatal(err)
}

var b bytes.Buffer
tpl := yourTemplate
t, err := template.New("Email").Parse(tpl)
if err != nil {
    log.Fatal()
}

data := struct {
          Title string
      }{
Title: "My email",
      }

buff := io.Writer(&b)
err = t.Execute(buff, data)

c := twi.Convert(b.String(), styles)

Contributing

I’m open to contributions

Star

If you’ve found this useful please give it a star ⭐️ as it helps other developers find my repos.

Star History Chart

About

Generate inline style attributes with Tailwind CSS

Topics

Resources

License

Stars

Watchers

Forks

Contributors