Resilient Label Rows
Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 32 of 55.
Rows that combine a long label and a fixed action need a clear shrinking policy. Give the label min-w-0 flex-1 so it can use the remaining space and shrink below its content-based minimum. Give fixed controls shrink-0 so the label does not squeeze them.
<div class="flex w-72 gap-3"><p class="min-w-0 flex-1 truncate">Long descriptive document name.pdf</p><button class="w-16 shrink-0">Open</button></div>The truncate utility combines hidden overflow, no wrapping and ellipsis text overflow. The example keeps the complete file name in the document while limiting its visible presentation to one line. A lone ellipsis declaration does not establish all of those conditions.
Use truncation where the surrounding interaction can still reveal or open the full item. Do not replace essential long content with a shortened string merely to satisfy layout; the CSS pattern can preserve the original text.
Challenge
MediumFit the long filename and its 80px Open button into the supplied 320px row with a 16px gap. The filename must flex into the remaining 224px, permit shrinking below its content minimum and display a one-line ellipsis. Keep the button from shrinking and preserve the complete filename text.
Preserve the supplied content, semantic elements and IDs. Edit the requested utility classes. Press Run preview after edits, then Check/Run code to grade the result. Supplied JavaScript is read-only.
Try it yourself
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<div id="row" class="flex w-80 gap-4"><p id="name" class="flex-1">Workshop-recording-with-a-very-long-descriptive-filename.mp4</p><button id="action" class="w-20 ">Open</button></div>
</body></html>
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Responsive UI Patterns
1Page Shells
Growing Page ShellsFlexible Content RailsBounded Scroll RegionsFull-Bleed RegionsRecap: Page Shells4Form Layouts
Responsive Field GroupsFocused Field GroupsSelectable Form OptionsNative Validation CuesRecap: Form Layouts7Intrinsic Layouts
Auto-Fitting CollectionsResilient Label RowsMulti-Line PreviewsReadable Long TokensRecap: Intrinsic Layouts2Navigation Patterns
Wrapping NavigationCurrent Page CuesNative Menu DisclosuresKeyboard Skip LinksRecap: Navigation5Data Tables
Scrollable Data TablesPredictable Table ColumnsRow State PresentationSticky Table HeadersRecap: Data Tables8Interactive Panels
Expanded Control CuesChoice Card StatesFocus-Aware Help PanelsContent-Aware Empty StatesRecap: Interactive Panels11Project: Event Portal
Portal ShellSession Browser