shadcn.io is not affiliated with official shadcn/ui
Sort Controls Gallery Block for Radix UI
Eight drawn bike frames that each print their date, likes and title, with a Sort by select, a reverse toggle and a Grid or List switch, so the order is checkable by eye.
Installation
Overview
Sort controls for React with Radix UI, for Spoke & Co, a bike shop. A centred header sits over a band with a "Sort by" Select (Date added, Likes, Title), a "Reverse order" Toggle and a Grid / List Toggle Group, then eight drawn bike frames on shared hairlines. Every frame prints the three things it can be sorted by, a fixed date, a like count and a title, and the key in use is set in heavier type, so you can check the order by eye. Date and Likes start with the biggest first and Title from A, and Reverse flips each. A polite status in the foot band says "Sorted by Likes, most liked first. List view." The list and the grid share one cell, so no choice moves the page. The frames are drawn, never photographed: road, step-through, flat-bar and cargo bikes, each as one line. It's built from Select, Toggle, Toggle Group and Guides.
FAQ
How is the order worked out?
From the data, with one comparison per key and the title as the tie-break, so equal likes always fall in the same order. The natural direction is newest first, most liked first and A to Z; Reverse flips it. Nothing is sorted in place: the block sorts a copy and renders it.
Does the page move when I change the sort or the view?
No. The list and the grid are both always in the markup, in one grid cell; the one you are not looking at is invisible, aria-hidden and inert, and both stretch to the taller one, so the rows of the list grow a little to match a grid that is taller. Every row and cell is the same height whatever the order, because titles are one line.
Which keys work?
What does a screen reader hear?
A polite status line that says which key and direction are in use and which view is showing, each time any of them changes. Rows and cells are plain lists; the date is a time element and the likes carry a hidden "likes".
How do I use my own pictures?
The drawn pictures are one Scene component. Where the code comment says so, replace it with an <img> (object-cover in a box of the picture's own ratio) and give each entry a src. Keep each entry's ratio the picture's own so the layout doesn't change. Replace each frame's Scene in both views.