Expand description
Premade UI components for Topcoat applications.
In the spirit of shadcn/ui, components are not
consumed as an opaque dependency. Instead, topcoat ui add <name> copies a
component’s source straight into the user’s project, where it can be freely
modified.
This crate models the registry that backs that command. A registry is a
cargo crate that carries a [package.metadata.topcoat-ui] key pointing at a
directory holding a registry.toml manifest alongside the component source
files. A registry is referenced by its crate name and must be a dependency
of the consuming project, so its component source is always present locally
at the matching version. Registries are read at runtime, so the set of
available components can change without rebuilding the CLI.
Each component is versioned independently by a hash of its source (see
content_hash). A registry.toml records no hashes: it names each
component and its source file, and the hash is computed from the registry’s
current source. The hash is recorded in the project’s install state when a
component is added, then recomputed from the registry to surface updates.
A registry.toml is written by hand; there is no generator.
Modules§
- manage
- Package-side management of installed components.
Structs§
- Component
- A single component within a
Registry. - Registry
- A component registry loaded from a crate’s registry directory.
- Theme
- A single theme within a
Registry: a CSS file that becomes a project’s Tailwind input, copied into the project atinittime.
Enums§
- Dependency
- Another component that must be installed alongside a component.
- Error
- An error loading a registry or one of its components.
Constants§
- DEFAULT_
REGISTRY - The registry name used when a project does not specify one. It is also the
name under which the built-in registry is recorded in a project’s install
state and given on the
topcoat uicommand line. It is an alias for theDEFAULT_REGISTRY_CRATEcrate, which thetopcoatfacade pulls in under itsuifeature. - DEFAULT_
REGISTRY_ CRATE - The crate that provides the built-in registry. It is referred to by the name
DEFAULT_REGISTRYeverywhere a registry is named, and, unlike other registries, need not be a direct dependency of the project: thetopcoatfacade pulls it in transitively under itsuifeature. - MANIFEST_
FILE - The manifest file naming the components within a registry.
- MANIFEST_
VERSION - The
registry.tomlformat version this build understands. Stored in the manifest’sversionfield so older and newer formats can be told apart; a manifest declaring a newer version than this is rejected.
Functions§
- content_
hash - Computes the content hash recorded for a component, the sha256 of its source
prefixed with
sha256:. Hashing the same source always yields the same value, so a project can tell its installed component apart from an updated one by comparing the hash it recorded against a fresh hash of the registry’s current source.