Go icons provides an aggregation of icon libraries for golang developers using either html/template or a-h/templ.
Simply use the command line utility to install individual icons into your project, or use them directly as templ.Component templates.
| Icon Library | Version | License |
|---|---|---|
| Ionicons | MIT | |
| Lucide Icons | ISC | |
| Material Icons | MIT | |
| Radix Icons | MIT | |
| Simple Icons | CC0 1.0 |
Go Icons can be used in two different ways:
- Icons imported as a package of templ icons
- A command line utility to generate html or templ icons directly into your project
Note
If an icon you want to use starts with a number, it will be prefixed with a capital T.
E.g,
@material.T10_24px()Install
go get github.com/dimmerz92/go-icons/ionicons@latestUsage
@ionicons.Accessibility() // no argument
@ionicons.Accessibility(templ.Attributes{}) // templ.Attributes argumentInstall
go get github.com/dimmerz92/go-icons/lucide@latestUsage
@lucide.AArrowDown() // no argument
@lucide.AArrowDown(templ.Attributes{}) // templ.Attributes argumentInstall
go get github.com/dimmerz92/go-icons/material@latestUsage
@material.T10_24px() // no argument
@material.T10_24px(templ.Attributes{}) // templ.Attributes argumentInstall
go get github.com/dimmerz92/go-icons/radix-icons@latestUsage
@radixicons.Accessibility() // no argument
@radixicons.Accessibility(templ.Attributes{}) // templ.Attributes argumentInstall
go get github.com/dimmerz92/go-icons/simple-icons@latestUsage
@simpleicons.T1001trackLists() // no argument
@simpleicons.T1001trackLists(templ.Attributes{}) // templ.Attributes argumentInstall
go install github.com/dimmerz92/go-icons/cmd/go-icons@latestUsage
Note
The command follows a simple model of go-lucide <LIBRARY>:<FORMAT> <ICON NAME> [OPTIONS]
LIBRARIES: [simple-icons radix-icons ionicons material lucide]
FORMATS: [html templ]
ICON NAMES: depending on the library, some are kebab case, snake case, or not separated.
This is an understandable painpoint, and search functionality will be on the future todos.
OPTIONS:
-out: directory to save icon to. Default: [.]
go-icons lucide:html a-arrow-down -out templates/iconsHTML Icon Usage
The HTML icons are prepared to accept optional attributes on the <svg> tags.
This can easily be done by passing them the template.HTMLAttr data structure.
iconData := []template.HTMLAttr{
`class="some-class another-class"`,
`style="height: 2rem; width: 2rem"`,
}
err := tpls.ExecuteTemplate(w, "a-arrow-down", iconData)<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<p>some text</p>
<!-- expecting data -->
{{ template "worm" . }}
<!-- not expecting data -->
{{ template "fish" }}
</body>
</html>This project is provided under the MIT License
All icons are provided under their respective licenses listed at the top of this document.