hectorperez

hectorperez

Hi!

This does NOT work in my phoenix app:

@tailwind base;
@tailwind components;
@tailwind utilities;

@import "./markdown.css";
@import "./code.css";

Yet, this does:

@import "./markdown.css";
@import "./code.css";

@tailwind base;
@tailwind components;
@tailwind utilities;

If it helps, you can see my PR with the changes — including the content of markdown.css and code.css.

Tailwind’s commands should be at the top so they don’t override my custom CSS, right?

Any idea why it doesn’t work? Thanks!

Showing Posts 1 to 8

aiwaiwa

aiwaiwa

Check out Tailwind’s @layer directive.

hectorperez

hectorperez OP

Thanks @aiwaiwa.

Can I use @import within a @layer directive?

The following does NOT work:
app.css

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  @import "./markdown.css";
}

@layer utilities {
  @import "./code.css";
}

The following does NOT work either:
app.css:

@tailwind base;
@tailwind components;
@tailwind utilities;

@import "./markdown.css";
@import "./code.css";

markdown.css:

@layer base {
  .markdown h1 {
    @apply pb-2 text-4xl;
  }
  ...
}

code.css:

@layer utilities {
  .highlight .hll {
    background-color: #49483e
  }
  ...

Yet, this did work:
app.css:

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  .markdown h1 {
    @apply pb-2 text-4xl;
  }
...
}

@layer utilities {
  .highlight .hll {
    background-color: #49483e
  }
...
}

So can’t I use @import inside @layer?
Or am I doing something wrong?
Thanks!

aiwaiwa

aiwaiwa

I feel I led you to a wrong direction, @import inside @layer is a PostCSS instruction apparently. Relatively simple instruction and not working! Duh :smiley:
So apparently it should work in-between tailwind imports, and yet you are saying it doesn’t.

I’ve tested it on a simple file, and other.css seems to be imported at the right place - after components and before utilities. Certainly, no tree shaking happening.

@import "tailwindcss/base";
@import "tailwindcss/components";
@import "other.css";
@import "tailwindcss/utilities";
hectorperez

hectorperez OP

Wait, @import tailwind does works:

@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

@import "./markdown.css";
@import "./code.css";

Yet, @tailwind doesn’t:

@tailwind base;
@tailwind components;
@tailwind utilities;

@import "./markdown.css";
@import "./code.css";

I’ll @import tailwind. Thanks!

LostKobrakai

LostKobrakai

@import is a css/postcss feature and those imports can only be added at the top of any css file. Using @tailwind essentially means the following @imports are no longer at the top of the file.

hectorperez

hectorperez OP

I get it now, thank you for explaining it!

aiwaiwa

aiwaiwa

It looks like a great project indeed!

hectorperez

hectorperez OP

Glad that you like Notesclub!

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
saleyn
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New
rlipscombe
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used? I’ve got two Github accoun...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews