PaulBickford
I am having trouble with my Phoenix/LiveView/Tailwind app not displaying correctly. The proper Tailwind classes are being created, but not all of them are being turned into CSS classes. I created a demo app below to illustrate the problem.
The Tailwind labels
absolute
top-0 (8, 16, 24, 32, 40)
left-0 (8, 16, 24, 32, 40)
bg-red-500 (yellow)
h-8
w-8
pt-px
pl-px
are all being created in the HTML, but the CSS classes do not include
top-x
left-x
Any idea on why the correct CSS is not being generated for all Tailwind classes?
TWTest demo app
Erlang 24.3.1 and Elixir 1.13.3-otp-24.
$ mix phx.new tw_test --no-ecto --no-mailer
mix.exs, deps:
{:tailwind, "~> 0.1", runtime: Mix.env() == :dev}
config.exs, add:
config :tailwind,
version: "3.0.10",
default: [
args: ~w(
--config=tailwind.config.js
--input=css/app.css
--output=../priv/static/assets/app.css
),
cd: Path.expand("../assets", __DIR__)
]
$ mix deps.get
$ mix tailwind.install
$ mix tailwind default
dev.exs, watchers:
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}
mix.exs, aliases add:
"assets.deploy": ["tailwind default --minify", ...]
router.ex, change route to:
live "/", Demo
Add demo.ex:
defmodule TwTestWeb.Demo do
use TwTestWeb, :live_view
def render(assigns) do
~H"""
<h1>Tailwind Test</h1>
<div class={"relative w-screen h-80 bg-teal-50"}>
<%= for i <- 0..4 do %>
<.box
style="bg-red-500"
x={assigns.nodes[i].x}
y={assigns.nodes[i].y}
/>
<.box
style="bg-yellow-500"
x={assigns.nodes[i].y}
y={assigns.nodes[i].x}
/>
<% end %>
</div>
"""
end
def mount(_params, _session, socket) do
nodes =
Map.new(0..4, &{&1, %{x: 4 - &1, y: &1}})
|> IO.inspect()
{:ok, assign(socket, nodes: nodes)}
end
def box(assigns) do
~H"""
<div
class={
"absolute top-#{8 * assigns.y} left-#{8 * assigns.x} #{assigns.style} h-8 w-8 pt-px pl-px"
}
>
</div>
"""
end
end
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
stefanchrobot
This is because you’re computing the classes dynamically - Tailwind purges the
top-8,top-16etc. classes since it doesn’t “see” them being used.One way to fix this would be to list them explicitly in a comment:
karlosmid
Hi!
Or you could put all possible computed CSS classes in
tailwind.config.jsexcludelist.