Skip to content

Icon

@astryxdesign/core v0.7.1 · Icon

Props ​

NameTypeDefaultDescription
namestring—Iconify id, collection:icon. carbon-settings is the same as carbon:settings after the carbon collection is registered. Hyphenated collection names should keep the colon.
iconstring | Component—A semantic name, a CSS icon class, or your own component. A semantic name resolves to an Iconify id from the nearest theme, and falls back to the built-in glyph until that icon is registered. Ignored when name is set.
color'inherit' | 'primary' | 'secondary' | 'tertiary' | 'disabled' | 'accent' | 'success' | 'error' | 'warning' | 'blue' | 'cyan' | 'green' | 'gray' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow''inherit'Sets the color the icon's currentColor resolves to. inherit keeps the surrounding text color.
size'xsm' | 'sm' | 'md' | 'lg'—12px, 16px, 20px, or 24px at a 16px root. When omitted, a name icon is 1em. Any other icon falls back to md unless a parent provides a size.
labelstring—Accessible name for a meaningful icon. Sets role="img" and aria-label. Omit it for decoration (aria-hidden="true"). An empty string stays decorative.

Slots ​

  • Default: SVG written inline, used when neither name nor icon is set.

Registration ​

NameFromDescription
astryxIcons()@astryx-vue/core/iconsVite plugin. Scans static names and bundles only those icons from installed @iconify-json/* packages. Pass collections to limit which prefixes are read.
addIcon(name, data)@astryx-vue/core/IconRegister one icon. name is collection:icon. data.body is the SVG inner markup.
addCollection(collection)@astryx-vue/core/IconRegister an @iconify-json document. The whole collection is included in the bundle.

Semantic names ​

defineTheme({ icons }) overrides by name. Entries merge shallowly with the theme this one extends, and this theme wins. A name that is not listed keeps the default id. The collection has to be registered, or the built-in glyph stays.

NameDefault Iconify id
closelucide:x
chevronDownlucide:chevron-down
chevronLeftlucide:chevron-left
chevronRightlucide:chevron-right
chevronsLeftlucide:chevrons-left
chevronsRightlucide:chevrons-right
checklucide:check
successlucide:circle-check
errorlucide:circle-x
warninglucide:triangle-alert
infolucide:info
calendarlucide:calendar
clocklucide:clock
externalLinklucide:external-link
menulucide:menu
moreHorizontallucide:ellipsis
searchlucide:search
uploadlucide:upload
arrowUplucide:arrow-up
arrowDownlucide:arrow-down
arrowsUpDownlucide:arrow-up-down
funnellucide:funnel
eyeSlashlucide:eye-off
viewColumnslucide:columns-3
copylucide:copy
checkDoublelucide:check-check
wrenchlucide:wrench
stoplucide:square
microphonelucide:mic
imagelucide:image

These are the shared names. Every component draws from the same set. The IconRegistry type describes a complete registry that draws every shared name, and upload is required like the rest. A theme that supplies a whole icon set must give upload its own upload drawing instead of reusing arrowUp. Redrawing upload leaves the arrowUp used by sortable tables and the send button alone.

An icon that only one component draws does not become a shared name. It gets a namespaced key, component:role, typed as NamespacedIconName. There is one today:

KeyUsed by
numberInput:stepperDownNumberInput's step buttons. A small down chevron; the increment button flips it.

A theme overrides it through the same icons map: defineTheme({ icons: { 'numberInput:stepperDown': 'carbon:chevron-down' } }). Without an override the built-in glyph is drawn. Adding a namespaced key never adds a required entry to IconRegistry.

useSemanticIcon(name) comes from @astryx-vue/core/Icon and from the package root. An unknown string with no theme entry returns empty, so the caller can still treat it as a CSS class.

Theme ​

Color follows the icon tokens. A theme replaces one by setting the variable on the theme root.

css
.my-theme {
  --astryx-icon-accent-foreground: #0074e2;
}
  • --astryx-icon-primary-foreground
  • --astryx-icon-secondary-foreground
  • --astryx-icon-disabled-foreground
  • --astryx-icon-accent-foreground
  • --astryx-icon-success-foreground
  • --astryx-icon-error-foreground
  • --astryx-icon-warning-foreground
  • --astryx-icon-blue-foreground, and the same pattern for cyan, green, gray, orange, pink, purple, red, teal, and yellow.

Accessibility ​

The root is a <span>. Without label it is aria-hidden="true". With a non-empty label it is role="img" and that string is the accessible name. The SVG inside is always aria-hidden.

class and style fall through to the root. name does not: it selects the icon.