In this episode, we focus on refining the text area that you'll use to send messages in our chat interface. You'll see how we structure the chat message form and make it look nice using some of the existing styles from Laravel Breeze.
The key part is making the textarea behave just like any good chat app: you can hit Enter to send the message, but if you hold Shift+Enter, you get a new line instead. To pull this off, we use Alpine.js to capture keyboard events, detect shift key presses, and handle sending the message only when appropriate.
You'll also see how to link the textarea's value to your Livewire component using wire:model
, and make sure that empty messages don't get submitted by accident. We walk through setting placeholder text, adjusting the number of rows, and making sure accessibility features (like a screen-reader-only label) are in place.
By the end, you'll have a chat input that feels slick and intuitive: Enter sends, Shift+Enter makes a new line, and empty messages are ignored.