Acciones
Toolbar
Organiza las acciones y los controles de una pantalla.
Importación
import { NeuToolbarComponent } from '@neural-ui/native/toolbar';Ejemplos
Importa ExampleComponent en su padre y coloca <app-example /> dentro del neu-theme raíz de tu aplicación. El preview aporta el marco y las zonas seguras; utiliza la estructura raíz de Instalación en tu app.
Básico
La toolbar reúne el título de la pantalla a la izquierda y las acciones a la derecha. La lupa filtra los archivos y el signo más crea un borrador local.
Ver y copiar el ejemplo completo
import { Component, signal, computed } from '@angular/core';
import { NeuInputComponent } from '@neural-ui/native/input';
import { NeuToolbarComponent } from '@neural-ui/native/toolbar';
import { View, Text, ScrollView } from '@ng-native/components';
import type { NeuToolbarAction } from '@neural-ui/native/toolbar';
@Component({
selector: 'app-example',
imports: [NeuInputComponent, NeuToolbarComponent, View, Text, ScrollView],
template: `
<view class="documents-screen">
<neu-toolbar label="Acciones de documentos" [actions]="actions" (activated)="onActivated($event)">
<text class="toolbar-title" [numberOfLines]="1" ellipsizeMode="tail">Documentos</text>
</neu-toolbar>
<scroll-view class="documents-scroll" keyboardShouldPersistTaps="handled"><view class="documents-body">
@if (searching()) {
<neu-input requiredLabel="Obligatorio" label="Buscar documentos" placeholder="Nombre o tipo de archivo" [(value)]="query" />
}
<view class="section-heading">
<text class="section-title">Archivos recientes</text>
<text class="file-count">{{ visibleDocuments().length }}</text>
</view>
@for (document of visibleDocuments(); track document.id) {
<view class="document-row">
<view class="file-symbol"><text class="file-type">{{ document.type }}</text></view>
<view class="document-copy">
<text class="document-name" [numberOfLines]="1" ellipsizeMode="tail">{{ document.name }}</text>
<text class="document-meta">{{ document.detail }}</text>
</view>
</view>
} @empty {
<text class="empty-copy">No hay documentos que coincidan.</text>
}
<text class="status-copy" accessibilityLiveRegion="polite">{{ status() }}</text>
</view></scroll-view>
</view>
`,
styles: `
.actions { gap: 12px; align-items: flex-start; } text { color: var(--neu-text, #172033); font-size: 16px; }
:host { flex: 1; min-height: 0; }
.documents-screen { flex: 1; background-color: var(--neu-surface, #ffffff); }
.documents-scroll { flex: 1; min-height: 0; }
.toolbar-title { flex-shrink: 1; color: var(--neu-text, #172033); font-size: 20px; line-height: 26px; font-weight: 600; }
.documents-body { padding: 20px 16px; gap: 8px; }
.section-heading { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 8px; margin-bottom: 8px; }
.section-title { color: var(--neu-muted, #596477); font-size: 13px; line-height: 18px; font-weight: 500; }
.file-count { color: var(--neu-muted, #596477); font-size: 13px; line-height: 18px; }
.document-row { flex-direction: row; align-items: center; gap: 12px; min-height: 76px; padding: 12px 0; border-bottom-width: 1px; border-color: var(--neu-divider, #e4e7ec); }
.file-symbol { width: 44px; height: 48px; border-radius: 10px; background-color: var(--neu-tonal, #e9edfc); align-items: center; justify-content: center; }
.file-type { color: var(--neu-text, #172033); font-size: 11px; font-weight: 600; }
.document-copy { flex: 1; min-width: 0; gap: 4px; }
.document-name { color: var(--neu-text, #172033); font-size: 15px; line-height: 20px; font-weight: 500; }
.document-meta, .status-copy { color: var(--neu-muted, #596477); font-size: 13px; line-height: 18px; }
.status-copy { margin-top: 8px; }
.empty-copy { color: var(--neu-muted, #596477); font-size: 15px; line-height: 22px; padding: 24px 0; }
`,
})
export class ExampleComponent {
readonly searching = signal(false);
readonly query = signal('');
readonly status = signal('');
readonly documents = signal([
{ id: 'brief', name: 'Resumen del proyecto', type: 'PDF', detail: 'Hoy · 240 KB' },
{ id: 'notes', name: 'Notas de la reunión', type: 'TXT', detail: 'Ayer · 12 KB' },
{ id: 'guide', name: 'Guía de marca', type: 'PDF', detail: 'Lunes · 1,8 MB' },
]);
readonly visibleDocuments = computed(() => {
const query = this.query().trim().toLocaleLowerCase();
return this.documents().filter(document =>
(document.name + ' ' + document.type).toLocaleLowerCase().includes(query));
});
readonly actions: readonly NeuToolbarAction[] = [
{ id: 'search', label: 'Buscar archivos', svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="m16 16 4 4"/></svg>' },
{ id: 'new', label: 'Nuevo documento', svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>' },
];
private nextDraft = 1;
onActivated(id: string): void {
if (id === 'search') {
this.searching.update(value => !value);
this.query.set('');
}
if (id === 'new') {
const number = this.nextDraft++;
this.query.set('');
this.documents.update(documents => [
{ id: 'draft-' + number, name: 'Documento sin título ' + number, type: 'TXT', detail: 'Borrador · Ahora mismo' },
...documents,
]);
this.status.set('Borrador creado en esta pantalla.');
}
}
}Ajusta la configuración y prueba el resultado.
Capturas del dispositivo en inglés.


Personalización
Contenido proyectado
Contenido inicial alineado junto a las acciones. Proyecta un encabezado nativo breve u otro control compacto. Cada acción admite un svg opcional; label es su nombre accesible y se muestra como texto cuando no hay svg. El estado disabled de la toolbar no desactiva los controles que proyectes.
Utiliza elementos nativos de @ng-native/components y controles públicos de Neural Native. Los estilos Angular pertenecen al componente que declara este contenido.
Referencia API
Inputs
| Nombre | Tipo | Predeterminado | Enlace | Descripción |
|---|---|---|---|---|
| label | string | 'Toolbar' | Input | Nombre accesible que se anuncia para la barra de herramientas. No dibuja un título visible; para ello, proyecta un elemento de texto entre las etiquetas de la toolbar. |
| actions | readonly NeuToolbarAction[] | [] | Input | Acciones de la pantalla actual: id, label, svg opcional y disabled. Con svg se muestra un botón compacto de icono; sin él, label queda visible. activated emite su id. |
| disabled | boolean | false | Input | Desactiva los botones declarados en actions. Los controles interactivos que proyectes conservan su propio estado disabled, gestionado por tu aplicación. |
Models
Este componente no declara models bidireccionales.
Outputs
| Nombre | Payload | Cuándo se emite |
|---|---|---|
| activated | string | Emite el ID del elemento activado. Tu aplicación ejecuta la acción. |
Tipos e interfaces de datos
Utiliza los imports en tu aplicación. Las definiciones siguientes se muestran como referencia.
NeuToolbarAction
import type { NeuToolbarAction } from '@neural-ui/native/toolbar';
import type { NeuOption } from '@neural-ui/native';
// Public definition for reference only. Import this type; do not redeclare it.
export interface NeuToolbarAction extends NeuOption {
readonly svg?: string;
}| Campo | Tipo | Requisito | Significado |
|---|---|---|---|
| svg | string | Opcional | SVG opcional del icono de la acción. label mantiene su nombre accesible. Omite svg para mostrar label como texto visible. |
| id | string | Obligatorio | Identificador estable y único para seguimiento y selección. |
| label | string | Obligatorio | Nombre legible del elemento. |
| description | string | Opcional | Texto de apoyo opcional; su presentación depende del control. |
| disabled | boolean | Opcional | Impide activar o seleccionar este elemento. |
NeuOption
import type { NeuOption } from '@neural-ui/native';
// Public definition for reference only. Import this type; do not redeclare it.
export interface NeuOption {
readonly id: string;
readonly label: string;
readonly description?: string;
readonly disabled?: boolean;
}| Campo | Tipo | Requisito | Significado |
|---|---|---|---|
| id | string | Obligatorio | Identificador estable y único para seguimiento y selección. |
| label | string | Obligatorio | Nombre legible del elemento. |
| description | string | Opcional | Texto de apoyo opcional; su presentación depende del control. |
| disabled | boolean | Opcional | Impide activar o seleccionar este elemento. |