Alert
The TkAlert component is designed to display contextual feedback messages, such as success, warnings, informational notices, and errors.
- React
- Vue
- Angular
import { TkAlert } from '@takeoff-ui/react'
import { TkAlert } from '@takeoff-ui/vue'
import { TkAlert } from '@takeoff-ui/angular'
Variant​
The variant of the badge for styling.
- React
- Vue
- Angular
<TkAlert
variant="success"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="warning"
header="Warning Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="info"
header="Info Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="danger"
header="Danger Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="neutral"
header="Neutral Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
icon="flight"
/>
<TkAlert
variant="success"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="warning"
header="Warning Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="info"
header="Info Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="danger"
header="Danger Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="neutral"
header="Neutral Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
icon="flight"
/>
<tk-alert
variant="success"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<tk-alert
variant="warning"
header="Warning Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<tk-alert
variant="info"
header="Info Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<tk-alert
variant="danger"
header="Danger Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<tk-alert
variant="neutral"
header="Neutral Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
icon="flight"
/>
Type​
This prop specifies the design type of the component.
- React
- Vue
- Angular
<TkAlert
variant="success"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="success"
header="Success FilledLight Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filledlight"
/>
<TkAlert
variant="success"
header="Success Gradient Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="gradient"
/>
<TkAlert
variant="success"
header="Success Outlined Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="outlined"
/>
<TkAlert
variant="success"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<TkAlert
variant="success"
header="Success FilledLight Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filledlight"
/>
<TkAlert
variant="success"
header="Success Gradient Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="gradient"
/>
<TkAlert
variant="success"
header="Success Outlined Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="outlined"
/>
<tk-alert
variant="success"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filled"
/>
<tk-alert
variant="success"
header="Success FilledLight Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="filledlight"
/>
<tk-alert
variant="success"
header="Success Gradient Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="gradient"
/>
<tk-alert
variant="success"
header="Success Outlined Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
type="outlined"
/>
Alignment​
This prop specifies the alignment of the component.
- React
- Vue
- Angular
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
alignItems="start"
/>
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
/>
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
alignItems="end"
/>
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
align-items="start"
/>
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
/>
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
align-items="end"
/>
<tk-alert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
align-items="start"
></tk-alert>
<tk-alert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
></tk-alert>
<tk-alert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
align-items="end"
></tk-alert>
Messages​
Single Message View
Multi Message View
- React
- Vue
- Angular
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
/>
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message={[
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. ",
"Dummy text of the printing and typesetting",
"Lorem Ipsum has been the industry's standard.",
]}
/>
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
/>
<TkAlert
variant="success"
type="outlined"
header="Success Filled Alert"
:message='[
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. ",
"Dummy text of the printing and typesetting",
"Lorem Ipsum has been the industry's standard.",
]'
/>
<tk-alert
variant="success"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
/>
<tk-alert
variant="success"
type="outlined"
header="Success Filled Alert"
[message]="[
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. ',
'Dummy text of the printing and typesetting',
'Lorem Ipsum has been the industry's standard.'
]"
/>
Actions​
Right Action Slot
Footer Action Slot
- React
- Vue
- Angular
<TkAlert
variant="info"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
>
<div slot="right-action" className="flex gap-3">
<TkButton label="Action1" variant="info" type="text" />
<TkButton label="Action2" variant="info" type="text" />
</div>
</TkAlert>
<TkAlert
variant="info"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
>
<div slot="footer-action" className="flex gap-3">
<TkButton
label="Action1"
variant="info"
type="outlined"
size="small"
/>
<TkButton
label="Action2"
variant="info"
type="filled"
size="small"
/>
</div>
</TkAlert>
<TkAlert
variant="info"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
>
<div slot="right-action" className="flex gap-3">
<TkButton label="Action1" variant="info" type="text" />
<TkButton label="Action2" variant="info" type="text" />
</div>
</TkAlert>
<TkAlert
variant="info"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
>
<div slot="footer-action" className="flex gap-3">
<TkButton
label="Action1"
variant="info"
type="outlined"
size="small"
/>
<TkButton
label="Action2"
variant="info"
type="filled"
size="small"
/>
</div>
</TkAlert>
<tk-alert
variant="info"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
>
<div slot="right-action" class="flex gap-3">
<tk-button label="Action1" variant="info" type="text"></tk-button>
<tk-button label="Action2" variant="info" type="text"></tk-button>
</div>
</tk-alert>
<tk-alert
variant="info"
type="outlined"
header="Success Filled Alert"
message="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
>
<div slot="footer-action" class="flex gap-3">
<tk-button
label="Action1"
variant="info"
type="outlined"
size="small"
></tk-button>
<tk-button
label="Action2"
variant="info"
type="filled"
size="small"
></tk-button>
</div>
</tk-alert>
Toaster​
Provides a function that uses the TkAlert component. Allows you to open the TkAlert component in the desired position.
- React
- Vue
- Angular
import { createToast } from "@takeoff-ui/core";
const handleCreateToast = (position: string, variant: 'success' | 'warning' | 'info' | 'danger' | 'neutral') => {
createToast({
position: position,
header: "Deneme Başlık",
alignItems: 'start',
message: "Bu bir deneme mesajıdır. Dikkate almayınız.",
variant: variant,
type: "filled",
timeout: 10000,
removable: true,
actions: [
{
label: "Action 1",
icon: "flight",
type: "outlined",
variant: "secondary",
action: () => {
alert("action 1 clicked");
},
},
{
label: "Action 2",
icon: "flight",
type: "filled",
variant: "primary",
action: () => {
alert("action 2 clicked");
},
},
],
});
};
return (
<>
<TkButton
icon="north_west"
variant="success"
onTkClick={() => handleCreateToast("top-left", "success")}
/>
<TkButton
icon="north_east"
variant="info"
onTkClick={() => handleCreateToast("top-right", "info")}
/>
<TkButton
icon="south_west"
variant="warning"
onTkClick={() => handleCreateToast("bottom-left", "warning")}
/>
<TkButton
icon="south_east"
variant="danger"
onTkClick={() => handleCreateToast("bottom-right", "danger")}
/>
</>
);
<script setup>
import { TkButton } from '@takeoff-ui/vue';
import { createToast } from "@takeoff-ui/core";
const handleCreateToast = (position, variant) => {
createToast({
position: position,
header: "Deneme Başlık",
alignItems: 'start',
message: "Bu bir deneme mesajıdır. Dikkate almayınız.",
variant: variant,
type: "filled",
timeout: 10000,
removable: true,
actions: [
{
label: "Action 1",
icon: "flight",
type: "outlined",
variant: "secondary",
action: () => {
alert("action 1 clicked");
},
},
{
label: "Action 2",
icon: "flight",
type: "filled",
variant: "primary",
action: () => {
alert("action 2 clicked");
},
},
],
});
};
</script>
<template>
<TkButton icon="north_west" variant="success" @tkClick="handleCreateToast('top-left', 'success')" />
<TkButton icon="north_east" variant="info" @tkClick="handleCreateToast('top-right', 'info')" />
<TkButton icon="south_west" variant="warning" @tkClick="handleCreateToast('bottom-left', 'warning')" />
<TkButton icon="south_east" variant="danger" @tkClick="handleCreateToast('bottom-right', 'danger')" />
</template>
import { Component } from '@angular/core';
import { createToast } from '@takeoff-ui/core';
@Component({
selector: 'app-root',
template: `
<tk-button
icon="north_west"
variant="success"
(tk-click)="handleCreateToast('top-left', 'success')"
></tk-button>
<tk-button
icon="north_east"
variant="info"
(tk-click)="handleCreateToast('top-right', 'info')"
></tk-button>
<tk-button
icon="south_west"
variant="warning"
(tk-click)="handleCreateToast('bottom-left', 'warning')"
></tk-button>
<tk-button
icon="south_east"
variant="danger"
(tk-click)="handleCreateToast('bottom-right', 'danger')"
></tk-button>
`,
})
export class AppComponent {
handleCreateToast(position: string, variant: 'success' | 'warning' | 'info' | 'danger' | 'neutral') {
createToast({
position,
header: 'Deneme Başlık',
alignItems: 'start',
message: 'Bu bir deneme mesajıdır. Dikkate almayınız.',
variant: variant,
type: 'filled',
timeout: 10000,
removable: true,
actions: [
{
label: 'Action 1',
icon: 'flight',
type: 'outlined',
variant: 'secondary',
action: () => {
alert('action 1 clicked');
},
},
{
label: 'Action 2',
icon: 'flight',
type: 'filled',
variant: 'primary',
action: () => {
alert('action 2 clicked');
},
},
],
});
}
}
Persistent Toaster​
Provides persistent toast functionality. Toast can be shown and hidden with the same button, maintaining state until explicitly dismissed.
Multiple Persistent:
- React
- Vue
- Angular
import { showPersistentToast, isPersistentToastVisible, dismissAllPersistentToasts } from "@takeoff-ui/core";
const handlePersistentToast = () => {
const isOpen = showPersistentToast({
persistentId: "my-persistent-toast",
position: "top-right",
header: "Persistent Toast",
message: "This toast can be toggled. Click the same button again to close it.",
variant: "info",
type: "outlined",
removable: true,
actions: [
{
label: "Custom Action",
icon: "settings",
type: "text",
variant: "info",
action: () => {
alert("Custom action clicked!");
},
},
],
});
console.log(isOpen ? "Toast opened" : "Toast closed");
};
const handleCheckStatus = () => {
const isVisible = isPersistentToastVisible("my-persistent-toast");
alert(`Toast status: ${isVisible ? "Visible" : "Hidden"}`);
};
const handleDismissAll = () => {
dismissAllPersistentToasts();
};
return (
<div>
<TkButton
label="Show/Hide Toast"
icon="visibility"
variant="info"
onTkClick={handlePersistentToast}
/>
<TkButton
label="Check Status"
icon="help"
variant="neutral"
type="outlined"
onTkClick={handleCheckStatus}
/>
<TkButton
label="Dismiss All"
icon="close"
variant="danger"
type="text"
onTkClick={handleDismissAll}
/>
</div>
);
<script setup>
import { TkButton } from '@takeoff-ui/vue';
import { showPersistentToast, isPersistentToastVisible, dismissAllPersistentToasts } from "@takeoff-ui/core";
const handlePersistentToast = () => {
const isOpen = showPersistentToast({
persistentId: "my-persistent-toast",
position: "top-right",
header: "Persistent Toast",
message: "This toast can be toggled. Click the same button again to close it.",
variant: "info",
type: "outlined",
removable: true,
actions: [
{
label: "Custom Action",
icon: "settings",
type: "text",
variant: "info",
action: () => {
alert("Custom action clicked!");
},
},
],
});
console.log(isOpen ? "Toast opened" : "Toast closed");
};
const handleCheckStatus = () => {
const isVisible = isPersistentToastVisible("my-persistent-toast");
alert(`Toast status: ${isVisible ? "Visible" : "Hidden"}`);
};
const handleDismissAll = () => {
dismissAllPersistentToasts();
};
</script>
<template>
<div>
<TkButton
label="Show/Hide Toast"
icon="visibility"
variant="info"
@tkClick="handlePersistentToast"
/>
<TkButton
label="Check Status"
icon="help"
variant="neutral"
type="outlined"
@tkClick="handleCheckStatus"
/>
<TkButton
label="Dismiss All"
icon="close"
variant="danger"
type="text"
@tkClick="handleDismissAll"
/>
</div>
</template>
import { Component } from '@angular/core';
import { showPersistentToast, isPersistentToastVisible, dismissAllPersistentToasts } from '@takeoff-ui/core';
@Component({
selector: 'app-root',
template: `
<div>
<tk-button
label="Show/Hide Toast"
icon="visibility"
variant="info"
(tk-click)="handlePersistentToast()"
></tk-button>
<tk-button
label="Check Status"
icon="help"
variant="neutral"
type="outlined"
(tk-click)="handleCheckStatus()"
></tk-button>
<tk-button
label="Dismiss All"
icon="close"
variant="danger"
type="text"
(tk-click)="handleDismissAll()"
></tk-button>
</div>
`,
})
export class AppComponent {
handlePersistentToast() {
const isOpen = showPersistentToast({
persistentId: "my-persistent-toast",
position: "top-right",
header: "Persistent Toast",
message: "This toast can be toggled. Click the same button again to close it.",
variant: "info",
type: "outlined",
removable: true,
actions: [
{
label: "Custom Action",
icon: "settings",
type: "text",
variant: "info",
action: () => {
alert("Custom action clicked!");
},
},
],
});
console.log(isOpen ? "Toast opened" : "Toast closed");
}
handleCheckStatus() {
const isVisible = isPersistentToastVisible("my-persistent-toast");
alert(`Toast status: ${isVisible ? "Visible" : "Hidden"}`);
}
handleDismissAll() {
dismissAllPersistentToasts();
}
}
Custom Content Slot​
Illustrates how to add a content using the content slot.
İnfo
lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.- Email: lorem ipsum dolor sit amet
lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.
- React
- Vue
- Angular
<TkAlert
variant="info"
type="outlined"
>
<div slot="content">...</div>
</TkAlert>
<TkAlert
variant="info"
type="outlined"
>
<div slot="content">...</div>
</TkAlert>
<tk-alert
variant="info"
type="outlined"
>
<div slot="content">...</div>
</tk-alert>
API​
Props​
Name | Type | Default | Description |
---|---|---|---|
"center", "end", "start" | 'center' | Alignment of the alert content ('start', 'center', or 'end'). | |
string | null | The header text displayed at the top of the alert. | |
IIconOptions, string | null | The icon displayed in the alert. If not provided, a default icon is used based on the variant. | |
"base", "large", "small", "xlarge" | 'large' | Size of the icon displayed in the alert ('small', 'base', or 'large'). | |
string, string[] | null | The message text displayed within the alert. | |
boolean | false | The alert can be closed by the user. | |
"filled", "filledlight", "gradient", "outlined" | 'filled' | This field specifies the design type of the component. | |
"danger", "info", "neutral", "success", "warning" | 'neutral' | Defines the visual variant of the alert. |
Slots​
Name | Description |
---|---|
footer-action | Custom actions template to default footer. |
right-action | Custom actions template to right content. |