Installation
Add Focsd to a project with a package manager and a bundler.
The core of Focsd is two packages:
@focsd-dev/tokens: design tokens as CSS custom properties, plus self-hosted fonts.@focsd-dev/components: the styled components, built on headless primitives from@focsd-dev/primitives. With parts such asfocsd-optionandfocsd-tab, that is 136 custom elements (152 across all Focsd packages). The data grid, charts, rich text editor and AI chat kit are separate packages:@focsd-dev/data-grid,@focsd-dev/charts,@focsd-dev/editorand@focsd-dev/ai.
-
Install the packages.
Terminal window pnpm add @focsd-dev/components @focsd-dev/tokensTerminal window npm install @focsd-dev/components @focsd-dev/tokensTerminal window yarn add @focsd-dev/components @focsd-dev/tokens -
Load the tokens once, at the top of your app’s CSS or entry file. The fonts are optional; without them the system font stack is used.
import '@focsd-dev/tokens/fonts.css';import '@focsd-dev/tokens/tokens.css'; -
Register the components. Import everything:
import '@focsd-dev/components';Or import only the elements you use: each element has its own module,
focsd-<tag>.js, which registers that element and the parts it needs (focsd-tabs.jsalso registersfocsd-tabandfocsd-tab-panel). Each component page shows its module in the Usage section:import '@focsd-dev/components/focsd-button.js';import '@focsd-dev/components/focsd-date-picker.js'; // registers focsd-calendar tooGrouped modules such as
focsd-date.js(calendar, date pickers, time field, file upload) still register a whole family at once. -
Use the elements in your markup.
<focsd-button variant="action">Save changes</focsd-button>
Prevent layout shift
Section titled “Prevent layout shift”A custom element draws nothing until its script registers it, so for a moment the browser shows its raw content: every tab panel at once, a closed dialog’s text, an empty space where a text field will be. When the script runs, the page moves. Load upgrade.css before first paint and each element keeps the space it will take, with nothing unstyled on screen:
import '@focsd-dev/tokens/tokens.css';import '@focsd-dev/components/upgrade.css';Or link it in <head>, next to the tokens. The rules apply only until each element is defined. For an element that draws its content from data, such as a chart or a data grid, set its height on the element or its container for no shift at all.
Requirements
Section titled “Requirements”- The latest two versions of Chrome, Edge, Firefox and Safari (see Browser support). Components use native
<dialog>, the Popover API, CSS anchor positioning (with a fallback) and form-associated custom elements. - A bundler or an import map that resolves bare module specifiers (
lit,@focsd-dev/*).
Editor support
Section titled “Editor support”@focsd-dev/components ships a custom elements manifest (custom-elements.json) listing every element’s attributes, properties, events, slots and CSS parts. Editors and framework tools use it for autocomplete and type checking.
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.