Icon handbook
v2.3.4 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Display SVG icons with consistent size and color in buttons, navigation, and content.
When to use it
Use Icon as a consistent host for icons and sizing. Prefer SnowUI resource icons. For an action, place Icon inside Button and give the button an accessible name.
Prefer resource icons. Render
childrenonly when neithersrcnor a resolvediconis available.Size can inherit the parent size; the corner label uses Badge as="badge". The interaction name should be provided to the button that owns the operation.
The
Icon as="leading"in Accordion inherits the Accordion icon size whensizeis not explicitly specified: sm/md/lg are 16/20/24 respectively; Icon that does not declare leading does not participate in this inheritance, and the explicitsizetakes precedence.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
Layout model
Main layout model: internal atomic layout.
The root node of Icon is an inner box jointly determined by
size,backgroundpadding and icon resources, which is expressed as Hug as other layout sub-items.as="leading" / "trailing" / "icon" / "badge" / "prev" / "next" / "close"only declares the role of Icon in the external host; when entering the Image / ImageViewer host, it will be translated by the host context to the correspondingpin-*direction.Background, empty space, badge overlay, and resource rendering are Icon’s private layout; Icon does not expose general slots.
When icons and text are required externally, the host components such as Button, MenuItem and Frame should be responsible for gap / padding / alignment.
stateIcon Parsing rules
Iconreads thecurrentStateof the recent parent Frame Context.Use this icon when the current state hits
stateIcon[currentState].If the current state has no match, fall back to
stateIcon.Idle.If still unresolved, use the normal
icon,src, orchildrenrule.Icon is hidden when the status value is
null, which is used for stable structure state streams such asIdlewithout icon andPendingshowing Spinner.stateIcononly affects the display of Icon itself and does not modify the parent Frame state.
Loadis the status name of the Frame loading / skeleton protocol. If only the button task is being processed and the real Spinner needs to be displayed,Pendingis preferred.
Usage examples
Subcomponent context (Context)
Icon provides adaptive positioning context for subcomponents (such as Badge or another Icon):
badgeStyle: em-based absolute positioning keeps a badge aligned to the icon’s outer corner.badgeSize: default dot size (0.25em).
- size and weight are passed down by Icon; an explicit child icon value takes precedence (not recommended).
Icon style overlay
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
Icon type and status
Required Props: no named required Props.
Bindable Props: this component declares no named two-way binding; handle state updates through public callbacks or its host.
Inheritance: FrameProps. Consult the base class public documentation; fields excluded by Omit cannot be passed through unchanged.
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
StateValueMap
Source: components/src/logic/frame-types.ts
CoreState
Source: components/src/logic/frame-types.ts
IconSize
Source: components/src/components/Icon.svelte