Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Sortable Directory Team Block for React

A document-signing company's ten people in a table whose cells share their hairlines, sorted by name, department or tenure from the header, with a tenure bar and a live sort announcement.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A sortable team roster for React with Base UI, for Signetly, a document-signing company. A centred header sits over a table of ten people whose cells share their hairlines from rail to rail. Name, Department and Joined are header buttons: press one to sort by it, press it again to reverse the order, and the sorted column shows an arrow and says so to assistive technology. "Joined" is a tenure in company years ("Year 4", never a calendar year) with a thin bar behind it, and sorting by it puts the longest tenure first. After each sort the rows fade back in. On a phone the header gives way to a Sort by group, each person becomes a two-line row, six are shown and a Show all button opens the rest. It's built from Table, Toggle Group, Avatar, Button and Guides, with CSS transitions and your theme's tokens for every colour. For an about page or an internal directory that needs one ordering control. There are no filters; team-interactive-directory has those. The people are invented.

FAQ

How do I change the people and the sort options?

Edit PEOPLE at the top: a name, a role, a department and a year, the year of tenure. The longest tenure sets the bar's full width. The sortable columns are listed in COLUMNS; each key needs a case in the small compareBy function. Add a column by adding a key there, a header cell and a cell per row.

How does a sort work, and what does 'ascending' mean for Joined?

Pressing a column sorts by it from the start of its order; pressing the sorted column again reverses it. Name and Department run A to Z, then Z to A. Joined is a tenure, so its first order is longest tenure first, then newest first. Ties fall back to the name.

How is the sort announced?

The sorted header cell carries aria-sort (ascending or descending), the other sortable columns carry none, and a polite status line reads the result, such as "Sorted by Department, A to Z". Focus stays on the header you pressed. Each sortable header holds a real button inside its cell.

What happens on a phone?

The header row is hidden and a Sort by group (Name, Department, Joined) sits above the list. Press the selected button again to reverse the order, or another to switch. Each person is two lines, with the role and department under the name and the tenure at the end; six are shown and a Show all 10 button opens the rest.

What moves, and what happens with reduced motion?

The header and the table fade up once on load, and the rows fade in again after each sort; nothing slides, and no row animates between positions. With reduced motion every fade is off and the order simply changes.

Are the tenure bars read out?

The bars are decoration: the same tenure is in the cell as text ("Year 7"), and that text is what a screen reader reads. The numeral is isolated so it keeps its order in a right-to-left layout.

  • Pro

    Searchable Directory Team

    Lists and directories

    A field-service company's eighteen people in one table, under a ruled band with a search field, department and city selects, a live count and a clear button, with an empty state when nobody matches.

  • Pro

    Compact List Team

    Lists and directories

    The quiet roster of a fleet-telematics company: one dense line per person at forty pixels, rail to rail, twelve shown and the other twelve opened in place from a Show all button.

  • Pro

    Numbered List Team

    Lists and directories

    Sixteen people of a plant-care app as an ordered list in the order they joined, each row an employee number in tabular figures, an initials avatar, a name, a specific role and a company-relative join year.

  • Pro

    Department Tabs Team

    Tabs and accordions

    Thirty people of a grocery-delivery company by department: underline tabs with headcounts, then each panel opens with its lead on a tinted band and the team as two columns of hairline rows.

  • Pro

    Grid Cards Team

    Grids and walls

    Twelve people of a restaurant-software company in a hairline grid that runs from rail to rail, each an initials avatar with a name, a role, a department badge and a city, under a department picker that brings the picked team to the front and dims everyone else.

  • Pro

    Command Palette Search Team

    Lists and directories

    A people palette in a framed window for a team wiki: a live command box over twelve people and four teams, matched letters marked, arrow keys to move, and the highlighted entry's profile with its local time beside the list.