### Install Dependencies and Build Source: https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md Install project dependencies using npm and run the initial build. This ensures your development environment is set up correctly. ```bash npm install npm run build ``` -------------------------------- ### Install and Use LTS Node.js Version Source: https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md Installs the latest Long Term Support (LTS) version of Node.js and sets it as the active version. This is a common step in environment setup. ```bash nvm install --lts && nvm use --lts ``` -------------------------------- ### Clone and Setup Ionicons Repository Source: https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md Clone your fork of the Ionicons repository and set up the upstream remote. This is the first step in setting up your local development environment. ```bash git clone https://github.com/YOUR-USERNAME/ionicons.git cd ionicons git remote add upstream https://github.com/ionic-team/ionicons.git ``` -------------------------------- ### Install Ionicons via NPM Source: https://context7.com/ionic-team/ionicons/llms.txt Install the ionicons package for use in bundled projects like React, Vue, or Angular. ```bash npm install ionicons ``` -------------------------------- ### Preview ion-icon Component Locally Source: https://github.com/ionic-team/ionicons/blob/main/scripts/readme.md Start a local development server to preview the `ion-icon` component in action. This is useful for testing icon rendering and component behavior. ```sh npm start ``` -------------------------------- ### Install Node Version Manager (macOS/Linux) Source: https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md Installs nvm, a Node.js version manager, using a curl script. Recommended for managing Node.js versions on macOS and Linux. ```bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash ``` -------------------------------- ### Install Ionicons Web Component Source: https://github.com/ionic-team/ionicons/blob/main/readme.md Include these scripts to enable the Ionicons web component. Replace 'latest' with a specific version if needed. ```html ``` ```html ``` -------------------------------- ### Update Branch from Upstream Source: https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md Before starting new work or to keep your branch up-to-date, pull the latest changes from the upstream repository and create a new feature branch. ```bash git checkout main git pull upstream main git checkout -b your-feature-branch ``` -------------------------------- ### Internal SVG Sanitization Logic Source: https://context7.com/ionic-team/ionicons/llms.txt This TypeScript comment outlines the internal sanitization process: ` ``` -------------------------------- ### Build Ionicons Locally Source: https://github.com/ionic-team/ionicons/blob/main/scripts/readme.md Run this command after updating, adding, or deleting SVGs in the `src/svg` directory. It optimizes all icons and generates distribution files in the `dist` directory. ```sh npm run build ``` -------------------------------- ### Basic Ionicons Usage Source: https://github.com/ionic-team/ionicons/blob/main/readme.md Use the 'name' attribute to display a built-in icon from the Ionicons package. ```html ``` -------------------------------- ### Configure Custom Asset Path and Load Icons Source: https://github.com/ionic-team/ionicons/blob/main/readme.md Set the base path for loading custom icons and explicitly add specific icons using 'setAssetPath' and 'addIcons'. ```typescript import { setAssetPath, addIcons } from 'ionicons'; import { add, logoIonic, save } from 'ionicons/icons'; // set root path for loading icons to "/public/svg" setAssetPath(`${window.location.origin}/public/svg/`); // only load specific icons addIcons({ add, logoIonic, save }); ``` -------------------------------- ### Set Icon Size Source: https://context7.com/ionic-team/ionicons/llms.txt Apply pre-defined size tokens (`small`, `large`) or use CSS for arbitrary sizing. The `font-size` CSS property controls the icon size. ```html ``` -------------------------------- ### Render Built-in Icons by Name Source: https://context7.com/ionic-team/ionicons/llms.txt Renders a built-in icon using its kebab-case name. Ionicons automatically resolves the correct SVG asset path. ```html ``` -------------------------------- ### Enable Lazy Loading for `` Source: https://context7.com/ionic-team/ionicons/llms.txt Defer SVG network requests until icons scroll into the viewport by setting `lazy="true"`. This is useful for improving performance in long lists or virtualized tables. ```html ``` -------------------------------- ### Release Ionicons Source: https://github.com/ionic-team/ionicons/blob/main/scripts/readme.md Execute the release script to prepare and publish a new version of Ionicons. This script will prompt for versioning and tagging information. ```sh npm run release ``` -------------------------------- ### Rebuild SVG Icon Files Source: https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md Use this command to re-run the SVG optimization script. This is useful for verifying changes after optimizing SVGs. ```bash npm run build.files ``` -------------------------------- ### Ionicons Icon Sizing (CSS) Source: https://github.com/ionic-team/ionicons/blob/main/readme.md Set a specific icon size using the 'font-size' CSS property. Pixel sizes that are multiples of 8 are recommended. ```css ion-icon { font-size: 64px; } ``` -------------------------------- ### Ionicons Icon Sizing (Pre-defined) Source: https://github.com/ionic-team/ionicons/blob/main/readme.md Use the 'size' attribute for pre-defined font sizes like 'small' or 'large'. ```html ``` -------------------------------- ### Create a New Feature Branch Source: https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md Create a new branch from the main branch to isolate your changes. This is part of the recommended branch strategy for contributions. ```bash git checkout -b your-feature-branch ``` -------------------------------- ### Pre-register Icons with `addIcons` Source: https://context7.com/ionic-team/ionicons/llms.txt In custom-elements or tree-shaken builds, use `addIcons` to map icon names (camelCase or kebab-case) to their SVG data-URL strings. This avoids network fetches for icons used in templates. ```typescript import { addIcons } from 'ionicons'; import { heart, heartOutline, heartSharp, logoIonic, addCircleOutline } from 'ionicons/icons'; // Register specific icons — both camelCase and kebab-case names are accepted addIcons({ heart, heartOutline, // also registered as "heart-outline" heartSharp, // also registered as "heart-sharp" logoIonic, // also registered as "logo-ionic" addCircleOutline // also registered as "add-circle-outline" }); // Now usable by name in templates — no network fetch required // // // ``` -------------------------------- ### Custom Icon Usage Source: https://github.com/ionic-team/ionicons/blob/main/readme.md Provide the URL to an external SVG file in the 'src' attribute to use a custom icon. The SVG must be accessible and cannot contain scripts. ```html ``` -------------------------------- ### Display Outline Icon Source: https://github.com/ionic-team/ionicons/blob/main/readme.md Use the `name` attribute to specify the icon to display. For outline variants, the stroke width can be adjusted. ```html ``` -------------------------------- ### Ionicon Properties Source: https://github.com/ionic-team/ionicons/blob/main/src/components/icon/readme.md This section details the available properties for the ion-icon component, which control its appearance, behavior, and the icon source. ```APIDOC ## Properties | Property | Attribute | Description | Type | Default | | ---------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | -------------- | | `color` | `color` | The color to use for the background of the item. | `string \| undefined` | `undefined` | | `flipRtl` | `flip-rtl` | Specifies whether the icon should horizontally flip when `dir` is `"rtl"`. | `boolean \| undefined` | `undefined` | | `icon` | `icon` | A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property. | `any` | `undefined` | | `ios` | `ios` | Specifies which icon to use on `ios` mode. | `string \| undefined` | `undefined` | | `lazy` | `lazy` | If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`. | `boolean` | `false` | | `md` | `md` | Specifies which icon to use on `md` mode. | `string \| undefined` | `undefined` | | `mode` | `mode` | The mode determines which platform styles to use. | `string` | `getIonMode()` | | `name` | `name` | Specifies which icon to use from the built-in set of icons. | `string \| undefined` | `undefined` | | `sanitize` | `sanitize` | When set to `false`, SVG content that is HTTP fetched will not be checked if the response SVG content has any `