Skip to content

Custom icon set support - #20277

Merged
brandonkelly merged 3 commits into
5.12from
custom-icon-sets
Nov 2, 2026
Merged

brandonkelly merged 3 commits into
5.12from
custom-icon-sets

Conversation

@brandonkelly

@brandonkelly brandonkelly commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Icon pickers can now include custom icon sets alongside Font Awesome. Resolves the request in #17101.

Registering sets
  craft\services\Icons::EVENT_REGISTER_ICON_SETS  → plugins/modules add craft\icons\IconSet instances
                                                    (handle, name, getIcons(), getSvg(), getKeywords())
  customIconPath config setting                   → registers a “Custom” set from a directory of SVGs
                                                    (e.g. CRAFT_CUSTOM_ICON_PATH=@config/icons)

Stored values
  chevron-right          ← Font Awesome (unchanged)
  custom:width-half      ← set-handle:icon-name

Pickers
  Icon fields            → new sortable “Icon Sets” setting (shown when custom sets exist; Font Awesome only by default)
                           “Include Pro icons” hides when Font Awesome is deselected
  Entry types, option    → all sets, Font Awesome first
  icons, custom sources

Rendering / output
  Cp::iconSvg('set:icon')           → sanitized + ID-namespaced SVG from the set
  entry.icon.set / .getSvg() / .getKeywords()
  GraphQL “Full data” mode          → IconData { name styles set svg keywords }
  GraphQL “Name only” mode          → name only (no set handle)

Evidence

Icon field settings: new sortable “Icon Sets” setting

Icon Sets setting

Icon picker modal

Custom set only Custom + Font Awesome Searching “width”
Picker limited to the Custom set Picker with Custom and Font Awesome headings Search results across both sets

Entry edit page: custom icons in an Icon field and Button Group option icons

Entry with custom icons

GraphQL (one field in each mode, against a real install)

"nameOnlyIcon": "width-full",
"fullIcon": { "name": "width-full", "set": "custom", "styles": [], "keywords": [], "svg": "<svg …" },
"faIcon":   { "name": "star", "set": null, "styles": ["solid", …], "keywords": ["achievement", "award", …], "svg": "<svg …" }

Tests: new tests/unit/services/IconsTest.php (12 tests) covers value parsing (Windows paths, aliases, and SVG markup aren’t treated as set:icon), customIconPath registration and rendering, Icon field value round-tripping, getSvg()/getKeywords(), and Icon Sets validation.

Related issues

brandonkelly and others added 3 commits November 2, 2026 17:11
Icon pickers can now include icons from custom icon sets, which are
registered via craft\services\Icons::EVENT_REGISTER_ICON_SETS, or via the
new customIconPath config setting (registers a "Custom" set from a
directory of SVGs).

Icons from custom sets are stored as set-handle:icon-name; Font Awesome
icons are still stored as bare names. Icon fields get a sortable
"Icon Sets" setting, and their values get a `set` property along with
getSvg() and getKeywords() methods, which are also exposed via GraphQL in
"Full data" mode.

Refs #17101

Amp-Thread-ID: https://ampcode.com/threads/T-38d32f90-9202-488b-ac7e-a86581f667ef
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-38d32f90-9202-488b-ac7e-a86581f667ef
Co-authored-by: Amp <amp@ampcode.com>

# Conflicts:
#	CHANGELOG-5.12.md
#	src/web/assets/cp/dist/cp.js
#	src/web/assets/cp/dist/cp.js.map
@brandonkelly
brandonkelly merged commit 34d592d into 5.12 Nov 2, 2026
11 checks passed
@brandonkelly
brandonkelly deleted the custom-icon-sets branch November 2, 2026 17:45
brandonkelly added a commit that referenced this pull request Nov 2, 2026
Ports the 5.12 changes to 6.x:

- Color fields support translucent colors: palette colors can have an
  alpha channel, custom colors can too via the new "Allow opacity for
  custom colors" setting, and ColorRule/ColorData gained alpha support
  plus rgba/hsla/oklch/contrast helpers. Color fields also have a
  "GraphQL Mode" setting with a new ColorData GraphQL type (#20274)
- Custom icon sets (#20277): a `customIconPath` config setting,
  CraftCms\Cms\Cp\IconSets with an IconSetsResolving event, an "Icon
  Sets" Icon field setting, `set-handle:icon-name` values, and icon
  picker results grouped by set. The Yii2 adapter provides
  craft\services\Icons, RegisterIconSetsEvent, and craft\icons\* shims
- "Save as a new draft" carries nested entries over to the new draft,
  keeping modified-field tracking for doubly nested edits (#20226)

5.x's jQuery IconPicker/ColorInput, Twig templates, and Yii controllers
were deleted in 6.x, so their changes were ported to the Vue/Lit
components, UI controls, and Laravel controllers instead. The pinned
CDT time zone test has no 6.x counterpart, and composer.json already
allowed php-http/discovery.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-a65e3cbd-ffa2-4795-ab74-481b29563ebe
@linear-code

linear-code Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

CMS-2618

@brandonkelly brandonkelly mentioned this pull request Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant