friendly user zystem - Svelte UI library
fuz_ui (@fuzdev/fuz_ui) is a Svelte UI library built on fuz_css. It provides
components and TypeScript helpers for building user-friendly websites.
For coding conventions, see Skill(fuz-stack).
gro check # typecheck, test, lint, format check (run before committing)
gro typecheck # typecheck only (faster iteration)
gro test # run tests with vitest
gro gen # regenerate .gen files (library.json, fuz.css)
gro build # build for productionIMPORTANT for AI agents: Do NOT run gro dev - the developer will manage the
dev server.
- Svelte 5 - component framework
- SvelteKit - application framework
- fuz_css (@fuzdev/fuz_css) - CSS framework and design system foundation
- fuz_util (@fuzdev/fuz_util) - utility library
- Gro (@fuzdev/gro) - build system and CLI
fuz_ui is a Svelte 5 UI component library:
- UI components (dialogs, menus, forms, layout)
- Documentation system (tomes + auto-generated API docs)
- Source code analysis (TypeScript/Svelte introspection)
- Theme management integration with fuz_css
- CSS framework (use fuz_css)
- Pure utility functions (use fuz_util)
- Build tooling (use gro)
- State management beyond contexts
- Router or navigation (use SvelteKit)
src/
βββ lib/ # exportable library code
β βββ *.svelte # UI components (50+)
β βββ *.ts # TypeScript utilities
β βββ *.svelte.ts # Svelte 5 runes and reactive utilities
β βββ *.gen.ts # Gro genfiles (code generators)
βββ test/ # test files (not co-located)
β βββ fixtures/ # fixture-based tests (mdz, tsdoc, ts, svelte)
βββ routes/ # SvelteKit routes
βββ docs/ # documentation pages
β βββ tomes.ts # central documentation registry
β βββ api/ # auto-generated API docs
βββ library.gen.ts # library metadata generator
Tome - documentation units that define the library's structure. Each tome
represents a component or helper with name, category, component, and
related fields. Central registry: src/routes/docs/tomes.ts
Identifier namespacing - fuz_ui uses domain-prefix naming for its helper
clusters. See fuz-stack for the full naming conventions.
Helper file prefixes: ts_* (TypeScript API), tsdoc_* (JSDoc parsing),
svelte_* (component analysis), module_* (path utilities),
package_gen_* (Gro package generation).
Card,Details,Breadcrumb,TeleportDocs,DocsContent,DocsList,DocsMenu- documentation layoutTomeContent,TomeHeader,TomeSection- tome layout
Alert- alert/notification componentPendingAnimation,PendingButton- loading states
Dialog,Dialogs- modal dialogsContextmenu*- context menu system (Root, Entry, LinkEntry, TextEntry, Submenu, Separator)
HueInput,ColorSchemeInput,ThemeInput- theme controls
Svg,Glyph,ImgOrSvg
CopyToClipboard,PasteFromClipboard
Hashlink- hash anchor linksTomeLink,DeclarationLink,ModuleLink- docs navigationGithubLink,MdnLink- external reference links
PackageDetail,PackageSummary- package info displayMdz- renders mdz (minimal markdown dialect) contentApiIndex,ApiModule,ApiDeclarationList- API documentation
ThemeRoot- theme provider componentRedirect- client-side redirects
tome.ts- documentation system types and utilitiestheme_state.svelte.ts- theme and color scheme management (ThemeState class)context_helpers.ts- Svelte context utilities (create_context())mdz.ts- minimal markdown dialect parser and renderer
contextmenu_state.svelte.ts- context menu state managementdialog.ts- dialog utilities (to_dialog_params(), DialogLayout enum)alert.ts- alert utilitiesstorage.ts- localStorage utilities with optionalparse_fnfor custom parsingcsp.ts- Content Security Policy builder utilitiesdimensions.svelte.ts-Dimensionsclass for width/height trackingrune_helpers.svelte.ts-effect_with_count()wrapper
library.gen.ts- Gro genfile that orchestrates metadata generationlibrary.svelte.ts-Libraryclass wrapping library datadeclaration.svelte.ts-Declarationclass for code declarationsmodule.svelte.ts-Moduleclass for source fileslibrary_helpers.ts- docs URL helpersvite_plugin_library_well_known.ts- RFC 8615.well-known/metadata publishing
ts_helpers.ts- TypeScript compiler API utilities (ts_analyze_declaration,ts_analyze_module_exports,ts_create_program)svelte_helpers.ts- Svelte component analysis (svelte_analyze_file,svelte_analyze_component)tsdoc_helpers.ts- JSDoc/TSDoc parsing (tsdoc_parse,tsdoc_apply_to_declaration). Supports@param,@returns,@throws,@example,@deprecated,@see,@since,@nodocs,@mutatesmodule_helpers.ts- module path utilities (module_is_typescript,module_is_svelte,module_extract_path)library_analysis.ts- unified analysis entry pointlibrary_pipeline.ts- pipeline orchestration (collect, analyze, validate, transform, output)
docs_helpers.svelte.ts- docs navigation and linking (DocsLinks class)autofocus.svelte.ts- Svelte 5 attachment for focusing elements on mountintersect.svelte.ts- Svelte 5 attachment for IntersectionObserverhelpers.ts- general utilities (render_value_to_string)
svelte_preprocess_mdz.ts- build-time compilation of staticMdzcontentmdz_to_svelte.ts- convertsMdzNodearrays to Svelte markup stringsMdzPrecompiled.svelte- wrapper component for precompiled output
Compiles static <Mdz content="..."> usages to pre-rendered Svelte markup at
build time, replacing Mdz with MdzPrecompiled containing children.
Eliminates runtime mdz parsing for known-static content.
// svelte.config.js
import {svelte_preprocess_mdz} from '@fuzdev/fuz_ui/svelte_preprocess_mdz.js';
export default {
preprocess: [
svelte_preprocess_mdz({
components: {Alert: '$lib/Alert.svelte'},
elements: ['aside', 'details'],
}),
// ...other preprocessors
],
};excludeβ file patterns to skip (Array<string | RegExp>)componentsβ mdz component name to import path mapping (Record<string, string>)elementsβ allowed HTML element names in mdz content (Array<string>)component_importsβ import sources that resolve to Mdz (default:['@fuzdev/fuz_ui/Mdz.svelte'])compiled_component_importβ import path for MdzPrecompiled (default:'@fuzdev/fuz_ui/MdzPrecompiled.svelte')on_errorβ'log'or'throw'(default:'throw'in CI,'log'otherwise)
The preprocessor leaves Mdz untouched (falls back to runtime) when:
- File is excluded via
excludeoption - No matching import source found for Mdz
import typedeclaration (not a runtime import)MdzPrecompiledname already imported from a different sourcecontentprop is dynamic (variable, function call,$state,$derived)- Spread attributes present (
{...props}) - Content references unconfigured components or elements
baseprop is dynamic (falls back to runtime for correct resolution)- A ternary branch has dynamic content or unconfigured tags
- Static string attributes:
content="**bold**" - JS string expressions:
content={'**bold**'} - Template literals without interpolation:
content={`**bold**`} - Const variable references:
const msg = '**bold**'; content={msg} - Ternary chains with static branches:
content={show ? '**a**' : '**b**'} - Nested ternaries:
content={a ? 'x' : b ? 'y' : 'z'}β{#if}/{:else if}/{:else}
The preprocessor automatically:
- Adds
MdzPrecompiledimport - Adds imports required by rendered content (
DocsLink,Code,resolve, configured components) - Removes the
Mdzimport when all usages are transformed and the identifier is not referenced elsewhere - Removes dead
constbindings that were only consumed by transformed content
All contexts use the standardized pattern via context_helpers.ts:
Core:
theme_state_context- theme state (ThemeState class)library_context- library API metadata (Library class)
Documentation:
tomes_context- available documentation (Map<string, Tome>)tome_context- current documentation page (Tome)docs_links_context- documentation navigation (DocsLinks class)mdz_components_context- custom mdz componentsmdz_base_context- base path for relative link resolution
Contextmenu:
contextmenu_context- context menu statecontextmenu_submenu_context- submenu statecontextmenu_dimensions_context- positioning
Other:
selected_variable_context- style variable selection
Fuz provides a documentation system combining manual tomes with auto-generated API docs.
Tomes - manual documentation pages. Define in tomes.ts, create matching
+page.svelte wrapping content in <TomeContent>. Categories: "guide",
"helpers", "components". See src/routes/docs/tomes.ts for examples.
API documentation - auto-generated from TypeScript/Svelte source with full
TSDoc support. Two-phase architecture: TSDoc extraction at build time
(tsdoc_helpers.ts), mdz rendering at runtime (mdz.ts). Setup requires
library.gen.ts and API routes. See src/routes/docs/api/ for example routes.
Docs layout - <Docs> provides three-column responsive layout with managed
contexts for navigation.
- Early alpha - API will change
- SvelteKit dependency - Some components require SvelteKit
- Fixture tests - Never manually edit
expected.json(see Fixture tests section below) - Contextmenu focus - APG-compliant focus management not yet implemented
- Color optimization - Build-time color optimization not implemented
- TypeScript strict mode
- Svelte 5 with runes API
- Prettier with tabs, 100 char width
- Node >= 22.15
- Tests in
src/test/(not co-located) - Fixture-based tests (see below)
snake_casefor files, variables, functionsPascalCasefor types, classes, Svelte components- Explicit file extensions in imports
- JSDoc comments use proper sentences with periods; inline comments can be fragments without capitals
Fixture-based tests compare parser/analyzer output against expected JSON.
Each fixture is a directory with an input file and expected.json.
Never manually edit expected.json β create or modify input files and
regenerate with update tasks.
| Category | Input file | Tests |
|---|---|---|
fixtures/mdz/ |
input.mdz |
mdz parser (mdz_parse) |
fixtures/tsdoc/ |
input.ts |
TSDoc/JSDoc parsing (tsdoc_parse) |
fixtures/ts/ |
input.ts |
TypeScript declaration analysis |
fixtures/svelte/ |
input.svelte |
Svelte component analysis |
fixtures/svelte_preprocess_mdz/ |
input.svelte |
mdz preprocessor transforms |
gro src/test/fixtures/update # all categories
gro src/test/fixtures/mdz/update # mdz only
gro src/test/fixtures/svelte_preprocess_mdz/update # preprocessor only
gro src/test/fixtures/tsdoc/update # tsdoc only
gro src/test/fixtures/ts/update # ts only
gro src/test/fixtures/svelte/update # svelte only- Create a new directory under the appropriate category (e.g.
fixtures/mdz/my_new_case/) - Add the input file (
input.mdz,input.ts, orinput.svelte) - Run the category's update task to generate
expected.json - Run
gro testto verify
For svelte_preprocess_mdz fixtures, input files with fake imports need
// @ts-nocheck in the script block.
fuz_css- CSS framework (peer dependency)fuz_util- utility functions (peer dependency)fuz_template- starter template using fuz_uifuz_blog- blog template using fuz_uifuz_mastodon- Mastodon components using fuz_ui