Slimmer Desktop Chat Composer with Tailwind sm: Variants
Shrinking the desktop chat input field and buttons with four responsive Tailwind classes, no separate component and no JavaScript required.
TL;DR
The chunky mobile-sized chat composer was wasting desktop space, but a separate component felt like overkill. Four responsive Tailwind classes fixed it: base sizes stay touch-friendly for phones, sm: variants tighten padding and shrink buttons on desktop. Trade-off is width-based, not pointer-based, so wide touchscreen laptops get small buttons too.
The chat composer in my project's Tanya AI panel used to look chunky on desktop. A single-line textarea at least 40 pixels tall, extra vertical padding, plus two circular 44-pixel buttons. All of those sizes make sense on a phone because fingers need generous touch areas. On a desktop, where the mouse pointer moves with precision, that input strip was eating vertical space it did not need.
My first guess: a separate desktop component, or a small script that detects the viewport width and swaps button sizes. Yet the problem was nothing more than padding and icon dimensions. A second component means two places to maintain every time the input behavior changes. The answer turned out to be just four responsive Tailwind classes in one file, with no new component and no JavaScript.
Four Responsive Classes in One File
The change lives in ChatInputBar.tsx. Every utility that controls sizing got a sm: partner, which applies from a viewport width of 640 pixels up. The summary looks like this:
// field wrapper: tighter padding from 640px up
px-3 py-2 sm:py-1.5
// textarea: the 40px min-height is phones-only
min-h-[40px] sm:min-h-0 sm:py-1
// send and stop buttons: 44px on phones, 32px on desktop
size-11 sm:size-8
// the arrow icon shrinks one step too
size-5 sm:size-4
Class by class: the field wrapper gets a tighter padding variant on desktop. The textarea keeps its 40-pixel minimum height on phones, then releases it on large screens through a zero min-height and smaller padding. The send and stop buttons drop from size-11 to sm:size-8, from 44 to 32 pixels. The arrow icon shrinks one step along with them. The whole diff is four lines in a single file.
Why is this so cheap? Because Tailwind is mobile-first [1]. Utilities without a prefix apply at every screen size, while variants marked sm: only activate at the small breakpoint and above [1]. So the base classes are the phone styles, and the prefix is the exception for larger screens. The misreading is common: many people assume sm: means small screens, when it actually means from the small size upward.
The base sizes we kept are not arbitrary numbers either. size-11 produces a 44 x 44 pixel button, matching the minimum recommended by WCAG 2.5.5 for pointer targets [2]. The web.dev guidance goes further, suggesting about 48 device-independent pixels because that is roughly the size of a finger pad [3]. Giving those numbers up on phones to look compact would move the problem somewhere worse: fingers need large targets, mouse pointers do not.
A separate desktop variant sounded tidier at first, since each screen gets its own shape. Experience elsewhere in the same panel argues the opposite. Every duplicated component adds a contract to maintain: two places to change the placeholder, two places for the submit logic, two places to test. A breakpoint variant instead places both states side by side on one line of classes, so comparing layouts across sizes is as cheap as reading the code.
Testing it is cheap too. Temporarily strip every sm: variant from that file and the desktop view instantly turns chunky again; add them back and it tightens up. No state to simulate, no debug mode. In practice, at full width on a 27-inch screen the input area lost about a quarter of its height, enough for one extra answer line before the page needs scrolling.
One trade-off deserves honesty. This approach uses a width breakpoint, not an input-type media query like any-pointer: coarse, which web.dev recommends for distinguishing touch from mouse [3]. The consequence: a touchscreen laptop with a viewport wider than 640 pixels also gets 32-pixel buttons. For this chat panel most desktop visitors use a mouse, so the choice holds. If input-type matters later, the breakpoint variants can be swapped for pointer media queries.
The end result: compact on desktop, still safe to touch on phones, and no extra JavaScript. For the touch-target side of this story, I previously wrote about the 44-pixel button and 16-pixel font standards in the mobile chat panel: 44px Buttons, 16px Fonts: Standard Numbers in Mobile Chat.
Sources
- [1] Tailwind CSS Docs: Responsive Design, accessed 2026-09-08
- [2] W3C WAI: Understanding SC 2.5.5 Target Size, accessed 2026-09-08
- [3] web.dev: Accessible Tap Targets, accessed 2026-09-08