React Pro Package
The Boxicons Pro React package provides over 50,000 icon variations as highly optimized, tree-shakable components. It’s the most efficient way to use Boxicons in modern React applications.
Installation
To access the Pro registry, you must first configure your .npmrc file with your API key. You can find your key in your Account Settings .
- Add the following to your
.npmrc:
@boxicons-pro:registry=https://npm.boxicons.com/
//npm.boxicons.com/:_authToken=YOUR_API_KEY- Install the main package:
# Using npm
npm install @boxicons-pro/react
# Using yarn
yarn add @boxicons-pro/react
# Using pnpm
pnpm add @boxicons-pro/reactEnsure your API key remains secure. Avoid committing it directly to public repositories; consider using environment variables for CI/CD environments.
Quick Start
import { Alarm, Home, User } from '@boxicons-pro/react';
function App() {
return (
<div>
<Alarm size="lg" />
<Home weight="thin" color="#3b82f6" />
<User pack="filled" style="rounded" />
</div>
);
}Performance & Tree-Shaking
The package supports multiple import methods to suit your development and production needs.
Method 1: Named Imports (Best for DX)
Ideal for development. Modern bundlers (Vite, Webpack 5) will tree-shake unused icons in production, though initial dev build times may be slightly longer.
import { Alarm, Home } from '@boxicons-pro/react';Method 2: Direct Imports (Best for cold-start performance)
Guarantees that only the code for the specific icon is loaded, bypassing the barrel file entirely.
import { Alarm } from '@boxicons-pro/react/icons/Alarm';Method 3: Granular Packages (Best for bundle size)
If your project only uses a specific style (e.g., Rounded-Bold), you can install that variant specifically to minimize the dependency graph.
import { Alarm } from '@boxicons-pro/react-basic-rounded-bold';Icon Packs
Boxicons Pro includes multiple icon packs:
| Pack | Description |
|---|---|
basic | Simple line icons (default) |
filled | Solid filled icons |
duotone | Two-tone icons with primary and secondary colors |
duotone-mix | Duotone icons with mixed styling |
duotone-solid | Duotone icons with solid styling |
brands | Brand and logo icons |
<Alarm pack="basic" />
<Alarm pack="filled" />
<Alarm pack="duotone" />
<Alarm pack="duotone-mix" />
<Alarm pack="duotone-solid" />Styles
Each pack (except brands) supports three styles:
| Style | Description |
|---|---|
regular | Default rounded corners |
rounded | More pronounced rounded corners |
sharp | Sharp, angular corners |
<Alarm style="regular" />
<Alarm style="rounded" />
<Alarm style="sharp" />Weights
Icons come in three weights:
| Weight | Name | Description |
|---|---|---|
| 200 | thin | Light, thin strokes |
| 400 | normal | Default weight (no suffix needed) |
| 700 | bold | Heavy, bold strokes |
// Using weight names
<Alarm weight="thin" />
<Alarm weight="normal" /> // default
<Alarm weight="bold" />
// Using numeric values
<Alarm weight={200} />
<Alarm weight={400} />
<Alarm weight={700} />Naming Convention
Icon names are converted from kebab-case SVG filenames to PascalCase:
| SVG File | Component Name |
|---|---|
bx-alarm.svg | <Alarm /> |
bx-alarm-clock.svg | <AlarmClock /> |
bx-twitter.svg | <Twitter /> |
bx-8-ball.svg | <Icon8Ball /> |
Props Reference
Common Props
| Prop | Type | Default | Description |
|---|---|---|---|
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 |
size | IconSize | 'base' | Preset size (see size table below) |
width | number | string | - | Custom width (overrides size) |
height | number | string | - | Custom height (overrides size) |
fill | string | 'currentColor' | Fill color |
opacity | number | string | - | Overall opacity (0-1) |
flip | 'horizontal' | 'vertical' | - | Flip direction |
rotate | number | string | - | Rotation in degrees |
removePadding | boolean | false | Remove icon padding by adjusting viewBox |
className | string | - | CSS class name |
cssStyle | React.CSSProperties | - | Inline styles object |
Duotone-specific Props
| Prop | Type | Default | Description |
|---|---|---|---|
primaryFill | string | 'currentColor' | Primary layer fill color |
primaryOpacity | number | string | 1 | Primary layer opacity |
secondaryFill | string | 'currentColor' | Secondary layer fill color |
secondaryOpacity | number | string | 0.4 | Secondary layer opacity |