gg_icon/icon
gg_icon — the set-agnostic icon interface every gg_icons_* package builds
on. It holds the size scale, the shared svg wrapper (generic over viewBox
- per-variant defaults, so it serves stroke and fill variants), and the
authoring
placeholder. It never imports a concrete icon set and ships no Tailwind — keeping it a lean, dual-target foundation.
See dev-docs/icons.md in the gg_ui repo for the full design.
Types
Typed icon sizes. Each maps to a cn-icon-size-* class whose name carries
the size- token, so an explicit size defeats a container’s
[&_svg:not([class*='size-'])] default (the idiom shadcn and our own button
recipes already use). Sizing is fully orthogonal to set/variant.
pub type Size {
Sm
Md
Lg
}
Constructors
-
Sm -
Md -
Lg
Values
pub fn fallback_box(
attrs: List(attribute.Attribute(msg)),
) -> element.Element(msg)
A neutral rounded square — the placeholder’s no-resolver fallback, and a visible “icon would go here” marker in un-transformed previews.
pub fn placeholder(
lucide lucide: String,
tabler tabler: String,
attrs attrs: List(attribute.Attribute(msg)),
) -> element.Element(msg)
Authoring placeholder used in registry source. The (future) CLI transformer
replaces each call with a direct <shard>.<icon>(attrs) for the user’s
chosen set/variant, so this never reaches a shipped bundle. Until then — and
in any non-transformed runtime — it renders a neutral fallback box.
Storybook’s live preview will inject a resolver here so embedded icons
(a dialog-close x) switch with the toolbar; that wiring lands with the
apps/storybook demo catalog and keeps gg_icon set-agnostic.
pub fn size(size: Size) -> attribute.Attribute(msg)
A class attribute selecting a named size. Pass it in an icon’s attrs:
lucide.star([icon.size(icon.Lg)]). For a one-off, pass a raw
attribute.class("size-[18px]") instead — it wins by source order.
pub fn svg(
view_box view_box: String,
defaults defaults: List(#(String, String)),
attrs attrs: List(attribute.Attribute(msg)),
children children: List(element.Element(msg)),
) -> element.Element(msg)
Build an icon <svg>. Generated icon functions call this with their
variant’s view_box + defaults (e.g. fill=none stroke=currentColor for
an outline variant, fill=currentColor for a filled one). attrs is
appended last so caller overrides win by source order. Everything stays
currentColor, so color / text-* drive the colour and size /
size-* drive the size.