Skip to Content
SveltePro PackageInstall

Svelte Pro Package

The Boxicons Pro Svelte package provides native Svelte 4+ components for the complete library of 50,000+ icon variations. Optimized for Svelte’s compilation model, it ensures minimal runtime overhead and full tree-shaking.

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/svelte # Using yarn yarn add @boxicons-pro/svelte # Using pnpm pnpm add @boxicons-pro/svelte

Peer Dependencies

Ensure you are using Svelte 4.0.0 or higher:

npm install svelte@^4.0.0

Quick Start

<script> import { Alarm, Home, User } from '@boxicons-pro/svelte'; </script> <div class="icon-container"> <Alarm size="lg" /> <Home fill="#3b82f6" weight="thin" /> <User pack="filled" style="rounded" /> </div>

Performance & SSR

Boxicons Pro Svelte works seamlessly with SvelteKit and other SSR frameworks.

Tree-Shaking

Vite and Rollup will automatically remove any unused icons from your final build, keeping your client-side bundle as light as possible.

import { Alarm, Home } from '@boxicons-pro/svelte';

Granular Usage

For extreme optimization, you can import from specific pack/style/weight variants.

import { Alarm } from '@boxicons-pro/svelte-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
<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:

StyleDescription
regularDefault rounded corners
roundedMore pronounced rounded corners
sharpSharp, angular corners
<Alarm style="regular" /> <Alarm style="rounded" /> <Alarm style="sharp" />

Weights

Icons come in three weights:

WeightNameDescription
200thinLight, thin strokes
400normalDefault weight (no suffix needed)
700boldHeavy, 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} />

Duotone Icons

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

<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

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 { render } from '@testing-library/svelte'; import { Alarm } from '@boxicons-pro/svelte'; describe('Boxicons Pro Svelte Integration', () => { it('should support all packs', () => { const basic = render(Alarm, { props: { pack: 'basic' } }); const filled = render(Alarm, { props: { pack: 'filled' } }); const duotone = render(Alarm, { props: { pack: 'duotone' } }); expect(basic.container.querySelector('svg')).toBeTruthy(); expect(filled.container.querySelector('svg')).toBeTruthy(); expect(duotone.container.querySelector('svg')).toBeTruthy(); }); it('should support styles and weights', () => { const { container } = render(Alarm, { props: { style: 'rounded', weight: 'bold' } }); expect(container.querySelector('svg')).toBeTruthy(); }); it('should support duotone colors', () => { const { container } = render(Alarm, { props: { pack: 'duotone', primaryFill: '#3b82f6', secondaryFill: '#93c5fd' } }); const svg = container.querySelector('svg'); expect(svg).toBeTruthy(); }); });

Best Practices

Component Composition

Create reusable icon wrappers with dynamic pack/style/weight:

<script> import { Alarm, Home, Menu } from '@boxicons-pro/svelte'; export let name; export let pack = 'basic'; export let style = 'regular'; export let weight = 'normal'; const icons = { Alarm, Home, Menu }; $: Icon = icons[name]; </script> <svelte:component this={Icon} {pack} {style} {weight} />

SvelteKit

No additional configuration is needed for SvelteKit. The package works out of the box with full SSR support.

@boxicons-pro/svelte