### Installing OpenNG Icons
Source: https://optimus.openng.org/icons
Install the icon library package via npm.
```bash
npm install @openng/icons
```
--------------------------------
### Install Optimus UI dependencies
Source: https://optimus.openng.org/installation
Use these commands to install the core library and themes package using your preferred package manager.
```bash
# Using npm
npm install @openng/optimus-ui @openng/optimus-ui-themes
# Using yarn
yarn add @openng/optimus-ui @openng/optimus-ui-themes
# Using pnpm
pnpm add @openng/optimus-ui @openng/optimus-ui-themes
```
--------------------------------
### Install Optimus UI
Source: https://optimus.openng.org/
Use the Angular CLI to add the Optimus UI package to your project.
```bash
ng add @openng/optimus-ui
```
--------------------------------
### Basic PickList Implementation
Source: https://optimus.openng.org/picklist
A standard PickList setup using source and target signals with drag and drop enabled.
```typescript
import { Component, OnInit, inject, signal } from '@angular/core';
import { PickListModule } from '@openng/optimus-ui/picklist';
import { ProductService } from '@/service/productservice';
import { Product } from '@/domain/product';
@Component({
template: `
`,
standalone: true,
imports: [PickListModule],
providers: [ProductService]
})
export class PicklistBasicDemo implements OnInit {
private productService = inject(ProductService);
sourceProducts = signal([]);
targetProducts = signal([]);
ngOnInit() {
this.carService.getProductsSmall().then((products) => {
this.sourceProducts.set(products);
});
}
}
```
--------------------------------
### Implement a Basic Menubar in Angular
Source: https://optimus.openng.org/menubar
Demonstrates the basic setup of a Menubar component using a model of MenuItem objects.
```typescript
import { Component, OnInit } from '@angular/core';
import { MenubarModule } from '@openng/optimus-ui/menubar';
import { MenuItem } from '@openng/optimus-ui/api';
@Component({
template: `
`,
standalone: true,
imports: [MenubarModule]
})
export class MenubarBasicDemo implements OnInit {
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
label: 'Home',
icon: 'pi pi-home'
},
{
label: 'Features',
icon: 'pi pi-star'
},
{
label: 'Projects',
icon: 'pi pi-search',
items: [
{
label: 'Components',
icon: 'pi pi-bolt'
},
{
label: 'Blocks',
icon: 'pi pi-server'
},
{
label: 'UI Kit',
icon: 'pi pi-pencil'
},
{
label: 'Templates',
icon: 'pi pi-palette',
items: [
{
label: 'Apollo',
icon: 'pi pi-palette'
},
{
label: 'Ultima',
icon: 'pi pi-palette'
}
]
}
]
},
{
label: 'Contact',
icon: 'pi pi-envelope'
}
];
}
}
```
--------------------------------
### Customize Menu with Templates
Source: https://optimus.openng.org/menu
Shows how to use the start template slot to inject custom content into the menu.
```typescript
import { Component, OnInit } from '@angular/core';
import { AvatarModule } from '@openng/optimus-ui/avatar';
import { BadgeModule } from '@openng/optimus-ui/badge';
import { Menu, MenuModule } from '@openng/optimus-ui/menu';
import { RippleModule } from '@openng/optimus-ui/ripple';
import { MenuItem } from '@openng/optimus-ui/api';
@Component({
template: `
```
--------------------------------
### Overlay Events Setup
Source: https://optimus.openng.org/overlay
Template structure for handling overlay events.
```typescript
import { Component } from '@angular/core';
@Component({
template: `
`,
standalone: true,
imports: []
})
export class OverlayEventsDemo {}
```
--------------------------------
### Basic MegaMenu Implementation
Source: https://optimus.openng.org/megamenu
Demonstrates the basic setup of a MegaMenu component using a model of menu items defined in the component class.
```typescript
import { Component, OnInit } from '@angular/core';
import { MegaMenuModule } from '@openng/optimus-ui/megamenu';
import { MegaMenuItem } from '@openng/optimus-ui/api';
import { Table } from '@openng/optimus-ui/table';
@Component({
template: `
`,
standalone: true,
imports: [MegaMenuModule]
})
export class MegamenuBasicDemo implements OnInit {
items: MegaMenuItem[] | undefined;
ngOnInit() {
this.items = [
{
label: 'Furniture',
icon: 'pi pi-box',
items: [
[
{
label: 'Living Room',
items: [{ label: 'Accessories' }, { label: 'Armchair' }, { label: 'Coffee Table' }, { label: 'Couch' }, { label: 'TV Stand' }]
}
],
[
{
label: 'Kitchen',
items: [{ label: 'Bar stool' }, { label: 'Chair' }, { label: 'Table' }]
},
{
label: 'Bathroom',
items: [{ label: 'Accessories' }]
}
],
[
{
label: 'Bedroom',
items: [{ label: 'Bed' }, { label: 'Chaise lounge' }, { label: 'Cupboard' }, { label: 'Dresser' }, { label: 'Wardrobe' }]
}
],
[
{
label: 'Office',
items: [{ label: 'Bookcase' }, { label: 'Cabinet' }, { label: 'Chair' }, { label: 'Desk' }, { label: 'Executive Chair' }]
}
]
]
},
{
label: 'Electronics',
icon: 'pi pi-mobile',
items: [
[
{
label: 'Computer',
items: [{ label: 'Monitor' }, { label: 'Mouse' }, { label: 'Notebook' }, { label: 'Keyboard' }, { label: 'Printer' }, { label: 'Storage' }]
}
],
[
{
label: 'Home Theater',
items: [{ label: 'Projector' }, { label: 'Speakers' }, { label: 'TVs' }]
}
],
[
{
label: 'Gaming',
items: [{ label: 'Accessories' }, { label: 'Console' }, { label: 'PC' }, { label: 'Video Games' }]
}
],
[
{
label: 'Appliances',
items: [{ label: 'Coffee Machine' }, { label: 'Fridge' }, { label: 'Oven' }, { label: 'Vaccum Cleaner' }, { label: 'Washing Machine' }]
}
]
]
},
{
label: 'Sports',
icon: 'pi pi-clock',
items: [
[
{
label: 'Football',
items: [{ label: 'Kits' }, { label: 'Shoes' }, { label: 'Shorts' }, { label: 'Training' }]
}
],
[
{
label: 'Running',
items: [{ label: 'Accessories' }, { label: 'Shoes' }, { label: 'T-Shirts' }, { label: 'Shorts' }]
}
],
[
{
label: 'Swimming',
items: [{ label: 'Kickboard' }, { label: 'Nose Clip' }, { label: 'Swimsuits' }, { label: 'Paddles' }]
}
],
[
{
label: 'Tennis',
items: [{ label: 'Balls' }, { label: 'Rackets' }, { label: 'Shoes' }, { label: 'Training' }]
}
]
]
}
];
}
}
```
--------------------------------
### Initialize DataView Component Logic
Source: https://optimus.openng.org/dataview
Example of setting up component data and sort options within the ngOnInit lifecycle hook.
```typescript
ngOnInit() {
this.productService.getProducts().then((data) => this.products.set(data.slice(0, 5)));
this.sortOptions = [
{ label: 'Price High to Low', value: '!price' },
{ label: 'Price Low to High', value: 'price' }
];
}
```
--------------------------------
### Basic ConfirmPopup Implementation
Source: https://optimus.openng.org/confirmpopup
Demonstrates the basic setup of a ConfirmPopup using the p-confirmPopup tag and ConfirmationService to handle confirmation actions.
```typescript
import { Component, inject } from '@angular/core';
import { ButtonModule } from '@openng/optimus-ui/button';
import { ConfirmPopupModule } from '@openng/optimus-ui/confirmpopup';
import { ToastModule } from '@openng/optimus-ui/toast';
import { MessageService, ConfirmationService } from '@openng/optimus-ui/api';
@Component({
template: `
`,
standalone: true,
imports: [ButtonModule, ConfirmPopupModule, ToastModule],
providers: [ConfirmationService, MessageService]
})
export class ConfirmpopupBasicDemo {
private confirmationService = inject(ConfirmationService);
private messageService = inject(MessageService);
confirm2(event: Event) {
this.confirmationService.confirm({
target: event.currentTarget as EventTarget,
message: 'Do you want to delete this record?',
icon: 'pi pi-info-circle',
rejectButtonProps: {
label: 'Cancel',
severity: 'secondary',
outlined: true
},
acceptButtonProps: {
label: 'Delete',
severity: 'danger'
},
accept: () => {
this.messageService.add({ severity: 'info', summary: 'Confirmed', detail: 'Record deleted', life: 3000 });
},
reject: () => {
this.messageService.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
}
});
}
}
```
--------------------------------
### Advanced Dock Component Implementation
Source: https://optimus.openng.org/dock
A comprehensive example showing the integration of a Dock with various UI components like Menubar, Dialogs, and Galleria.
```typescript
@Component({
template: `
`,
standalone: true,
imports: [DialogModule, DockModule, GalleriaModule, MenubarModule, TerminalModule, ToastModule, TreeModule, TooltipModule],
providers: [NodeService, PhotoService, MessageService]
})
export class DockAdvancedDemo implements OnInit {
private nodeService = inject(NodeService);
private photoService = inject(PhotoService);
private messageService = inject(MessageService);
displayTerminal: boolean | undefined;
displayFinder: boolean | undefined;
displayGalleria: boolean | undefined;
dockItems: MenuItem[] | undefined;
menubarItems: any[] | undefined;
responsiveOptions: any[] | undefined;
images: any[] | undefined;
nodes: any[] | undefined;
subscription: Subscription | undefined;
ngOnInit() {
this.dockItems = [
{
label: 'Finder',
tooltipOptions: {
tooltipLabel: 'Finder',
tooltipPosition: 'top',
positionTop: -15,
positionLeft: 15,
showDelay: 1000
},
icon: 'https://optimus.openng.org/demo/dock/finder.svg',
command: () => {
this.displayFinder = true;
}
},
{
label: 'Terminal',
tooltipOptions: {
tooltipLabel: 'Terminal',
tooltipPosition: 'top',
positionTop: -15,
positionLeft: 15,
showDelay: 1000
},
icon: 'https://optimus.openng.org/demo/dock/terminal.svg',
command: () => {
this.displayTerminal = true;
}
},
{
label: 'App Store',
tooltipOptions: {
tooltipLabel: 'App Store',
tooltipPosition: 'top',
positionTop: -15,
positionLeft: 15,
showDelay: 1000
},
icon: 'https://optimus.openng.org/demo/dock/appstore.svg',
url: 'https://www.apple.com/app-store/'
},
{
label: 'Safari',
tooltipOptions: {
tooltipLabel: 'Safari',
tooltipPosition: 'top',
positionTop: -15,
```
--------------------------------
### Implement a Basic Bar Chart in Angular
Source: https://optimus.openng.org/chart
Demonstrates the setup of a basic bar chart using the ChartModule, including data initialization and styling based on CSS variables.
```typescript
import { Component, OnInit, inject } from '@angular/core';
import { ChartModule } from '@openng/optimus-ui/chart';
@Component({
template: `
`,
standalone: true,
imports: [ChartModule]
})
export class ChartBasicDemo implements OnInit {
basicData: any;
basicOptions: any;
platformId = inject(PLATFORM_ID);
configService = inject(AppConfigService);
ngOnInit() {
this.initChart();
}
initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--p-text-color');
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
this.basicData = {
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
datasets: [
{
label: 'Sales',
data: [540, 325, 702, 620],
backgroundColor: ['rgba(249, 115, 22, 0.2)', 'rgba(6, 182, 212, 0.2)', 'rgb(107, 114, 128, 0.2)', 'rgba(139, 92, 246, 0.2)'],
borderColor: ['rgb(249, 115, 22)', 'rgb(6, 182, 212)', 'rgb(107, 114, 128)', 'rgb(139, 92, 246)'],
borderWidth: 1
}
]
};
this.basicOptions = {
maintainAspectRatio: false,
aspectRatio: 0.8,
plugins: {
legend: {
labels: {
color: textColor
}
}
},
scales: {
x: {
ticks: {
color: textColorSecondary
},
grid: {
color: surfaceBorder
}
},
y: {
beginAtZero: true,
ticks: {
color: textColorSecondary
},
grid: {
color: surfaceBorder
}
}
}
};
this.cd.markForCheck();
}
}
}
```
--------------------------------
### Custom Toolbar Layout with Templates
Source: https://optimus.openng.org/toolbar
Demonstrates how to use the start and end templates to position buttons and avatars within a toolbar.
```typescript
import { Component } from '@angular/core';
import { AvatarModule } from '@openng/optimus-ui/avatar';
import { ButtonModule } from '@openng/optimus-ui/button';
import { ToolbarModule } from '@openng/optimus-ui/toolbar';
@Component({
template: `
`,
standalone: true,
imports: [AvatarModule, ButtonModule, ToolbarModule]
})
export class ToolbarCustomDemo {}
```
--------------------------------
### Implement Basic Toolbar in Angular
Source: https://optimus.openng.org/toolbar
Demonstrates a standard toolbar layout using start, center, and end templates to organize buttons, search inputs, and split buttons.
```typescript
import { Component, OnInit } from '@angular/core';
import { ButtonModule } from '@openng/optimus-ui/button';
import { IconFieldModule } from '@openng/optimus-ui/iconfield';
import { InputIconModule } from '@openng/optimus-ui/inputicon';
import { SplitButtonModule } from '@openng/optimus-ui/splitbutton';
import { ToolbarModule } from '@openng/optimus-ui/toolbar';
import { InputTextModule } from '@openng/optimus-ui/inputtext';
import { MenuItem } from '@openng/optimus-ui/api';
@Component({
template: `
`,
standalone: true,
imports: [ButtonModule, IconFieldModule, InputIconModule, SplitButtonModule, ToolbarModule, InputTextModule]
})
export class ToolbarBasicDemo implements OnInit {
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
label: 'Update',
icon: 'pi pi-refresh'
},
{
label: 'Delete',
icon: 'pi pi-times'
}
];
}
}
```
--------------------------------
### Initialize Optimus UI Provider
Source: https://optimus.openng.org/configuration
Configure the application providers during startup using provideOptimus.
```typescript
import { ApplicationConfig } from '@angular/core';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { provideOptimus } from '@openng/optimus-ui/config';
export const appConfig: ApplicationConfig = {
providers: [
provideAnimationsAsync(),
provideOptimus({ /* options */ })
]
};
```
--------------------------------
### Basic Breadcrumb Implementation
Source: https://optimus.openng.org/breadcrumb
Demonstrates a standard breadcrumb setup using the BreadcrumbModule and MenuItem interface.
```typescript
import { Component, OnInit } from '@angular/core';
import { BreadcrumbModule } from '@openng/optimus-ui/breadcrumb';
import { MenuItem } from '@openng/optimus-ui/api';
@Component({
template: `
`,
standalone: true,
imports: [BreadcrumbModule]
})
export class BreadcrumbBasicDemo implements OnInit {
items: MenuItem[] | undefined;
home: MenuItem | undefined;
ngOnInit() {
this.items = [{ label: 'Electronics' }, { label: 'Computer' }, { label: 'Accessories' }, { label: 'Keyboard' }, { label: 'Wireless' }];
this.home = { icon: 'pi pi-home' };
}
}
```
--------------------------------
### Select Data with Popover
Source: https://optimus.openng.org/popover
Example of retrieving and selecting data from within a popover component using Angular.
```typescript
import { Component } from '@angular/core';
import { ButtonModule } from '@openng/optimus-ui/button';
import { Popover, PopoverModule } from '@openng/optimus-ui/popover';
@Component({
template: `
Team Members
{{ member.name }}
{{ member.email }}
`,
standalone: true,
imports: [ButtonModule, PopoverModule]
})
export class PopoverSelectdataDemo {
selectedMember: any = null;
members: any[];
toggle(event) {
this.op.toggle(event);
}
selectMember(member) {
this.selectedMember = member;
this.op.hide();
}
}
```
--------------------------------
### Basic Overlay Implementation
Source: https://optimus.openng.org/overlay
Demonstrates a basic overlay component with responsive settings and visibility toggling.
```typescript
import { Component } from '@angular/core';
import { ButtonModule } from '@openng/optimus-ui/button';
@Component({
template: `
`,
standalone: true,
imports: [ButtonModule]
})
export class OverlayBasicDemo {
overlayVisible: boolean = false;
toggle() {
this.overlayVisible = !this.overlayVisible;
}
}
```
--------------------------------
### Implementing ContextMenu with Router Navigation
Source: https://optimus.openng.org/contextmenu
Demonstrates configuring a ContextMenu with different navigation types: routerLink, programmatic routing via command, and external URL navigation.
```typescript
import { Component, OnInit } from '@angular/core';
import { ContextMenuModule } from '@openng/optimus-ui/contextmenu';
import { MenuItem } from '@openng/optimus-ui/api';
@Component({
template: `
`,
standalone: true,
imports: [ContextMenuModule]
})
export class ContextmenuRouterDemo implements OnInit {
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
label: 'Router Link',
icon: 'pi pi-palette',
routerLink: '/theming'
},
{
label: 'Programmatic',
icon: 'pi pi-link',
command: () => {
this.router.navigate(['/installation']);
}
},
{
label: 'External',
icon: 'pi pi-home',
url: 'https://angular.io//'
}
];
}
}
```
--------------------------------
### provideOptimus(config)
Source: https://optimus.openng.org/theming
Configures the Optimus UI library with a theme preset and CSS generation options.
```APIDOC
## provideOptimus(config)
### Description
Initializes the Optimus UI library within an Angular application configuration. It accepts a configuration object to define the theme preset and CSS generation behavior.
### Parameters
- **config** (Object) - Required
- **theme** (Object) - Optional: Configuration for the theme.
- **preset** (Object) - Required: The theme preset to use (e.g., Aura).
- **options** (Object) - Optional: Configuration for CSS generation.
- **prefix** (string) - Optional: The prefix for CSS variables (default: 'p').
- **darkModeSelector** (string) - Optional: CSS rule for dark mode encapsulation (default: 'system').
- **cssLayer** (Object) - Optional: Configuration for CSS layers.
- **name** (string) - Required: Name of the CSS layer.
- **order** (string) - Required: Order of the CSS layers.
### Example
```typescript
provideOptimus({
theme: { preset: Aura },
options: {
prefix: 'my',
darkModeSelector: '.my-app-dark',
cssLayer: {
name: 'optimus',
order: 'app-styles, optimus, another-css-library'
}
}
})
```
```