I recently had to implement a newsletter subscription for a client using Infomaniak. It’s a decent service, especially for Switzerland, but the default embedding isn’t great visually.
TLDR: You can skip to the end to see the result and the code.
I had a few goals in mind to improve the user experience:
While I was developing, I found a few (undocumented) quirks with the javascript embed method:
document.write
.The alternatives seemed worse:
I’m using Tailwind v4
and TypeScript
, but the general approach is the same.
Afficher le message dans le formulaire
option.@layer components {
/* Infomaniak Newsletter styling – Some styles left out for brevity */
.inf-form {
.inf-content {
@apply grid grid-cols-4 gap-1;
& > .inf-input-text {
@apply order-1 col-span-3;
& > input {
@apply w-full;
}
}
& > .inf-submit {
@apply order-2 col-span-1;
& > input {
@apply !m-0 text-center cursor-pointer w-full;
}
}
/* Captcha Container does not have class */
div:not([class]) {
@apply order-3 col-span-4;
#mcaptcha__widget-container {
@apply border-black border;
}
}
}
}
}
const captchaContainer = document.querySelector(
"#mcaptcha__widget-container",
) as HTMLElement;
const emailInput = document.querySelector(
"div.inf-content > div.inf-input.inf-input-text > input[type=email]",
) as HTMLElement;
if (captchaContainer && emailInput) {
captchaContainer.style.display = "none";
emailInput.addEventListener("input", () => {
captchaContainer.style.display = "block";
});
}
This approach isn’t perfect, but it works. I might explore a more customized version later. Still, this should help anyone looking to style Infomaniak’s default newsletter embed without too much hassle.