{"id":55,"date":"2025-09-26T08:50:56","date_gmt":"2025-09-26T08:50:56","guid":{"rendered":"https:\/\/ska-blocks.com\/docs\/2025\/09\/26\/tailwind-block\/"},"modified":"2025-09-30T17:44:49","modified_gmt":"2025-09-30T17:44:49","slug":"tailwind-block","status":"publish","type":"post","link":"https:\/\/ska-blocks.com\/docs\/tailwind-block\/","title":{"rendered":"Tailwind block"},"content":{"rendered":"\n<p class=\"lead\">The Tailwind block in the ska-blocks plugin allows to enter HTML with Tailwind classes and compile it to include the Tailwind CSS on the front end as well.<\/p>\n\n\n\n<div class=\"flex flex-row gap-2.5 items-center px-4 py-3 mb-6 text-base\/none not-prose text-info-text bg-info-background rounded border border-info-border wp-block-ska-element\">\n<div aria-hidden=\"true\" class=\"shrink-0 w-6 h-auto text-current wp-block-ska-image image\"><svg   viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n\t<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4.84836 2.771C7.18302 2.42773 9.57113 2.25 12.0003 2.25C14.4292 2.25 16.8171 2.4277 19.1516 2.77091C21.1299 3.06177 22.5 4.79445 22.5 6.74056V12.7595C22.5 14.7056 21.1299 16.4382 19.1516 16.7291C18.0054 16.8976 16.8464 17.0262 15.6759 17.1135C15.5514 17.1228 15.4431 17.1875 15.379 17.2835L12.624 21.416C12.4849 21.6247 12.2508 21.75 12 21.75C11.7492 21.75 11.5151 21.6247 11.376 21.416L8.62092 17.2835C8.5569 17.1874 8.44853 17.1227 8.32408 17.1134C7.15358 17.0261 5.99452 16.8975 4.84836 16.729C2.87004 16.4381 1.5 14.7054 1.5 12.7593V6.74064C1.5 4.79455 2.87004 3.06188 4.84836 2.771ZM6.75 8.25C6.75 7.83579 7.08579 7.5 7.5 7.5H16.5C16.9142 7.5 17.25 7.83579 17.25 8.25C17.25 8.66421 16.9142 9 16.5 9H7.5C7.08579 9 6.75 8.66421 6.75 8.25ZM7.5 10.5C7.08579 10.5 6.75 10.8358 6.75 11.25C6.75 11.6642 7.08579 12 7.5 12H12C12.4142 12 12.75 11.6642 12.75 11.25C12.75 10.8358 12.4142 10.5 12 10.5H7.5Z\" fill=\"currentColor\"><\/path>\n<\/svg><\/div>\n\n\n\n<p class=\"m-0\">Tailwind block now supports AI: <a href=\"https:\/\/ska-blocks.com\/docs\/ska-blocks\/using-ai\/\" data-type=\"post\" data-id=\"1492\">read more<\/a>.<\/p>\n<\/div>\n\n\n\n<p>The block itself has multiple features and can serve many different purposes, such as rendering any custom HTML, converting Tailwind HTML to blocks, adding scripts or styles, server-side rendering shortcodes and compiling Tailwind CSS from their output. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"custom-html\">Custom HTML<\/h2>\n\n\n\n<p><strong>Insert any HTML<\/strong> a lot like the core WordPress <strong>HTML block<\/strong> but with the addition of basic syntax highlighting, indentation as well as a button to beautify your HTML:<\/p>\n\n\n\n<a aria-label=\"View image in full screen\" data-pswp-height=\"169\" data-pswp-width=\"1028\" data-ska-pswp=\"ska-pswp-1\" href=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-17.png\" class=\"wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-17.png\" alt=\"Tailwind HTML in a Tailwind block\" width=\"1028\" height=\"169\" loading=\"lazy\"\/><\/a>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"html-to-blocks\">Convert HTML to blocks<\/h2>\n\n\n\n<p>On the block toolbar, hit the <strong>Convert to blocks<\/strong> button to convert the inserted HTML into WordPress blocks:<\/p>\n\n\n\n<a aria-label=\"View image in full screen\" data-pswp-height=\"395\" data-pswp-width=\"1024\" data-ska-pswp=\"ska-pswp-2\" href=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-12-1024x395.png\" class=\"wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-12-1024x395.png\" alt=\"Result of converting Tailwind HTML to WordPress blocks\" width=\"1024\" height=\"395\" loading=\"lazy\"\/><\/a>\n\n\n\n<p>The blocks used are mostly <a href=\"https:\/\/ska-blocks.com\/docs\/element\/\" data-type=\"post\" data-id=\"203\">Element<\/a> and <a href=\"https:\/\/ska-blocks.com\/docs\/text\/\" data-type=\"post\" data-id=\"213\">Text<\/a> blocks, with core Paragraph, Heading and List blocks used when applicable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Additional features<\/h2>\n\n\n\n<p>Should you <em>not<\/em> convert HTML to blocks, you can also use this block as a better alternative for the WordPress core HTML block.<\/p>\n\n\n\n<ol class=\"wp-block-ska-element\">\n<li class=\"wp-block-ska-element\">\n<p><strong>CSS is compiled<\/strong> for the Tailwind classes that are included in the HTML. The CSS is then rendered on the front end along with your HTML. When the page has other blocks that are already using some of the same Tailwind classes the CSS is tree-shaken to include every Tailwind class only once.<\/p>\n<\/li>\n\n\n\n<li class=\"wp-block-ska-element\">\n<p><strong>Additional custom CSS<\/strong> can be added when navigating to the CSS tab in the block toolbar:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-8.png\" alt=\"Tailwind block CSS tab\" class=\"wp-image-219\"\/><\/figure>\n\n\n\n<p>Plain CSS can be used, as well as Tailwind <code>@apply<\/code> functionality and nested CSS syntax.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-9.png\" alt=\"Tailwind block CSS tab content\" class=\"wp-image-220\"\/><\/figure>\n<\/li>\n\n\n\n<li class=\"wp-block-ska-element\">\n<p><strong>Live preview<\/strong> of the HTML rendered along with the compiled CSS is available in the Preview tab:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-10.png\" alt=\"Tailwind block Preview tab\" class=\"wp-image-221\"\/><\/figure>\n<\/li>\n\n\n\n<li class=\"wp-block-ska-element\">\n<p><strong>Server side rendering<\/strong> &#8211; Should you include WordPress shortcodes in the HTML, enable the SSR option:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-11.png\" alt=\"Tailwind block Server side rendering option\" class=\"wp-image-222\"\/><\/figure>\n\n\n\n<p>This will render the shortcode server-side (which itself may use Tailwind classes) and compile CSS based on the server side rendered output, which means any Tailwind classes included in the shortcode output are also accounted for.<\/p>\n\n\n\n<p class=\"text-sm\"><strong>Note:<\/strong> if you change what the shortcode outputs, or the shortcode dynamically outputs different Tailwind classes under different circumstances, then the block will not know of any new classes until you edit the page and re-compile the CSS.<\/p>\n<\/li>\n\n\n\n<li class=\"wp-block-ska-element\">\n<p><strong>Render block inline<\/strong> &#8211; or don&#8217;t! Sometimes you need to add a bunch of raw HTML in a tight space. Disable the &#8220;Render block inline&#8221; option to only produce a small button in the block editor:<\/p>\n\n\n\n<div class=\"grid sm:grid-cols-2 place-items-center *:m-0 wp-block-ska-element\">\n<div role=\"figure\" class=\"wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-13.png\" alt=\"Tailwind block Render block inline option\" width=\"254\" height=\"97\" loading=\"lazy\"\/><\/div>\n\n\n\n<div role=\"figure\" class=\"wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-14.png\" alt=\"Tailwind block not rendered inline\" loading=\"lazy\"\/><\/div>\n<\/div>\n\n\n\n<p>When you click on the button, the whole block content opens up in a full screen modal so can make changes to the HTML.<\/p>\n\n\n\n<figure class=\"wp-block-ska-element\">\n<a aria-label=\"View image in full screen\" data-pswp-height=\"655\" data-pswp-width=\"1013\" data-ska-pswp=\"ska-pswp-3\" href=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-15.png\" class=\"[&amp;_img]:m-0! wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-15.png\" alt=\"Complicated language switcher in a modal\" width=\"1013\" height=\"655\" loading=\"lazy\"\/><\/a>\n\n\n\n<figcaption class=\"mt-2! text-xs! text-center wp-block-ska-text ska-text\">Complicated language switcher in a modal<\/figcaption>\n<\/figure>\n<\/li>\n\n\n\n<li class=\"wp-block-ska-element\">\n<p><strong>Beautify HTML\/CSS<\/strong> &#8211; The block also features buttons for quickly formatting the HTML or CSS code that has been inputted.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2024\/03\/image-16.png\" alt=\"\" class=\"wp-image-229\"\/><\/figure>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>The Tailwind block in the ska-blocks plugin allows to enter HTML with Tailwind classes and compile it to include the Tailwind CSS on the front end as well. The block itself has multiple features and can serve many different purposes, such as rendering any custom HTML, converting Tailwind HTML to blocks, adding scripts or styles,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[4],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-ska-blocks","tag-blocks"],"_links":{"self":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/55","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":4,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":416,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/55\/revisions\/416"}],"wp:attachment":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}