About this set
A chat that does with CSS what most chat widgets do with JavaScript, shown in a wide and a narrow slot. The log is a flex container with flex-direction: column-reverse around a normal message stack, so it opens at the newest message and stays there as new ones are added, with no scroll script. New messages fade and slide in through @starting-style. The textarea grows with its text through field-sizing: content, and because it is required, :has(textarea:invalid) dims the Send button while the field is empty. A container query on the chat itself switches layouts by the width of its slot rather than the window: from 420px up it shows avatars and a labelled Send button, below that it drops the avatars and keeps an icon button with a hidden label. The only script, about 20 lines, appends your message and handles Enter and Shift+Enter. The same markup fits a sidebar, a modal and a full page. Where field-sizing is unsupported the textarea keeps one row and scrolls, and where @starting-style is unsupported messages simply appear.
What’s included
- column-reverse log that stays on the newest message
- field-sizing: content textarea with no resize script
- :has() dims Send while the required field is empty
- Container query layout for wide and narrow slots
- @starting-style entrance, removed under reduced motion
Accessibility
The log is a focusable role="log" region with aria-live="polite", and every message has a sender, hidden for your own, and a time element. Because the field is required, pressing Send while it is empty shows the browser's own validation message instead of failing silently. In the compact layout the Send label is visually hidden rather than removed, and the entrance transition is switched off under prefers-reduced-motion.
Customise it
Change --mc-accent, --mc-in and --mc-line on .mc, and the 420px value in @container mc (min-width: 420px) to choose where the roomy layout starts. In Tailwind edit the --color-mc-* theme colours and the @min-[420px]/mc: variants; in Bootstrap the same variables sit on the .card.






