Skip to content

Icons

Iridium uses lucideicons to provide icons. A dump of all icons is stored as templ components you can call throughout your application. This is tree-shaken based on your includes to keep the binary size down.

Icon list

Please refer to lucideicons to search for the icon of your choice.

Icons

Iridium's icons are stored globally to allow you to call on them directly without a method call. For example:

go
import "github.com/iridiumgo/iridium/view/icon/icons"

icons.Anvil // This is a global ptr to the anvil icon

Customizing Icons

Icons have a series of methods that allow you to customize them.

Size

go
icons.Anvil.Size("xs")

// There is also an enum for you to use:
icons.Anvil.Size(icons.SizeXS)

The supported sizes are:

  • xxs
  • xs
  • sm
  • md
  • lg
  • xl
  • xxl

Stroke

Stroke applies the stroke color to the icon.

go
icons.Anvil.Stroke("red")

StrokeWidth

StrokeWidth applies the stroke width to the icon.

go
icons.Anvil.StrokeWidth("2")

Attributes

Attributes allows you to add custom attributes to the icon.

go
icons.Anvil.Attributes(map[string]any{
    "@click" : "alert('You just clicked this anvil!'),
})

Class

Class is a convience method to apply a class attribute to the icon.

go
icons.Anvil.Class("text-red-500")

Component

Component returns the underlying templ component for this icon. This is useful when creating your own templ files where you want access to Iridium's icons.

go
templ MyComponent() {
    @icons.Anvil.Component()
}

Global customization

Because icons are stored globally, you can directly mutate them to affect all instances of that specific icon. For example, if you want a specific icon to always be a different size, you can do the following:

go
icons.Anvil.GlobalSize("xs")

// Elsewhere...
icons.Anvil // a call here will also have it size set to xs

Global Size

GlobalSize sets the global size for this icon:

go
icons.Anvil.GlobalSize("xs")

GlobalStroke

GlobalStroke sets the global stroke for this icon:

go
icons.Anvil.GlobalStroke("red")

GlobalStrokeWidth

GlobalStrokeWidth sets the global stroke width for this icon:

go
icons.Anvil.GlobalStrokeWidth("2")

GlobalAttributes

GlobalAttributes sets the global attributes for this icon:

go
icons.Anvil.GlobalAttributes(map[string]any{
    "@click" : "alert('You just clicked this anvil!')",
})

Global Class

GlobalClass is a convience method to apply a class attribute to the icon globally.

go
icons.Anvil.GlobalClass("text-red-500")

Future

Iridium will support different icon packs & allow you to drop in your own in the future. For now, you are limited our templ components derived from lucideicons.

Released under the MIT License.