Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Select Template Dialog Block for React

A documents app's new-document dialog shown open: six icon tiles in two columns that move with the arrow keys and jump on a typed letter, Popular and New badges, a Create button that names the choice, and the new file landing on the home.

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

Let people start from a template without a gallery page, with this new-document dialog for React with Base UI. It opens from the Documents home of Foliodesk, a documents app: the page's header holds an outline New document Button, and the home itself, a top bar with a search and a New button, a row of folders and a list of recent files, is drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The Dialog holds six icon tiles in two columns, Blank, Meeting notes, Weekly report, Proposal, Invoice and Roadmap, each with an icon, a name and a line about it, a "Popular" and a "New" Badge among them, and the chosen tile is ringed and ticked. The tiles are one radio group: the arrow keys move in two dimensions, and typing a letter jumps to the next tile that starts with it. The only Shine Button names the choice, "Create Weekly report", and Start blank is a ghost button. Creating puts "Untitled weekly report" at the top of the drawn recent files. For preview the dialog is drawn open in place when the page loads; the header button opens the real Dialog, with the same tiles. For documents, notes, spreadsheets and any app that starts from a template.

FAQ

Why is the dialog already open, and what do I keep?

So you can see it without a click. On load the dialog is a copy drawn in place over the home: a native dialog element that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. The New document button opens the real Dialog, modal, with its focus trap, Escape and focus return, and the copy stays closed until a reload. Both show the same TemplateTiles component and share the block's state, so the tile you chose in the copy is chosen in the real one. In your app keep the Dialog and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.

How do the arrow keys and typing work?

The tiles are native radio buttons, so the group is one tab stop and moving the focus chooses the tile. Left and Right move along a row (reversed in a right-to-left layout) and stop at the row's ends, Up and Down move between rows, and Home and End go to the first and last tile. Typing a letter jumps to the next tile whose name starts with it, wrapping round, so M finds Meeting notes and R finds Roadmap. Each name starts with its own letter, so one key is enough; with names that share a letter, pressing it again steps to the next one.

What do Create and Start blank do?

Create adds a file named for the template, "Untitled weekly report", to the top of the drawn recent files and says so in a polite message; Start blank adds "Untitled document". Both close the dialog and return focus to the New document button. The newest three files show above the older ones, and nothing is created anywhere: the row lives in this tab.

Why icon tiles and no thumbnails?

A template's name and one line carry its meaning, and an icon marks its kind. Drawn thumbnails of each page would be six illustrations to keep in step with real templates, and they sink on a small screen. The tiles stay in two columns on a phone, with the icon above the name, and the badges say what is popular or new in words.

What stays local in the demo, and how do I wire it up?

All of it. The six templates are a typed list and Create only updates the drawn home. In your app load the templates from your API in the same shape (an id, a name, a line, an optional badge), create the document from create and send the person to it; the tiles, the keys and the label that names the choice stay as they are.

Is it accessible from the keyboard?

Yes. The real dialog is named by its title and described by its sentence, the tiles are a labelled radio group with their key instructions as its description, focus starts on the chosen tile and stays inside until the dialog closes, and Escape and the close button return focus to New document. The trigger is passed to DialogTrigger through render, and the dialog is controlled with open and onOpenChange. The copy shown on load moves no focus; Escape inside it and its close button close it and put focus on the button.

  • Pro

    A gallery of twelve drawn templates in three tabs, chosen as radio cards, each with a Preview that opens a dialog with a larger drawing and the pages it would make.

  • Pro

    Select Plan Dialog

    Payments and plans

    A static-site host's Sites page with its plan chooser shown open: three plans as rows that unfold to their features, a yearly switch that rewrites the prices and what is due today, and a comparison table behind a disclosure.

  • Pro

    An invoicing app's quick-actions dialog shown open: eight action tiles in two columns, a star on each that pins it into one of four slots at the top, arrow keys across the tiles and a letter that runs an action.

  • Pro

    A scaffolding tool's welcome tab with a new-project dialog shown open: a numbered rail beside four selects, a project name in kebab case and a live command in a themed mono window that the Shine Button copies to your clipboard.

  • Pro

    Save Draft Dialog

    Notes and editing

    A publishing editor with its save-draft dialog shown open: a name, a folder, an autosave choice with a sentence that follows it, and a discard that asks again in the same row.

  • Pro

    A docs editor's empty library as a whole page: three document types as choice cards with drawn mini pages, one button that names the choice, and a quiet strip to drop a file instead.