You are viewing documentation generated from a user contribution or an upcoming or past release. The contents of this document may not have been reviewed by the Deno team. Click here to view the documentation for the latest release.


Using Twind with Deno

Twind is a tailwind-in-js solution for using Tailwind. Twind is particularly useful in Deno's server context, where Tailwind and CSS can be easily server side rendered, generating dynamic, performant and efficient CSS while having the usability of styling with Tailwind.

Basic example

In the following example, we will use twind to server side render an HTML page and log it to the console. It demonstrates using the tw function to specify grouped tailwind classes and have it rendered using only the styles specified in the document and no client side JavaScript to accomplish the tailwind-in-js:

import { setup, tw } from "https://esm.sh/twind@0.16.16";
import { getStyleTag, virtualSheet } from "https://esm.sh/twind@0.16.16/sheets";

const sheet = virtualSheet();

  theme: {
    fontFamily: {
      sans: ["Helvetica", "sans-serif"],
      serif: ["Times", "serif"],

function renderBody() {
  return `
    <h1 class="${tw`text(3xl blue-500)`}">Hello from Deno</h1>
      <input name="user">
      <button class="${tw`text(2xl red-500)`}">

function ssr() {
  const body = renderBody();
  const styleTag = getStyleTag(sheet);

  return `<!DOCTYPE html>
    <html lang="en">
        <title>Hello from Deno</title>