Import Workflow
Use shadcn-templ as a plain Go module dependency.
⚠️ Experimental: This workflow may not survive to 2.0 stable. The supported path is the CLI, which copies component source into your app so you own and edit it, exactly like shadcn. The import workflow instead consumes shadcn-templ like any Go library: no copied files, updates via
go get, customization by wrapping components rather than editing them. If you rely on it, say so. Real-world usage decides whether it ships in stable.
Prerequisites
The same tools as the CLI workflow: see Installation → Configure templ, Tailwind CSS and Task.
Setup
1. Add shadcn-templ
You can also just import a component package and run go mod tidy.
2. Initialize Styles
Style setup is the same shadcn-templ init as in the CLI workflow: it creates assets/css/globals.css and merges your theme variables and base layer into it. Pick a design on shadcn-templ.com/create and pass its preset code, or use one of the named presets:
Then add one line to assets/css/globals.css, right after the tailwindcss import:
sources.generated.css is written by the tailwind task in the next step: it pulls the component styles (style-nova.css), the shared shadcn/tailwind.css layer and the tw-animate-css utilities straight from the shadcn-templ module and registers the .templ sources for scanning.
💡 Tip: For custom themes and color palettes, see the theming docs.
3. Create Taskfile
Run everything with:
4. Activate a style
Components carry cn-* classes; the style class on <body> picks which of the eight styles renders them (style-nova, style-vega, style-maia, style-lyra, style-mira, style-luma, style-sera, style-rhea). Use the style from your components.json (init writes it, nova by default) and import the matching style-<name>.css in the tailwind task above (the snippets use style-nova):
5. Import and use a component
JavaScript and Assets
The script bundle and asset serving are identical in both workflows: see Installation → JavaScript and Installation → Serve Assets.