The shadcn-templ CLI uses Go import paths for installing components and rewriting imports.
Go resolves imports through the module path in your go.mod, so there is no separate alias configuration like path mappings in other ecosystems. The CLI derives your import paths from go.mod and stores them as aliases in components.json.
Example
You configure aliases in your components.json:
Then import installed components using your module path:
Alias paths are Go import paths and must live under the module path of your go.mod. shadcn-templ init derives them for you.
Module Imports
In the import workflow, components are imported directly from the shadcn-templ module. No components.json and no aliases are needed:
See the installation guide for the full setup of both workflows.
App
For apps that install components into their own module with the CLI.
Configure go.mod
The module path is the root of every generated import.
Configure components.json
Run shadcn-templ init to write components.json. It derives the aliases from your go.mod module path.
The components alias is the import path components install under. The utils alias is the import path of the shared utils package.
Add components
The CLI resolves registry dependencies recursively and rewrites all imports — github.com/axadrn/shadcn-templ/v2/components/... and github.com/axadrn/shadcn-templ/v2/utils — to your aliases.
Troubleshooting
If Go cannot resolve an import after adding components, check that:
- the alias paths in
components.jsonlive under themodulepath of yourgo.mod - you ran
templ generateandgo mod tidyafter adding - the component directory exists under the path the
componentsalias points to
If a component is installed but its imports still point at the wrong module path, fix the aliases in components.json and re-run shadcn-templ add <component> --overwrite.