Skip to Content
JavaScriptPro PackageInstall

Javascript Pro Package

The Boxicons Pro JavaScript library is a lightweight, framework-agnostic package for generating SVG icons. It provides direct access to 50,000+ variations and supports SVG string generation, DOM manipulation, and auto-replacement.

Installation

To access the Pro registry, configure your .npmrc file with your API key. You can find your key in your Account Settings .

  1. Add the following to your .npmrc:
@boxicons-pro:registry=https://npm.boxicons.com/ //npm.boxicons.com/:_authToken=YOUR_API_KEY

Ensure your API key remains secure. Avoid committing it directly to public repositories; consider using environment variables for CI/CD environments.

  1. Install the main package:
# Using npm npm install @boxicons-pro/js # Using yarn yarn add @boxicons-pro/js # Using pnpm pnpm add @boxicons-pro/js

Quick Start

The library provides multiple ways to render icons.

SVG String Generation

import { createSvgString, Alarm, Home } from '@boxicons-pro/js'; // Simple usage const alarmSvg = createSvgString(Alarm); // With customization const homeSvg = createSvgString(Home, { size: 'lg', fill: '#3b82f6', weight: 'thin' });

Direct SVG Access

Icons are exported as objects containing the path data, allowing for custom rendering logic if needed.

import { Alarm } from '@boxicons-pro/js'; console.log(Alarm.name); // "alarm" console.log(Alarm.paths.basic.regular.normal); // SVG path data string

Performance

The library is fully tree-shakable. When using modern bundlers, only the icons you explicitly import will be included in your final bundle.

Method 1: Named Imports

import { Alarm, Heart } from '@boxicons-pro/js';

Method 2: Granular Packages

import { Alarm } from '@boxicons-pro/js-basic-regular-bold';

Icon Packs

Boxicons Pro includes multiple icon packs:

PackDescription
basicSimple line icons (default)
filledSolid filled icons
duotoneTwo-tone icons with primary and secondary colors
duotone-mixDuotone icons with mixed styling
duotone-solidDuotone icons with solid styling
brandsBrand and logo icons
createSvgString(Alarm, { pack: 'basic' }); createSvgString(Alarm, { pack: 'filled' }); createSvgString(Alarm, { pack: 'duotone' }); createSvgString(Alarm, { pack: 'duotone-mix' }); createSvgString(Alarm, { pack: 'duotone-solid' });

Styles

Each pack (except brands) supports three styles:

StyleDescription
regularDefault rounded corners
roundedMore pronounced rounded corners
sharpSharp, angular corners
createSvgString(Alarm, { style: 'regular' }); createSvgString(Alarm, { style: 'rounded' }); createSvgString(Alarm, { style: 'sharp' });

Weights

Icons come in three weights:

WeightNameDescription
200thinLight, thin strokes
400normalDefault weight (no suffix needed)
700boldHeavy, bold strokes
// Using weight names createSvgString(Alarm, { weight: 'thin' }); createSvgString(Alarm, { weight: 'normal' }); // default createSvgString(Alarm, { weight: 'bold' }); // Using numeric values createSvgString(Alarm, { weight: 200 }); createSvgString(Alarm, { weight: 400 }); createSvgString(Alarm, { weight: 700 });

Duotone Icons

Duotone icons support separate colors and opacities for primary and secondary layers:

createSvgString(Alarm, { pack: 'duotone', primaryFill: '#3b82f6', primaryOpacity: 1, secondaryFill: '#93c5fd', secondaryOpacity: 0.4 });

Props Reference

Common Props

PropTypeDefaultDescription
pack'basic' | 'filled' | 'duotone' | 'duotone-mix' | 'duotone-solid' | 'brands''basic'Icon pack to use
style'regular' | 'rounded' | 'sharp''regular'Icon style variant
weight'thin' | 'normal' | 'bold' | 200 | 400 | 700'normal'Icon stroke weight
sizeIconSize'base'Preset size
widthnumber | string-Custom width (overrides size)
heightnumber | string-Custom height (overrides size)
fillstring'currentColor'Fill color
opacitynumber | string-Overall opacity (0-1)
flip'horizontal' | 'vertical'-Flip direction
rotatenumber | string-Rotation in degrees
removePaddingbooleanfalseRemove icon padding by adjusting viewBox
classNamestring-CSS class name

Duotone-specific Props

PropTypeDefaultDescription
primaryFillstring'currentColor'Primary layer fill color
primaryOpacitynumber | string1Primary layer opacity
secondaryFillstring'currentColor'Secondary layer fill color
secondaryOpacitynumber | string0.4Secondary layer opacity

Testing

Test your Pro icon integration:

import { describe, it, expect } from 'vitest'; import { createSvgString, Alarm } from '@boxicons-pro/js'; describe('Boxicons Pro Integration', () => { it('should support all packs', () => { const basic = createSvgString(Alarm, { pack: 'basic' }); const filled = createSvgString(Alarm, { pack: 'filled' }); const duotone = createSvgString(Alarm, { pack: 'duotone' }); expect(basic).toContain('<svg'); expect(filled).toContain('<svg'); expect(duotone).toContain('<svg'); }); it('should support styles and weights', () => { const svg = createSvgString(Alarm, { style: 'rounded', weight: 'bold' }); expect(svg).toContain('<svg'); }); it('should support duotone colors', () => { const svg = createSvgString(Alarm, { pack: 'duotone', primaryFill: '#3b82f6', secondaryFill: '#93c5fd' }); expect(svg).toContain('fill="#3b82f6"'); }); });

@boxicons-pro/js