Badge Columns
A badge column allow you to render a badge within your table
You can create a badge column as so:
go
BadgeColumn("my-badge")Prefix Icon
The PrefixIcon method allows you to specify an icon to preceed the text of your badge:
go
import "github.com/iridiumgo/iridium-icons/icon/icons"
// static
BadgeColumn("my-badge").
PrefixIcon(icons.Atom)
// callback
BadgeColumn("my-badge").
PrefixIconFn(
func (ctx CellContext) *icon.Icon {
return icons.Email
}
)Postfix Icon
The PostfixIcon method allows you to specify and icon to proceed the text of your badge:
go
import "github.com/iridiumgo/iridium-icons/icon/icons"
// static
BadgeColumn("my-badge").
PostfixIcon(icons.Atom)
// callback
BadgeColumn("my-badge").
PostfixIconFn(
func (ctx CellContext) *icons.Icon {
return icons.Email
}
)Variant
The Variant method allow you to specify the style/colour of the badge.
There are 5 supported variants:
- BadgeDefault
- BadgePrimary
- BadgeSecondary
- BadgeDestructive
- BadgeOutline
go
import "github.com/iridiumgo/iridium/core/table/column/components/config"
// static
BadgeColumn("my-badge").
Variant(config.BadgePrimary)
// callback
BadgeColumn("my-badge").
VariantFn(
func (ctx CellContext) config.BadgeVariant {
return config.BadgeOutline
}
)CustomColor
The CustomColor method allows you to define a custom colour.
You can see more about that here
go
// static
BadgeColumn("my-badge").
CustomColor("background-color: #ff0000")
// callback
BadgeColumn("my-badge").
CustomColourFn(
func (ctx CellContext) string {
return "background-color: #000000"
}
)