Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Nettalco/nettalco-theme/llms.txt

Use this file to discover all available pages before exploring further.

The PrimeNG p-togglebutton component is a two-state button that switches between on and off, functioning as a stylized checkbox replacement for settings panels, feature flags, and binary filter toggles. Nettalco Theme defines a three-section token structure — root, content, and icon — giving precise control over the outer wrapper, the inner sliding pill, and icon color at every interaction state. The checked elevation shadow and surface-scale color progression are tuned to Nettalco’s dark Navy surface palette.

Basic Usage

<!-- Label-based toggle -->
<p-togglebutton
  [(ngModel)]="isEnabled"
  onLabel="Enabled"
  offLabel="Disabled"
/>

<!-- Icon + label -->
<p-togglebutton
  [(ngModel)]="isMuted"
  onLabel="Muted"
  offLabel="Active"
  onIcon="pi pi-volume-off"
  offIcon="pi pi-volume-up"
/>

<!-- Icon only -->
<p-togglebutton
  [(ngModel)]="isStarred"
  onIcon="pi pi-star-fill"
  offIcon="pi pi-star"
  aria-label="Favourite"
/>

Component Setup (TypeScript)

import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ToggleButtonModule } from 'primeng/togglebutton';

@Component({
  selector: 'app-settings-panel',
  standalone: true,
  imports: [FormsModule, ToggleButtonModule],
  templateUrl: './settings-panel.component.html',
})
export class SettingsPanelComponent {
  notifications = true;
  darkMode       = false;
  autoSave       = true;
  isStarred      = false;
}

Size Variants

<!-- Small -->
<p-togglebutton [(ngModel)]="val" onLabel="On" offLabel="Off" size="small" />

<!-- Default -->
<p-togglebutton [(ngModel)]="val" onLabel="On" offLabel="Off" />

<!-- Large -->
<p-togglebutton [(ngModel)]="val" onLabel="On" offLabel="Off" size="large" />

Reactive Forms & Validation

<form [formGroup]="form">
  <p-togglebutton
    formControlName="termsAccepted"
    onLabel="Accepted"
    offLabel="Accept Terms"
    [invalid]="form.get('termsAccepted')?.invalid && form.get('termsAccepted')?.touched"
  />
  <small *ngIf="form.get('termsAccepted')?.invalid" class="p-error">
    You must accept the terms.
  </small>
</form>
import { FormBuilder, Validators } from '@angular/forms';

form = this.fb.group({
  termsAccepted: [false, Validators.requiredTrue],
});

Disabled State

<p-togglebutton
  [(ngModel)]="val"
  onLabel="On"
  offLabel="Off"
  [disabled]="true"
/>
When disabled, the component uses {form.field.disabled.background} and {form.field.disabled.color} tokens — consistent with all other Nettalco form fields.

Root Design Tokens

TokenValueDescription
togglebutton.root.padding0.25remOuter wrapper inset padding
togglebutton.root.borderRadius{content.border.radius}Outer wrapper corner radius
togglebutton.root.gap0.5remSpace between icon and label
togglebutton.root.fontWeight500Medium weight label text
togglebutton.root.disabledBackground{form.field.disabled.background}Disabled state background
togglebutton.root.disabledBorderColor{form.field.disabled.background}Disabled state border (matches bg)
togglebutton.root.disabledColor{form.field.disabled.color}Disabled state text/icon color
togglebutton.root.invalidBorderColor{form.field.invalid.border.color}Validation error border
togglebutton.root.focusRing.width{focus.ring.width}Focus outline width
togglebutton.root.focusRing.style{focus.ring.style}Focus outline style
togglebutton.root.focusRing.color{focus.ring.color}Focus outline color
togglebutton.root.focusRing.offset{focus.ring.offset}Focus outline offset
togglebutton.root.focusRing.shadow{focus.ring.shadow}Focus outline shadow
togglebutton.root.transitionDuration{form.field.transition.duration}Hover/check CSS transition

Size Tokens

SizeTokenValue
Smalltogglebutton.root.sm.fontSize{form.field.sm.font.size}
Smalltogglebutton.root.sm.padding0.25rem
Largetogglebutton.root.lg.fontSize{form.field.lg.font.size}
Largetogglebutton.root.lg.padding0.25rem

Content Section Tokens

The content section styles the inner sliding pill that moves when the button is checked.
TokenValueDescription
togglebutton.content.padding0.25rem 0.75remPill inner padding
togglebutton.content.borderRadius{content.border.radius}Pill corner radius
togglebutton.content.checkedShadow0px 1px 2px 0px rgba(0,0,0,0.02), 0px 1px 2px 0px rgba(0,0,0,0.04)Subtle checked elevation
togglebutton.content.sm.padding0.25rem 0.75remSmall size pill padding
togglebutton.content.lg.padding0.25rem 0.75remLarge size pill padding

Icon Section Tokens

TokenValueDescription
togglebutton.icon.disabledColor{form.field.disabled.color}Icon color when disabled

Color Scheme Tokens

Light Mode

SectionTokenValue
rootbackground{surface.100}
rootcheckedBackground{surface.100}
roothoverBackground{surface.100}
rootborderColor{surface.100}
rootcolor{surface.500}
roothoverColor{surface.700}
rootcheckedColor{surface.900}
rootcheckedBorderColor{surface.100}
contentcheckedBackground{surface.0}#ffffff
iconcolor{surface.500}
iconhoverColor{surface.700}
iconcheckedColor{surface.900}

Dark Mode

SectionTokenValue
rootbackground{surface.950}#060d1a
rootcheckedBackground{surface.950}
roothoverBackground{surface.950}
rootborderColor{surface.950}
rootcolor{surface.400}#2e476d
roothoverColor{surface.300}#3d5a7e
rootcheckedColor{surface.0}#f0f5fb
rootcheckedBorderColor{surface.950}
contentcheckedBackground{surface.800}#0f1e35
iconcolor{surface.400}
iconhoverColor{surface.300}
iconcheckedColor{surface.0}

Nettalco-Specific Customizations

Navy-toned dark mode surface scale. Nettalco overrides the dark-mode surface palette with a Navy-blue tint (#060d1a at 950, through #f0f5fb at 0). The ToggleButton’s dark-mode tokens map directly into this Navy scale, so an unchecked toggle sits on a deep Navy #060d1a background and the checked pill lifts to a mid-Navy #0f1e35 — creating a subtle depth effect that fits the Nettalco brand. Checked shadow for tactile feedback. The content.checkedShadow applies a two-layer box-shadow when the button is in the on state. The shadow values are intentionally subtle (2px, 4% opacity) to suggest elevation without competing with the surface color contrast. Disabled border matches disabled background. togglebutton.root.disabledBorderColor is set to {form.field.disabled.background} (the same token as the background), making the border invisible in disabled state. This produces a flat, muted appearance that clearly signals non-interactivity without a jarring color contrast. Consistent focus ring with form fields. Unlike the Button component (which suppresses the focus shadow), ToggleButton uses all five focus-ring tokens including focusRing.shadow. This provides a more prominent keyboard-navigation indicator appropriate for a form control context.

Build docs developers (and LLMs) love