### Clone and Set Up Bootstrap Icons Development Environment
Source: https://github.com/twbs/icons/blob/main/README.md
Clone the Bootstrap Icons repository, install its dependencies, and start the local development server to view the documentation and test changes.
```shell
git clone https://github.com/twbs/icons/
cd icons
npm i
npm start
```
--------------------------------
### Install Bootstrap Icons with npm
Source: https://github.com/twbs/icons/blob/main/README.md
Use this command to install Bootstrap Icons as a dependency in your project via npm.
```shell
npm i bootstrap-icons
```
--------------------------------
### Install Bootstrap Icons with Composer
Source: https://github.com/twbs/icons/blob/main/README.md
For projects using Packagist, install Bootstrap Icons using Composer with this command.
```shell
composer require twbs/bootstrap-icons
```
--------------------------------
### Include via CDN
Source: https://context7.com/twbs/icons/llms.txt
Reference the icon font stylesheet from the jsDelivr CDN to use icons without local installation.
```html
```
```css
/* Or import in CSS */
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css");
```
--------------------------------
### Include Bootstrap Icons via CDN (Stylesheet)
Source: https://github.com/twbs/icons/blob/main/docs/content/_index.md
Link the Bootstrap Icons stylesheet from jsDelivr in your HTML's `
` to quickly start using icon fonts. Ensure the version parameter matches your desired Bootstrap Icons version.
```html
```
--------------------------------
### Development Build Scripts for Bootstrap Icons
Source: https://context7.com/twbs/icons/llms.txt
Utilize npm scripts for building icons, generating fonts, and running the documentation site locally. These scripts cover tasks from optimization to release preparation.
```bash
# Start local documentation server
npm start
# or
npm run docs-serve
# Process and optimize SVG icons, generate fonts and sprite
npm run icons
# Generate permalink pages for each icon
npm run pages
# Build documentation site
npm run docs-build
# Create release ZIP file
npm run icons-zip
# Run all tests
npm test
```
--------------------------------
### Configure Icons with Sass
Source: https://context7.com/twbs/icons/llms.txt
Define the font directory path and import the Bootstrap Icons Sass file to support module bundlers. Use @extend or map-get for custom icon styling.
```scss
// Configure the font directory path for your project structure
$bootstrap-icons-font-dir: "bootstrap-icons/font/fonts";
// Import the Bootstrap Icons Sass file
@import "bootstrap-icons/font/bootstrap-icons";
// Custom icon styling
.custom-icon {
@extend .bi;
font-size: 1.5rem;
color: var(--bs-primary);
}
// Using the icon map for dynamic content
.status-icon::before {
font-family: "bootstrap-icons" !important;
content: map-get($bootstrap-icons-map, "check-circle-fill");
}
```
--------------------------------
### Build and Copy JavaScript Assets with Hugo
Source: https://github.com/twbs/icons/blob/main/docs/layouts/partials/scripts.html
Builds JavaScript files using esbuild with specified options and copies them to the assets directory. This is done conditionally for the search page in production and always for the application script.
```gohtml
{{- if or .IsHome (eq .Page.Layout "sprite") -}} {{- $searchJs := resources.Get "js/search.js" | js.Build $esbuildOptions | resources.Copy "/assets/js/search.js" -}} {{- end }} {{- $application := resources.Get "js/application.js" | js.Build $esbuildOptions | resources.Copy "/assets/js/application.js" -}}
```
--------------------------------
### Use External Images
Source: https://context7.com/twbs/icons/llms.txt
Reference individual SVG files via tags. This is ideal for static icons that do not require dynamic color changes.
```html
```
--------------------------------
### Configure esbuild Options in Hugo
Source: https://github.com/twbs/icons/blob/main/docs/layouts/partials/scripts.html
Sets esbuild options, targeting ES2019 and enabling minification in production environments. This configuration is used for building JavaScript assets.
```gohtml
{{- $esbuildOptions := dict "target" "es2019" -}} {{- if eq hugo.Environment "production" -}} {{- $esbuildOptions = merge $esbuildOptions (dict "minify" "true") -}} {{- end -}}
```
--------------------------------
### Configure Sass for Bootstrap Icons
Source: https://github.com/twbs/icons/blob/main/docs/content/_index.md
Adjust the font directory variable and import the library to ensure correct path resolution in build tools like Vite or Parcel.
```scss
// Update the import directory to point to it‘s location within node_modules
$bootstrap-icons-font-dir: "bootstrap-icons/font/fonts";
// Import the Sass files as usual
@import "bootstrap-icons/font/bootstrap-icons";
```
--------------------------------
### Implement Accessible Icons
Source: https://github.com/twbs/icons/blob/main/docs/content/_index.md
Provide text alternatives for meaningful icons or hide decorative ones using aria-hidden.
```html
```
```html
```
```html
```
--------------------------------
### Use SVG Sprite with