Skip to content
Focsd homeFocsd homeFocsd
Forms

Blocks

Whole pages you copy into your project with one command, built only from Focsd's public APIs.

A block is a complete, accessible page: plain HTML, one JS module and, for some blocks, a small CSS file. npx focsd add block <name> writes it into blocks/<name>/ in your project. It is only markup and the elements it imports, so it fits any framework, but it needs a bundler or an import map (see below).

Terminal window
npx focsd list --blocks
npx focsd add block dashboard
npx focsd add block dashboard --out src/pages/overview
  • It never overwrites. If any target file exists, the command writes nothing, lists the files in the way and exits with code 1. --overwrite is refused for blocks. Pick another folder with --out, which is relative to the project root.
  • It uses the packages. The JS imports @focsd-dev/components/focsd-*.js (plus @focsd-dev/charts and @focsd-dev/data-grid for the dashboard). The command prints the npm install line for the block. A focsd.json is not required; if you copied components with focsd add, those win and the block works with them.
  • The text is yours. The sample content is in the HTML, so edit it in place. Block strings are not routed through registerTranslation.
  • It needs a bundler or an import map. The block’s script imports bare specifiers (@focsd-dev/components/focsd-card.js), which a plain static server cannot resolve: the page stays blank. Open blocks/<name>/index.html with Vite, Parcel, webpack or another dev server that resolves bare imports, or add an import map. The two <link> tags for @focsd-dev/tokens point at /node_modules/@focsd-dev/tokens/dist/; in a bundler setup, replace them with import '@focsd-dev/tokens/tokens.css' in the block’s script.
  • It sends nothing. Settings and sign-in validate on the page and send no request. Settings fires a cancelable settings:save event; the sample handler in settings.js resolves at once, so replace it with your own save call. Sign-in’s form has an empty action: set your endpoint there or handle the submit in sign-in.js.
  • Icons. Sidebars use the built-in icons (home, inbox, users, package, settings and more). Register your own icon set to use any other icon, and change the icon attributes.

An app shell with a sidebar, four stat tiles, a revenue chart and a sortable, paginated orders grid.

Copy it into your project
npx focsd add block dashboard

Needs: npm install @focsd-dev/components @focsd-dev/charts @focsd-dev/data-grid @focsd-dev/tokens. Uses 14 elements: app-shell, avatar, chart, data-grid, footer, header, icon-button, menu, menu-item, sidebar, sidebar-item, sparkline, stat, theme-toggle.

The sidebar becomes a drawer below 768 px, the four stat tiles wrap to two columns and then one, and the orders grid scrolls inside its own wrapper on a phone.

App shell with a tabbed settings form: profile, notifications and security, an error summary and a Saved announcement.

Copy it into your project
npx focsd add block settings

Needs: npm install @focsd-dev/components @focsd-dev/tokens. Uses 15 elements: app-shell, button, error-summary, fieldset, header, option, select, sidebar, sidebar-item, switch, tab, tab-panel, tabs, text-field, theme-toggle.

A tabbed form. An invalid email stops the submit and moves focus to the error summary. Saving announces “Settings saved” and sends nothing: wire your own request.

Centered sign-in card with email, password and remember me, correct autocomplete tokens and an error summary. Sends nothing.

Copy it into your project
npx focsd add block sign-in

Needs: npm install @focsd-dev/components @focsd-dev/tokens. Uses 7 elements: button, card, checkbox, error-summary, link, password-field, text-field.

A centered card with autocomplete tokens that password managers understand. It sends nothing; replace the form action and the submit handler with your sign-in call.

App shell with header and sidebar and a first-run empty state with a primary action and a secondary link.

Copy it into your project
npx focsd add block empty-app

Needs: npm install @focsd-dev/components @focsd-dev/tokens. Uses 8 elements: app-shell, button, empty-state, header, link, sidebar, sidebar-item, theme-toggle.

A shell with a header and sidebar and an empty state in main. The skip link reaches main, and there is one main landmark.