tadasajon

tadasajon

So I spent a good bit of time getting Tailwind working and then learning how to do every little thing with Tailwind – I did this because everyone using Phoenix seems to think it is fantastic. I liked Tailwind when I was reading about it from a theoretical perspective, but in terms of actually using it… well, it seems like I just want something faster and easier and less verbose. I can barely tell the value of Tailwind over just using inline styles.

Then I discovered that Milligram is automatically included when you make a new Phoenix app – right there in assets/css/phoenix.css. From what I can tell so far it is just a super-lightweight version of Bootstrap, which is basically exactly what I need to get going fast.

I’m astonished that people aren’t talking about how it is even faster to just get going with Milligram, which is included by default. The docs don’t seem to mention it – or at least I haven’t come across it anywhere. It would have been super-nice if I’d been tipped off re: Milligram a month ago, when I started my project.

More info at Milligram.io for those who are interested – you don’t even have to install it to get started with it – just don’t delete it!

Showing Posts 1 to 10

Sebb

Sebb

Sure, milligram is enough for a lot of use cases. If you need a little more you can also use (CSS-only) bootstrap very easily with phoenix 1.6 per CDN (so you can stay completely node/npm/webpack-free).

You can’t do that with tailwind because it has to be processed. But tailwind imo is only needed if you want more advanced or very customized styling - but for that its great.

fuelen

fuelen

try to set :hover using inline styles.

tadasajon

tadasajon OP

You can just toss a <style> tag anywhere you want in a Phoenix template and add hover styles to your heart’s content. What’s the big deal?

<div> a bunch of previously existing template content here... </div>

<style>
#my-div { background-color: lightblue; }
#my-div:hover { background-color: yellow; }
</style>
<div id="my-div"> hello world.  </div>
Adzz

Adzz

Milligram and Tailwind are really two different technologies with completely different aims.

Milligram is a lightweight CSS library - attempting to give you some styles for free.

Tailwind is attempting to bring a new spin on how to write maintainable front ends.

It sounds like you may not have needed the power of Tailwind so it stands to reason Milligram might be a better fit. But it is worth reading about the value of tailwind

As to why you never heard of Milligram only you can answer that :slight_smile: it’s right there when you start a phoenix app!

stefanchrobot

stefanchrobot

For me, the main benefit of Tailwind is TailwindUI which allows me to stitch a pretty good looking UI quickly. Plus tons of useful utilities like space-x-n, style purging, etc.

AndyL

AndyL

See also DaisyUI

tadasajon

tadasajon OP

DaisyUI looks really interesting. It seems that the missing link for me was not understanding that Tailwind is not meant to be used directly, but is rather meant to be used by specialized people who build CSS UI frameworks like Bootstrap and Daisy UI etc and then actual app developers just use those.

Also, @Adzz I had read that article re: Tailwind by Adam Wathan about the separation of concerns and it made a ton of sense to me at the time, which is why I decided to go ahead with Tailwind. But in practice using Tailwind directly seems far less practical. It’s like a theoretically beautiful solution that just makes CSS an even bigger headache in practice. You’re just writing the same miserable CSS, but this time in a foreign language and with twice as many terms to memorize.

I’m wondering now whether it might not make the most sense for me to just ditch compiling and loading CSS in the head of the html via an app.css file and instead just include <style> elements at the top of each Phoenix template that styles whatever is in the template. At least that way everything is super-straightforward and I can style the HTML in the same file that I write the HTML. No reason to get too clever here.

cmo

cmo

Tailwind is not meant to be used directly, but is rather meant to be used by specialized people who build CSS UI frameworks like Bootstrap and Daisy UI etc and then actual app developers just use those.

I’m not entirely sure that is true for a lot of us.

I don’t know CSS so I learnt tailwind instead. There’s nothing stopping you creating classes yourself with @apply.

baldwindavid

baldwindavid

Certainly it is great as a design framework builder because it gets you closer to the metal than something like Bootstrap and Bulma, but I found it to be useful long before TailwindUI came along. I experienced a great deal of pain with CSS over the years for which the concept of atomic styles helped to combat. Tailwind then provided an exhaustive and consistent atomic style API, great documentation, and even support for using it to build custom design frameworks.

That being said, if Milligram is enough, you should totally use that. I wouldn’t personally place CSS in <style> tags for reasons of maintainability and page size but, sure, you could do that. I suspect you’ll still find the need for at least some defaults (like normalize) that you won’t love pasted into every page.

brightball

brightball

I’m a terrible UI designer but Tailwind was a breeze for me fwiw. Honestly the biggest analysis paralysis issue that I always faced on personal projects was figuring out which CSS framework to invest my time learning.

Thanks to Tailwind, I never have to do that again and it’s a great feeling.

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 91898 914
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews