toggle-character


目录

title: Assign character to icon in icon set
types:
  IconSet: './index.md'
  IconifyJSON: '/docs/types/iconify-json.md'
functions:
  chars: './chars.md'
  entries: './entries.md'

toggleCharacter()

This function is part of [type]IconSet class in Iconify Tools.

Function [func]toggleCharacter() adds character to icon or removes it.

Usage

Function has the following parameters:

Function returns true on success, false on failure.

Character map

What is the purpose of characters map?

It is used to generate icon fonts. Each icon in an icon font has a character assigned to it. Even when using ligatures, ligatures point to a character, so character is needed.

How to find all characters? {#chars}

You can get list of all assigned characters by using [func]chars() method.

If you want to know characters assigned to an icon, use code like this:

const item = iconSet.entries['some-icon'];
// Set<string>
console.log(item.chars);

It is safe to modify characters directly in [func]entries property.

Example

src: libraries/tools/icon-set/chars.ts
title: 'chars-example.ts'

版本号 #2
由 壳壳虫 创建于 2026-10-31 14:25:44 UTC
由 壳壳虫 更新于 2026-10-31 14:25:45 UTC