SVG Icon Library
betaSearch and filter an SVG collection, preview icons, copy their markup, and download individual files or a prepared ZIP.
Built from Accordion, Toast, Icon Color Picker, Button, Search Field, Select, and Skeleton.
Preview
Install
1. Add the registry to
components.json, once per app. Without it, the shadcn CLI looks up@txbrendanin a public list that txbrendan/ui does not control.npx shadcn@latest registry add "@txbrendan=https://txbrendan.dev/r/{name}.json"2. Add the theme, once per app. It replaces your color tokens with ones checked for contrast.
npx shadcn@latest add @txbrendan/theme3. Add the block. It also adds every component it uses. Its own files go in your
componentsfolder, and they are yours to edit.npx shadcn@latest add @txbrendan/svg-icon-library
Use it for
- Place one Toaster in your app layout to show brief copy confirmations.
- A downloadable icon collection with names and categories.
- Host trusted SVG files and the optional ZIP on your own origin. Copy needs fetch access; browser downloads work with same-origin URLs.
- Supply your own assets. The block does not install the gallery's example artwork.
Avoid it for
- A single icon inside a control: use Icon.
- Untrusted uploads. This block does not sanitize or host files.
Props
- palette
Editable original hex paints. Overrides apply to SVG paint attributes in previews, copies, downloads, and ZIPs; geometry and transparency stay intact.
readonly { label: string; value: string }[]
- items
Unique name, visible title, category, and SVG src URL for each icon.
readonly SvgIconAsset[] · default []
- downloadAllHref
Optional same-origin ZIP for original artwork. With custom colors, a new ZIP of the whole collection is generated locally. Filters never reduce the collection.
string
- loading
Shows placeholders and hides stale artwork and download actions.
boolean · default false
- emptyText
Message when the collection has no assets.
string · default "No icons yet."
- className
Extra classes on the container. Later classes win.
string
| Prop | Type | Default | What it does |
|---|---|---|---|
| palette | readonly { label: string; value: string }[] | - | Editable original hex paints. Overrides apply to SVG paint attributes in previews, copies, downloads, and ZIPs; geometry and transparency stay intact. |
| items | readonly SvgIconAsset[] | [] | Unique name, visible title, category, and SVG src URL for each icon. |
| downloadAllHref | string | - | Optional same-origin ZIP for original artwork. With custom colors, a new ZIP of the whole collection is generated locally. Filters never reduce the collection. |
| loading | boolean | false | Shows placeholders and hides stale artwork and download actions. |
| emptyText | string | "No icons yet." | Message when the collection has no assets. |
| className | string | - | Extra classes on the container. Later classes win. |
Accessibility
- Search and category controls have accessible names. Each icon is a named button with aria-pressed selection.
- Copy success uses a toast. Failures, counts, and loading are announced in a status line.
- Copy requires a secure context and clipboard permission. A failed copy keeps the download link available.
- Filtering keeps the preview and download link on a visible result. No matches hides both.
Examples
An asset collection
<SvgIconLibrary items={[{ name: "ball", title: "Rugby ball", category: "Sport", src: "/icons/ball.svg" }]} downloadAllHref="/icons/collection.zip" />