• CMSnpm version

    • Overview
    • ContentBuilder
    • InviteUserForm
    • LoginForm
    • RenewPasswordForm
  • UInpm version

    • Overview
    • Accordion
    • AlertBubble
    • AnnouncementBar
    • Avatar
    • AvatarFileInput
    • Badge
    • Button
    • ButtonGroup
    • ButtonList
    • Calendar
    • Checkbox
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • Chip
    • ColorRadio
    • ColorRadioGroup
    • Combobox
    • DatePicker
    • DatePickerInput
    • DateRangePicker
    • DateRangePickerInput
    • DatetimePicker
    • DatetimePickerInput
    • Dialog
    • Dropdown
    • Dropzone
    • ErrorMessage
    • FileInput
    • FlashMessages
    • FormComponent
    • Icon
    • IconButton
    • ImageGallery
    • InfoBox
    • Input
    • Label
    • Layout
    • Lightbox
    • ListItem
    • Loader
    • Lozenge
    • Menu
    • Message
    • Modal
    • ✅ ModalDialog
    • ✅ ModalHeader
    • MultiCombobox
    • MultiSelect
    • Pagination
    • Paper
    • Popover
    • Radio
    • RadioGroup
    • RasterImage
    • Select
    • ✅ Tabs
    • TextInput
    • TextLink
    • Textarea
    • TimePicker
    • TimePickerInput
    • Toggle
    • Tooltip
    • Typography
  • Formnpm version

    • Overview
    • AvatarFileInput
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • ColorRadioGroup
    • Combobox
    • DatePickerInput
    • DateRangePickerInput
    • DatetimePickerInput
    • Dropzone
    • FileInput
    • Form
    • FormRenderer
    • GpsInput
    • MoneyInput
    • MultiCombobox
    • MultiSelect
    • NumberInput
    • PasswordInput
    • RadioGroup
    • Select
    • TextInput
    • Textarea
    • TimePickerInput
    • Toggle
  • DataGridnpm version

    • Overview
    • DataGrid
    • DataGridCustomExample
    • ExportButton
    • FilterList
    • Filters
    • FiltersButton
    • FulltextInput
    • HiddenColumns
    • HiddenColumnsButton
    • Pagination
    • RowCounts
    • RowsPerPageSelect
    • SelectedRowsToolbar
    • TableV2
    • ToolbarControl
    • ToolbarCustoms
    • ToolbarTabs
  • Wysiwygnpm version

    • Overview
  • Resizernpm version

    • Overview
  • Routernpm version

    • Overview
  • Corenpm version

    • Overview
  • Core-Reactnpm version

    • Overview
  • Stylesnpm version

    • Overview
  • Localizenpm version

    • Overview
  • Analyticsnpm version

    • Overview
  • Datepickernpm version

    • Overview
  • Icons-generatornpm version

    • Overview
  • Smart-addressnpm version

    • Overview
  • E2Enpm version

    • Overview
  • E2E-Playwrightnpm version

    • Overview
View source on GitLab

Icon

Renders an SVG icon — either from the app's icon sprite (by name) or from a custom SVG component (Component).

When to use

Use Icon wherever you need a vector icon. Pass name to render a sprite icon from the app's generated icon set; pass Component to render a one-off custom SVG with the same sizing/aspect-ratio behaviour. Exactly one of the two is required.

There is no @uxf/form twin — Icon is a display primitive.

Usage

import { Icon } from "@uxf/ui/icon";

// sprite icon by name
<Icon name="camera" size={16} />

// tinted via a Tailwind text color
<Icon className="text-primary-600" name="camera" size={12} />

// custom SVG component instead of a sprite icon
<Icon Component={MyGlyph} size={16} />

Props

IconProps accepts exactly one of name / Component (a discriminated union), plus:

Prop Type Default Description
name IconName — Sprite icon id. Required unless Component is set; mutually exclusive with it.
Component FunctionComponent<AnyObject> — Custom SVG component to render instead of a sprite icon. Required unless name is set; mutually exclusive with it.
size number — Icon size in px (converted to rem, drives --i-w / --i-h). When omitted, size comes from CSS.
color IconColor — Named color; adds a uxf-icon--color-* class.
mode "meet" | "slice" "meet" SVG preserveAspectRatio mode.
aria-label string — Accessible label. role="img" is always set.
className string — Extra class on the rendered SVG.
style CSSProperties — Inline style (merged with the size CSS variables).

Icon forwards its ref to the underlying SVGSVGElement.

Icon name typing

IconName is keyof IconsSet, and IconsSet (exported from @uxf/ui/icon/theme, re-exported from @uxf/ui/icon) is an open interface whose base declaration is a string index signature ([key: string]: true). Each project extends it by module augmentation to enumerate the icons it actually ships — normally generated, alongside the runtime config and sprite, by @uxf/icons-generator into a icons.d.ts:

// icons.d.ts (generated)
declare module "@uxf/ui/icon/theme" {
    interface IconsSet {
        camera: true;
        chevronLeft: true;
        // …
    }
}

Because of the base index signature, name accepts any string at the type level. Validation happens at runtime: if name is not present in the configured iconsConfig, Icon logs a console.warn and renders a fallback question-mark glyph.

Variants & states

Built-in color values (from theme.ts), mapped to the token color layer:

Group Values
color default, positive, negative, warning, info
<Icon color="negative" name="camera" size={16} />

Requirements

Import the component stylesheet once in your global CSS:

@import url("@uxf/ui/css/icon.css");

Sprite (name) rendering reads the sprite path and icon config from UiContextProvider (@uxf/ui/context), so the component must render inside it:

import { UiContextProvider } from "@uxf/ui/context";
import { ICONS } from "./generated/icons";

<UiContextProvider
    value={{
        icon: { iconsConfig: ICONS, spriteFilePath: "/icons-generated/_icon-sprite.svg" },
        // …other context options
    }}
>
    {children}
</UiContextProvider>;

Component-based icons do not need the sprite or icon config.

Also requires the global @uxf/ui token layer, set up once per app — see @uxf/ui setup.

Links

  • @uxf/icons-generator — generates the icon sprite, runtime config, and IconsSet type augmentation.
AllIcons
Open in new tab
ColorAndSizes
Open in new tab
CustomComponent
Open in new tab
SpriteIcon
Open in new tab
SpriteIconNotExists
Open in new tab