Styling with TailwindCSS

Styling form errors in the signup page

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $15

Modified files

static/input.css
--- 
+++ 
@@ -28,4 +28,8 @@

 .EasyMDEContainer:has(textarea:focus), textarea:focus {
   @apply ring-1 ring-emerald-500 border-emerald-500;
+}
+
+.error {
+  @apply p-2 my-2 text-sm text-red-700 bg-red-50 rounded-md border-red-300 border;
 }
templates/account/login.html
--- 
+++ 
@@ -15,7 +15,7 @@
       {% if form.errors %}
         {% for field, errors in form.errors.items %}
           {% for error in errors %}
-            <div class="p-2 my-2 text-sm text-red-700 bg-red-50 rounded-md border-red-300 border">
+            <div class="error">
             {{ error }} 
             </div>
           {% endfor %}
templates/account/signup.html
--- 
+++ 
@@ -31,6 +31,11 @@
               </div>
               <div class="space-y-2">
                 <label class="sr-only" for="{{ form.password1.id_for_label }}">Password</label>
+                {% if form.password1.errors %}
+                  <div class="error [&>ul]:space-y-2">
+                    {{ form.password1.errors }}
+                  </div>
+                {% endif %}
                 <div class="form-field">
                   {% render_field form.password1 class="block text-black shadow-sm focus:ring-emerald-500 focus:border-emerald-500 border-gray-300 text-sm" %}
                 </div>