AshScenario.Tailwind.Assets (ash_scenario v0.6.0)
View SourceAsset management for optional Tailwind CSS integration. Only available when Tailwind dependency is present.
Summary
Functions
Checks if Tailwind CSS is available and compiled.
Builds the CSS if in development mode.
Returns CSS classes with fallback when Tailwind is not available.
Checks if Tailwind CSS has been compiled.
Returns the compiled CSS content if available.
Returns a hash of the CSS content for cache busting. Returns nil if CSS is not compiled.
Returns the path to the compiled CSS file in the application's priv directory.
Injects the AshScenario Tailwind CSS into the current page if available.
Returns a link tag pointing to the compiled CSS file. Useful when serving the CSS as a static asset. Includes cache busting via version parameter.
Returns a Phoenix.HTML style tag with the compiled CSS. Useful for injecting CSS into LiveView components.
Functions
Checks if Tailwind CSS is available and compiled.
Returns true if CSS has been compiled and embedded, false otherwise.
In development, logs a warning if CSS is not compiled.
Builds the CSS if in development mode.
Returns CSS classes with fallback when Tailwind is not available.
Examples
# Returns Tailwind classes when available, fallback otherwise
AshScenario.Tailwind.Assets.classes(
"bg-blue-500 text-white px-4 py-2 rounded",
fallback: "default-button-class"
)
Checks if Tailwind CSS has been compiled.
Returns the compiled CSS content if available.
Returns {:ok, content} if CSS is compiled and embedded, or
{:error, :not_compiled} with helpful instructions otherwise.
Returns a hash of the CSS content for cache busting. Returns nil if CSS is not compiled.
Returns the path to the compiled CSS file in the application's priv directory.
Injects the AshScenario Tailwind CSS into the current page if available.
Use this in your LiveView or component when you want to include the styles:
<%= AshScenario.Tailwind.Assets.inject() %>Or with a custom path:
<%= AshScenario.Tailwind.Assets.inject(path: "/assets/ash_scenario.css") %>
Returns a link tag pointing to the compiled CSS file. Useful when serving the CSS as a static asset. Includes cache busting via version parameter.
Returns a Phoenix.HTML style tag with the compiled CSS. Useful for injecting CSS into LiveView components.