Responsive layout and reading order for shadcn
Rules / Layout: 4 rules and 0 guidelines
Layout decides more than how a page looks. It decides whether the page still works when someone zooms in to 400 percent, holds a phone, or listens to the page with a screen reader. Tailwind makes layout fast to write and easy to change at each breakpoint. That also makes it easy to break in ways nobody notices on a wide desktop screen.
Where layout goes wrong
- A sidebar and the content side by side at every width, so on a phone or when zoomed in, people scroll sideways to read each line. LAY-001
- A fixed width, such as a card set to
w-[600px]or a long line of code, that pushes the whole page wider than the screen. LAY-001 order-first,flex-row-reverseor grid placement that moves content on screen while the order in the code stays the same, so a screen reader tells a different story and Tab jumps around. LAY-002- A dialog footer whose buttons stack in reverse on a narrow screen: Save above Cancel on screen, Cancel first in the code. shadcn’s own dialog footers do this; Is shadcn accessible? explains why. LAY-002, ACT-003a
maximum-scale=1in the viewport tag, a heading sized invwonly, or a button with a fixed height that cuts its label once the text grows or its spacing widens. LAY-003a, LAY-003b
How the rules fit together
LAY-001 is about width. At 320 CSS pixels, which is what a 1280-pixel window gives you at 400 percent zoom, every piece of content and every function is still there, and nothing needs scrolling in two directions to be read or used. A part that needs two dimensions to make sense, such as a data table or a map, may scroll within itself. To check, make the browser window 320 pixels wide, or zoom in, and use the page.
LAY-002 is about order. Wherever order carries meaning, the order in the code tells the same story as the order on screen. Screen readers read the code order, and the keyboard follows it. Rearranging things visually is fine for decoration. It is not fine for steps, buttons, form fields or text that reads in sequence.
Two texts cover text that grows. LAY-003a lets text, also in controls and labels, grow to 200 percent with nothing cut off, laid over other content or broken, so zoom stays on and no text is sized in viewport units alone. LAY-003b keeps everything intact when a person widens line height, letter, word and paragraph spacing. Both come down to the same habit: let boxes grow with their text rather than fixing their height.
The two rules meet on narrow screens, where layouts are most often rearranged. When columns stack, decide the order in the markup and let CSS change only the arrangement. Several other rules depend on that: the order of a dialog’s buttons (ACT-003a), where focus goes in a dialog (DLG-006), and keeping the focused element in view (KBD-002), which a sticky header on a small screen breaks easily. The keyboard patterns cover that last one. When a sidebar moves into a sheet, its links keep their order (NAV-003) and its current-page mark (NAV-002b). A table that scrolls on its own gets a name for that area (TBL-004, a guideline), and rows that turn into cards keep each value’s label (TBL-001).
Our own dialog footer keeps the order of the code at every width, so Cancel comes first both on screen and for the keyboard.
What WCAG requires
All four rules are requirements of WCAG 2.2. LAY-001 follows from 1.4.10 Reflow, LAY-003a from 1.4.4 Resize Text, LAY-003b from 1.4.12 Text Spacing, and LAY-002 from 1.3.2 Meaningful Sequence and 2.4.3 Focus Order. The judges are recorded on each page as well: all three supported LAY-001, both who spoke supported LAY-003a, and the one who spoke supported LAY-002 and LAY-003b.
Rules and guidelines
Each one has its own page with the full rule, Do and Don't cases, exceptions and the verdict. A rule is decided by WCAG 2.2 or by the judges. A guideline is our own choice. How the method works
Required by WCAG 2.2
A WCAG 2.2 Level AA criterion requires the behaviour. Where a rule adds advice of its own, it says so.
LAY-001Let the page fit a 320-pixel viewport without scrolling sidewaysWhen the viewport is 320 CSS pixels wide, every piece of content and every function is still there. Nothing needs scrolling in two directions to be read or used, except a part that needs two dimensions to be understood or used, such as a data table or a map.LAY-002Keep the order in the code telling the same story as the order on screenWhere the order of content carries meaning or affects how it is used, the order in the code, which screen readers read and the keyboard follows, tells the same story as the order on screen, and layout tools such as grid placement or the order property never rearrange that content so the two disagree.LAY-003aLet text grow to 200 percent without losing content or functionText, also in controls and labels, can be enlarged to 200 percent without losing content or function: nothing is cut off, laid over other content or stops working. Do not switch off zoom or cap it below 200 percent in the viewport setting, and size no text in viewport units alone.LAY-003bKeep all text and functions intact when people widen the text spacingWhen a person sets line height to 1.5 times the font size, space after paragraphs to 2 times, letter spacing to 0.12 times and word spacing to 0.16 times, no text is cut off, hidden or laid over other content, and every function still works. The page need not use these values itself.
All rules · Is shadcn accessible? · Give the rules to an AI agent
Justified by Blackwood & Blake helps you work toward WCAG 2.2 AA. It is not a certification. Read more
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.