Enhance the usability and design of the post new form in Rails by improving layout, readability, and error message styling. Learn how to adjust form widths, reposition navigation links, and refine the UI for a cleaner, more user-friendly experience. These improvements set the stage for further UI refinements and prepare the app for deployment.
Now that we've polished our models and controllers, it's time to shift our focus to the UI layer.
There's a lot we can do to enhance usability and aesthetics, and you can follow all changes in the linked repository. In this video, I want to focus specifically on improving the post new form—making it more user-friendly and visually appealing.
I'll walk through my thought process on UI improvements, and then we'll apply iterative changes to achieve a cleaner, more intuitive design.
Assessing the Current Form UI
Jumping into our form view, let's examine how it currently looks in the browser.
A few immediate issues stand out:
- The title input is full-width, while the body text area is not—which feels inconsistent.
- The body text area is too small—we need to indicate that we expect a larger block of text.
- The "Back to Posts" link is awkwardly placed at the bottom—we should reposition it for better navigation.
- The full-width input fields aren't ideal for usability—I’d prefer half-width for the title and full-width for the body for a better experience.
Let's start moving things around to see how the page improves.
Improving Navigation & Layout
Repositioned "Back to Posts" Link:
- Moved it next to the page title (
<h1>
), making navigation more intuitive.
- Styled it as an hlink button—a ghost button positioned on the right-hand side for better UI balance.
Added an Arrow Icon for Better UX:
- Used an HTML entity (←) for a left arrow to make the navigation clearer.
- Ensured the link is marked as "HTML safe" for proper rendering.
Refactored Form Layout:
- Set the title input to two-thirds width (w-2/3) while keeping the body text area full width.
- Increased the body text area height (rows=10) to better accommodate long-form content.
Enhancing Form Styling
- Removed inline styles on labels—instead, defined them in the CSS file for better maintainability.
- Ensured labels are block elements (display: block)—this fixes alignment issues in the form.
- Applied placeholder values where appropriate, though in this case, the form layout already looks clear.
Reducing Code Duplication
We refactored form title handling:
- The title text was duplicated in multiple places, which made maintenance harder.
- Instead, reused the same variable to ensure consistency across the page title and form heading.
Redesigning Error Messages for Better Readability
We also want to improve form validation messages. The default Rails scaffolded styles aren't the best, so let’s refine them.
Removed inline styles from error messages and instead:
- Used ARIA role="alert" for better accessibility.
- Applied consistent Tailwind styling for clarity and emphasis.
Updated styling in the Tailwind file:
- Added red text and bold headers for better visibility.
- Applied list styles (square) to error messages for improved scannability.
The result? A clean, easy-to-read error display that aligns with the rest of the form's styling.
With these updates, the post new form now looks great—it's more user-friendly, visually balanced, and functional.
Next, I’ll commit these changes and move on to refining the post show page. From there, we'll establish consistent UI patterns across our Rails application before transitioning to deployment preparation.