so I was trying out tailwindcss with leptos framework, what I noticed is when classes are included in static class attribute, the tailwindcss config recognize and build up those in output.css. however if I was to include class name using Dynamic Classes in leptos framework, those classes are not being auto included in output.css. Eg. 'rounded-lg' style won't be included in output.css
use leptos::*;
use leptos_meta::*;
#[component]
fn App(cx: Scope) -> impl IntoView {
let (count, set_count) = create_signal(cx, 0);
provide_meta_context(cx);
view! { cx,
<Stylesheet id="leptos" href="/pkg/tailwind.css"/>
<button
class="p-1 px-2.5 bg-sky-500 hover:bg-sky-700 focus:outline-none focus:ring focus:ring-sky-300 hover:text-white"
class:rounded-lg=move || count() % 2 == 1
on:click=move |_| {
set_count.update(|n| *n += 1);
}
>
"Click me: " {move || count()}
</button>
}
}
fn main() {
leptos::mount_to_body(|cx| view!{ cx, <App/> })
}
I had to manually add those styles to output.css, wondering if there is better way to auto extract that rather than adding it manually all the time.
You could try using the Safelisting classes
tailwind.config.jsoption.Check out this example I created here with that config setting. https://play.tailwindcss.com/Bpz8xH6Edk?file=config
Even though there is no
HTMLbeing output, therounded-lgclass still gets included into the compiledCSS.There is another option which is shown under Working with third party libraries.