npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@truenas/ui-components

v0.1.6

Published

A comprehensive Angular component library for TrueNAS and related applications, featuring a powerful icon system with automatic sprite generation.

Readme

TrueNAS UI Component Library

A comprehensive Angular component library for TrueNAS and related applications, featuring a powerful icon system with automatic sprite generation.

Installation

npm install @truenas/ui-components

Features

  • 🎨 Complete UI Component Library - Pre-built Angular components with consistent styling
  • 🖼️ Icon Sprite System - Automatic SVG sprite generation with tree-shaking
  • 📦 7,000+ MDI Icons - Material Design Icons built-in
  • 🎯 Custom Icons - Support for custom SVG icons
  • 🔌 Icon Registry - Integrate any third-party icon library (Lucide, Heroicons, etc.)
  • 🌈 8 Built-in Themes - Dark mode, high contrast, and more
  • Accessibility - WCAG 2.1 AA compliant components

Quick Start

1. Import Components

import { TnButtonComponent, TnIconComponent } from '@truenas/ui-components';

@Component({
  standalone: true,
  imports: [TnButtonComponent, TnIconComponent],
  template: `
    <tn-button variant="primary">Click me</tn-button>
    <tn-icon name="folder" library="mdi"></tn-icon>
  `
})
export class MyComponent {}

2. Include Styles

Add to your angular.json:

{
  "styles": [
    "node_modules/@truenas/ui-components/src/styles/themes.css"
  ]
}

Or import in your main styles file:

@import '@truenas/ui-components/src/styles/themes.css';

Icon System

Using Icons

The library includes an intelligent icon system that supports multiple icon sources:

<!-- MDI icons from sprite (recommended) -->
<tn-icon name="folder" library="mdi"></tn-icon>
<tn-icon name="server" library="mdi" size="lg" color="#007acc"></tn-icon>

<!-- Lucide icons via registry -->
<tn-icon name="home" library="lucide"></tn-icon>

<!-- Unicode fallbacks -->
<tn-icon name="star"></tn-icon>  <!-- Shows ★ -->

Icon Sizes

Available sizes: xs, sm, md (default), lg, xl

Icons in Menus

const menuItems: TnMenuItem[] = [
  { id: '1', label: 'Home', icon: 'home', iconLibrary: 'mdi' },
  { id: '2', label: 'Settings', icon: 'cog', iconLibrary: 'mdi' },
  { id: '3', label: 'Profile', icon: 'user', iconLibrary: 'lucide' },
];

Sprite Generation for Consumers

The library includes a powerful sprite generation system that scans your application and automatically creates an optimized SVG sprite containing only the icons you use.

Setup

  1. Add the sprite generation script to your package.json:
{
  "scripts": {
    "icons": "truenas-icons generate"
  }
}
  1. Run sprite generation:
npm run icons

This will:

  • Scan your templates for <tn-icon> elements
  • Detect icons marked with tnIconMarker() in TypeScript
  • Generate src/assets/icons/sprite.svg with only used icons
  • Create src/assets/icons/sprite-config.json with manifest

Configuration

Create truenas-icons.config.js in your project root:

export default {
  // Source directories to scan for icon usage
  srcDirs: ['./src/lib', './src/app'],

  // Output directory for sprite files
  outputDir: './src/assets/icons',

  // Optional: Directory with custom SVG icons
  customIconsDir: './custom-icons'
};

CLI Options

# Use custom source directories
npx truenas-icons generate --src ./src,./app

# Specify output directory
npx truenas-icons generate --output ./public/icons

# Use custom icons
npx truenas-icons generate --custom ./my-icons

# Use config file
npx truenas-icons generate --config ./my-config.js

Marking Dynamic Icons

For icons whose names are determined at runtime, use tnIconMarker() to ensure they're included in the sprite:

import { tnIconMarker } from '@truenas/ui-components';

// In arrays or objects
const actions = [
  { name: 'Save', icon: tnIconMarker('mdi-content-save') },
  { name: 'Delete', icon: tnIconMarker('mdi-delete') }
];

// In conditional logic
const icon = isEditing
  ? tnIconMarker('mdi-pencil')
  : tnIconMarker('mdi-eye');

// In component properties
export class MyComponent {
  icon = tnIconMarker('mdi-database');
}

Custom Icons

  1. Create a directory for your custom SVG icons:
mkdir custom-icons
  1. Add SVG files (they'll be prefixed with tn- automatically):
custom-icons/
  ├── logo.svg        → Available as "tn-logo"
  ├── brand.svg       → Available as "tn-brand"
  └── custom-icon.svg → Available as "tn-custom-icon"
  1. Configure sprite generation:
// truenas-icons.config.js
export default {
  customIconsDir: './custom-icons'
};
  1. Run sprite generation:
npm run icons
  1. Use your custom icons:
<tn-icon name="tn-logo"></tn-icon>

Icon Registry (Advanced)

For integrating third-party icon libraries like Lucide:

import { TnIconRegistryService } from '@truenas/ui-components';
import * as LucideIcons from 'lucide';

export function setupIcons() {
  const iconRegistry = inject(TnIconRegistryService);

  // Register Lucide library
  iconRegistry.registerLibrary({
    name: 'lucide',
    resolver: (iconName: string) => {
      const icon = LucideIcons[iconName];
      // Convert icon data to SVG string
      return svgString;
    }
  });

  // Register individual icons
  iconRegistry.registerIcon('my-logo', '<svg>...</svg>');
}

Themes

Apply themes by adding a class to your root element:

<html class="tn-dark">
  <!-- Your app -->
</html>

Available themes:

  • tn-dark (default)
  • tn-blue
  • dracula
  • nord
  • paper
  • solarized-dark
  • midnight
  • high-contrast

Development

Building the Library

# Build the library
ng build truenas-ui

# Generate icon sprite for library development
yarn icons

# Run Storybook
yarn run sb

Testing

# Run unit tests
yarn test

# Run tests with coverage
yarn test-coverage

# Run Storybook interaction tests
yarn test-sb

Publishing

# Build the library
ng build truenas-ui

# Navigate to dist
cd dist/truenas-ui

# Pack for testing
npm pack

# Or publish to npm
npm publish

Project Structure

projects/truenas-ui/
├── src/
│   ├── lib/              # Component source code
│   ├── stories/          # Storybook stories
│   ├── styles/           # Global themes and styles
│   └── public-api.ts     # Public API exports
├── assets/
│   └── icons/
│       ├── custom/       # Custom TrueNAS icons
│       ├── sprite.svg    # Generated sprite
│       └── sprite-config.json
├── scripts/
│   └── icon-sprite/      # Sprite generation system
└── package.json

Browser Support

  • Chrome/Edge (latest)
  • Firefox (latest)
  • Safari (latest)

License

Copyright © iXsystems, Inc.

Additional Resources