About this set
One comment thread shown twice, in a wide main column and a 300px sidebar, to show how much of a comment section current CSS can run without scripts. A container query lays the thread out by the width of its slot: from 420px it uses large avatars, names and times on one line and text labels on the actions; below that it uses small avatars, stacked names and icon-only actions with hidden labels. Reply is a native details element, so it opens and closes with the keyboard and announces its state without JavaScript, and :has() turns the whole comment into a Replying state with an accent border, a tint and a Replying tag while its form is open. Like is a visually hidden checkbox whose label fills the heart through :has(:checked). The reply textarea grows with its text through field-sizing: content, and browsers without it get a taller box the reader can resize. Send looks inactive while the required field is empty, comment text uses text-wrap: pretty and the heading text-wrap: balance. About ten lines of JavaScript only keep the demo on the page after sending and let Esc close the form.
What’s included
- Container query layout that adapts to the slot, not the viewport
- Native details reply forms with a :has() Replying state
- Checkbox likes styled with :has(:checked)
- field-sizing: content textarea with a resizable fallback
- text-wrap: pretty for comments and balance for the heading
Accessibility
The details summary is a native disclosure that reports expanded or collapsed and works with Enter and Space; its name includes the author, and Esc closes the form and returns focus to it. The Like checkbox keeps its label and draws focus on the visible pill. Icon-only actions keep visually hidden labels in the narrow layout, the reply field is labelled, sending is announced politely, and transitions stop under prefers-reduced-motion.
Customise it
Change --mx-accent, --mx-soft and --mx-heart on .mx, and the 420px value in the @container rule for the switch point. Bootstrap uses the same variables; in Tailwind edit the --color-mx-* theme colours and the @min-[420px]/mx: variants.






