From 96da1c5cd04ae883b08ad05689b86a3a8a26a31e Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 21 Jul 2025 19:32:25 +0200 Subject: [PATCH] docs: add page for tailwindcss (#3120) --- docs/canary/plugins/tailwindcss.md | 54 ++++++++++++++++++++++++++++++ docs/toc.ts | 1 + 2 files changed, 55 insertions(+) create mode 100644 docs/canary/plugins/tailwindcss.md diff --git a/docs/canary/plugins/tailwindcss.md b/docs/canary/plugins/tailwindcss.md new file mode 100644 index 00000000..5ce186d5 --- /dev/null +++ b/docs/canary/plugins/tailwindcss.md @@ -0,0 +1,54 @@ +--- +description: "Use Tailwindcss to style your app" +--- + +[Tailwindcss](https://tailwindcss.com/) is a utility-first CSS framework that +generates CSS out of the class names that are used in JSX. Since we use +Tailwindcss ourselves here at Deno, Fresh ships with an official plugin for +that. + +## Usage + +1. Set `nodeModulesDir` in `deno.json` to `"auto"` or `"manual"` + +```diff deno.json + { + "name": "@example/my-cool-project" ++ "nodeModulesDir": "auto", + "imports": { + ... + } + } +``` + +2. Run `deno install jsr:@fresh/plugin-tailwind` +3. Update `dev.ts`: + +```diff dev.ts + import { Builder } from "fresh/dev"; + import { app } from "./main.ts"; ++ import { tailwind } from "@fresh/plugin-tailwind"; + + const builder = new Builder(); ++ tailwind(builder, app); +``` + +4. Add `@import "tailwindcss";` at the top of your main stylesheet. + +For more information on how to use tailwindcss, check out +[their documentation](https://tailwindcss.com/docs/styling-with-utility-classes). + +## Options + +You can customize the tailwind plugin via the following options: + +```ts +tailwind(builder, app, { + // Exclude certain files from processing + exclude: ["/admin/**", "*.temp.css"], + // Force optimization (defaults to production mode) + optimize: true, + // Exclude base styles + base: null, +}); +``` diff --git a/docs/toc.ts b/docs/toc.ts index a4cd65bf..5aa1a7d2 100644 --- a/docs/toc.ts +++ b/docs/toc.ts @@ -72,6 +72,7 @@ const toc: RawTableOfContents = { pages: [ ["cors", "cors", "link:canary"], ["trailing-slashes", "trailingSlashes", "link:canary"], + ["tailwindcss", "tailwindcss", "link:canary"], ], }, examples: {