# Snackbar

O snackbar é um componente de alertas no formato de balão de notificação, onde poderá optar entre **sucesso**, **alerta**, **error** e **informação.**

### Uso

{% code title="page-snackbar.component.ts" %}

```html
<cat-toolbar [config]="getToolbarInfo()">
  <nav buttons>
    <cat-success-button class="mr-8" (click)="openSnackbar('success')">Sucesso</cat-success-button>
    <cat-warning-button class="mr-8" (click)="openSnackbar('warning')">Atenção</cat-warning-button>
    <cat-danger-button class="mr-8" (click)="openSnackbar('error')">Error</cat-danger-button>
    <cat-info-button (click)="openSnackbar('info')">Informação</cat-info-button>
  </nav>
</cat-toolbar>
```

{% endcode %}

{% code title="page-snackbar.component.ts" lineNumbers="true" %}

```typescript
import { Component } from '@angular/core';
import { CatComponentBase } from '@catrx/ui/common';
import { CatSnackbarService, CatSnackbarType } from '@catrx/ui/snackbar';

@Component({
  templateUrl: './page-snackbar.component.html'
})
export class PageSnackbarComponent extends CatComponentBase {
  constructor(private snackbarService: CatSnackbarService) {
    super();
  }

  openSnackbar(type: CatSnackbarType) {
    this.snackbarService.open({
      type,
      title: 'Título do Snackbar',
      message: `Mensagem do <b>Snackbar</b>`,
      openedTime: 10000
    });
  }
}
```

{% endcode %}

{% code title="page-snackbar.module.ts" lineNumbers="true" %}

```typescript
import { NgModule } from "@angular/core";
import { CatSuccessButtonComponent } from '@catrx/ui/button/seccess';
import { CatWarningButtonComponent } from '@catrx/ui/button/warning';
import { CatDangerButtonComponent } from '@catrx/ui/button/danger';
import { CatInfoButtonComponent } from '@catrx/ui/button/info';
import { CatToolbarModule } from "@catrx/ui/toolbar";
import { PageSnackbarComponent } from "./page-snackbar.component";
import { PageSnackbarRoutingModule } from "./page-snackbar.routing.module";

@NgModule({
  declarations: [PageSnackbarComponent],
  imports: [
    CatToolbarModule,
    CatSuccessButtonComponent,
    CatWarningButtonComponent,
    CatDangerButtonComponent,
    CatInfoButtonComponent,
    PageSnackbarRoutingModule,
  ],
})
export class PageSnackbarModule {}
```

{% endcode %}

### Overview

{% embed url="<https://cat-ui.igordrangel.com.br/components/snackbar>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.catui.igordrangel.com.br/janelas-e-alertas/snackbar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
