leptos/examples/tailwind_csr_trunk
2023-06-01 22:12:18 -04:00
..
end2end examples: added example using Tailwind, CSR (only) and Trunk (#666) 2023-03-17 12:45:49 -04:00
public examples: added example using Tailwind, CSR (only) and Trunk (#666) 2023-03-17 12:45:49 -04:00
src examples: added example using Tailwind, CSR (only) and Trunk (#666) 2023-03-17 12:45:49 -04:00
style chore: build CSS with trunk (#1016) 2023-05-08 08:36:07 -04:00
.gitignore ci(examples): verify examples (#1125) 2023-06-01 22:12:18 -04:00
Cargo.toml chore: Upgrade console_log to stable (#724) 2023-03-22 18:21:53 -04:00
index.html examples: added example using Tailwind, CSR (only) and Trunk (#666) 2023-03-17 12:45:49 -04:00
input.css examples: added example using Tailwind, CSR (only) and Trunk (#666) 2023-03-17 12:45:49 -04:00
LICENSE examples: added example using Tailwind, CSR (only) and Trunk (#666) 2023-03-17 12:45:49 -04:00
Makefile.toml ci(examples): verify examples (#1125) 2023-06-01 22:12:18 -04:00
README.md chore: build CSS with trunk (#1016) 2023-05-08 08:36:07 -04:00
tailwind.config.js examples: added example using Tailwind, CSR (only) and Trunk (#666) 2023-03-17 12:45:49 -04:00
Trunk.toml examples: fix trunk config to run tailwind at the right time (#1040) 2023-05-13 19:39:36 -04:00

Leptos Starter Template

This is a template demonstrating how to integrate TailwindCSS with the Leptos web framework and the trunk tool.

Install Tailwind and build the CSS:

Trunk.toml is configured to build the CSS automatically.

Install trunk to client side render this bundle.

cargo install trunk Then the site can be served with trunk serve --open

The browser will automatically open http://127.0.0.1:8080//

You can begin editing your app at src/app.rs.

Installing Tailwind

You can install Tailwind using npm:

npm install -D tailwindcss

If you'd rather not use npm, you can install the Tailwind binary here.

Setting up with VS Code and Additional Tools

If you're using VS Code, add the following to your settings.json

  "emmet.includeLanguages": {
    "rust": "html",
    "*.rs": "html"
  },
  "tailwindCSS.includeLanguages": {
      "rust": "html",
      "*.rs": "html"
  },
  "files.associations": {
      "*.rs": "rust"
  },
  "editor.quickSuggestions": {
    "other": "on",
    "comments": "on",
    "strings": true
  },
  "css.validate": false,

Install Tailwind CSS Intellisense.

Install "VS Browser" extension, a browser at the right window.
Allow vscode Ports forward: 3000, 3001.

Notes about Tooling

By default, cargo-leptos uses nightly Rust, cargo-generate, and sass. If you run into any trouble, you may need to install one or more of these tools.

  1. rustup toolchain install nightly --allow-downgrade - make sure you have Rust nightly
  2. rustup default nightly - setup nightly as default, or you can use rust-toolchain file later on
  3. rustup target add wasm32-unknown-unknown - add the ability to compile Rust to WebAssembly
  4. cargo install cargo-generate - install cargo-generate binary (should be installed automatically in future)
  5. npm install -g sass - install dart-sass (should be optional in future

Attribution

This is based on the original Tailwind example (../examples/tailwind)