calebjosue

calebjosue

How do you render HTML elements as they are meant to be rendered in Phoenix Framework?

Hello everybody!

So, I’ve created a simple app by means of mix phx.new emptyapp --no-ecto. Changed directory into emptyapp and modified the router at lib/emptyapp_web/router.ex by adding the following route.
live "/sayhi", SayHello in the root scope.

After I that, I created the say_hello.ex file in the following route lib/emptyapp_web/live/ with the following content:

defmodule EmptyappWeb.SayHello do

    use Phoenix.LiveView
end

I’ve proceeded with the following file lib/emptyapp_web/live/say_hello.html.heex with the following content (plain html):

<h1>This is a header</h1>

<p>This is a Paragraph</p>

Run the server with mix phx.server and got the following result.

I was expecting to see an actual header in the traditional way, a little bit bigger than the paragraph. You know, as specified here.

So, how do you guys achieve this behavior in the Phoenix Framework?

Or is this approach unusual?

I also tried adding use MyemptyappWeb, :html with the same results.

Of course, in the end most HTML elements will end being styled by means of CSS, so basically my question is if these results are expected.

Thanks!

Marked As Solved

Eiji

Eiji

@calebjosue It’s “normal” for Tailwind which is used in phoenix generators. For more information see Preflight - Tailwind CSS documentation.

Also Liked

adw632

adw632

You might also find the tailwind prose class useful which is part of the tailwind typography plugin.

Just add the prose plugin to tailwind configuration and prose works out of the box. There is no need for npm installation as the plugin is included by default in Phoenix.

Last Post!

calebjosue

calebjosue

How amazing is that?
Thanks for sharing that link @adw632 !

Where Next?

Popular in Questions Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement