Button
TkButton is an extension to standard input element with icons and theming.
- React
- Vue
- Angular
import { TkButton } from '@takeoff-ui/react'
import { TkButton } from '@takeoff-ui/vue'
import { TkButton } from '@takeoff-ui/angular'
Playground
Preview
Generated Code
<TkButton variant="primary" size="base" type="filled" mode="button" iconPosition="left" label="Hello World!"/><TkButton variant="primary" size="base" type="filled" mode="button" iconPosition="left" label="Hello World!"/><tk-button variant="primary" size="base" type="filled" mode="button" iconPosition="left" label="Hello World!"/>Controls
Variant
The variant of the badge for styling.
- React
- Vue
- Angular
<div style={{ marginBottom: "16px", display: "flex", gap: "8px" }}>
<TkButton variant="primary" label="Primary" />
<TkButton variant="secondary" label="Secondary" />
<TkButton variant="neutral" label="Neutral" />
<TkButton variant="info" label="Info" />
<TkButton variant="success" label="Success" />
<TkButton variant="danger" label="Danger" />
<TkButton variant="warning" label="Warning" />
</div>
<div style='margin-bottom: 16px; display: flex; gap: 8px;'>
<TkButton variant="primary" label="Primary" />
<TkButton variant="secondary" label="Secondary" />
<TkButton variant="neutral" label="Neutral" />
<TkButton variant="info" label="Info" />
<TkButton variant="success" label="Success" />
<TkButton variant="danger" label="Danger" />
<TkButton variant="warning" label="Warning" />
</div>
<div style="margin-bottom: 16px; display: flex; gap: 8px">
<tk-button variant="primary" label="Primary" />
<tk-button variant="secondary" label="Secondary" />
<tk-button variant="neutral" label="Neutral" />
<tk-button variant="info" label="Info" />
<tk-button variant="success" label="Success" />
<tk-button variant="danger" label="Danger" />
<tk-button variant="warning" label="Warning" />
</div>
Type
This prop specifies the design type of the component. "filled", "outlined", "text" designs are available.
- React
- Vue
- Angular
<TkButton variant="primary" label="Primary" type="filled" />
<TkButton variant="primary" label="Primary" type="outlined" />
<TkButton variant="primary" label="Primary" type="text" />
<TkButton variant="primary" label="Primary" type="filled" />
<TkButton variant="primary" label="Primary" type="outlined" />
<TkButton variant="primary" label="Primary" type="text" />
<tk-button variant="primary" label="Primary" type="filled" />
<tk-button variant="primary" label="Primary" type="outlined" />
<tk-button variant="primary" label="Primary" type="text" />
Full Width
Sets the button width to full width.
- React
- Vue
- Angular
<TkButton variant="primary" label="Full Width Button" fullWidth />
<TkButton variant="primary" label="Full Width Button" fullWidth />
<tk-button variant="primary" label="Full Width Button" fullWidth />
Size
The "size" prop can be used with one of the sizes "small", "base", and "large". The default value is "base".
- React
- Vue
- Angular
<TkButton variant="primary" size="small" label="small button" />
<TkButton variant="primary" size="base" label="base button" />
<TkButton variant="primary" size="large" label="large button" />
<TkButton variant="primary" size="small" label="small button" />
<TkButton variant="primary" size="base" label="base button" />
<TkButton variant="primary" size="large" label="large button" />
<tk-button variant="primary" size="small" label="small button" />
<tk-button variant="primary" size="base" label="base button" />
<tk-button variant="primary" size="large" label="large button" />
Icon
It can be used with icons. You can also specify the icon direction. You should use Material Symbols icons.
- React
- Vue
- Angular
<TkButton
variant="primary"
size="large"
icon="flight"
label="left icon"
/>
<TkButton
variant="primary"
size="large"
icon="flight"
iconPosition="right"
label="right icon"
/>
<TkButton
variant="primary"
size="large"
label="multiple icons"
icon={{
left: { name: 'key', color: 'pink' },
right: { name: 'check_circle', color: 'pink', fill: true }
}}
/>
<TkButton
variant="primary"
size="large"
icon="flight"
label="left icon"
/>
<TkButton
variant="primary"
size="large"
icon="flight"
iconPosition="right"
label="right icon"
/>
<TkButton
variant="primary"
size="large"
label="multiple icons"
:icon="{ left: { name: 'key', color: 'pink' }, right: { name: 'check_circle', color: 'pink', fill: true } }"
/>
<tk-button
variant="primary"
size="large"
icon="flight"
label="left icon"
/>
<tk-button
variant="primary"
size="large"
icon="flight"
iconPosition="right"
label="right icon"
/>
<tk-button
variant="primary"
size="large"
label="multiple icons"
[icon]="{ left: { name: 'key', color: 'pink' }, right: { name: 'check_circle', color: 'pink', fill: true } }"
></tk-button>
Mode
The mode prop can be used to set the button's behavior. The available options are button, link, submit, and reset. The default value is button.
- React
- Vue
- Angular
import { TkButton, TkInput } from '@takeoff-ui/react';
import { showPersistentToast, IToast } from '@takeoff-ui/core';
import React from 'react';
const handleMultiplePersistent = (position: string, variant: string, id: string) => {
showPersistentToast({
persistentId: id,
position: position,
header: `${variant.toUpperCase()} Persistent Toast`,
message: `Your form submitted successfully.`,
variant: variant,
type: 'filled',
removable: true,
});
};
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
handleMultiplePersistent('top-right', 'info', 'persistent-info');
};
const ExampleForm = (
<form onSubmit={handleSubmit}>
<div className="flex flex-col flex-wrap gap-2">
<div className="flex flex-col gap-2">
<TkInput label="Name" size="small" />
<TkInput label="Surname" size="small" />
<TkInput label="Password" mode="password" size="small" />
</div>
<div className="flex flex-row justify-center gap-8">
<TkButton mode="reset" label="Reset" />
<TkButton mode="submit" label="Submit" />
</div>
</div>
</form>
);
return (
<div className="flex flex-row items-center gap-4">
<div className="basis-1/5">
<TkButton mode="button" label="Button" />
</div>
<div className="basis-1/5">
<TkButton
mode="link"
label="Link"
href="https://github.com/turkishtechnology/takeoff-ui"
target="_blank"
/>
</div>
<div className="inline-block h-[250px] min-h-[1em] w-0.5 self-stretch bg-gray-300"></div>
<div className="basis-3/5">{ExampleForm}</div>
</div>
);
<script setup>
import { TkButton, TkInput } from '@takeoff-ui/vue';
import { showPersistentToast } from '@takeoff-ui/core';
const handleMultiplePersistent = (position, variant, id) => {
showPersistentToast({
persistentId: id,
position: position,
header: `${variant.toUpperCase()} Persistent Toast`,
message: `Your form submitted successfully.`,
variant: variant,
type: 'filled',
removable: true,
});
};
const handleSubmit = (e) => {
e.preventDefault();
handleMultiplePersistent('top-right', 'info', 'persistent-info');
};
</script>
<template>
<div class="flex flex-row items-center gap-4">
<div class="basis-1/5">
<TkButton mode="button" label="Button" />
</div>
<div class="basis-1/5">
<TkButton
mode="link"
label="Link"
href="https://github.com/turkishtechnology/takeoff-ui"
target="_blank"
/>
</div>
<div class="inline-block h-[250px] min-h-[1em] w-0.5 self-stretch bg-gray-300"></div>
<div class="basis-3/5">
<form @submit="handleSubmit">
<div class="flex flex-col flex-wrap gap-2">
<div class="flex flex-col gap-2">
<TkInput label="Name" size="small" />
<TkInput label="Surname" size="small" />
<TkInput label="Password" mode="password" size="small" />
</div>
<div class="flex flex-row justify-center gap-8">
<TkButton mode="reset" label="Reset" />
<TkButton mode="submit" label="Submit" />
</div>
</div>
</form>
</div>
</div>
</template>
import { Component } from '@angular/core';
import { showPersistentToast } from '@takeoff-ui/core';
@Component({
selector: 'app-button-mode',
template: `
<div class="flex flex-row items-center gap-4">
<div class="basis-1/5">
<tk-button mode="button" label="Button"></tk-button>
</div>
<div class="basis-1/5">
<tk-button
mode="link"
label="Link"
href="https://github.com/turkishtechnology/takeoff-ui"
target="_blank">
</tk-button>
</div>
<div class="inline-block h-[250px] min-h-[1em] w-0.5 self-stretch bg-gray-300"></div>
<div class="basis-3/5">
<form (submit)="handleSubmit($event)">
<div class="flex flex-col flex-wrap gap-2">
<div class="flex flex-col gap-2">
<tk-input label="Name" size="small"></tk-input>
<tk-input label="Surname" size="small"></tk-input>
<tk-input label="Password" mode="password" size="small"></tk-input>
</div>
<div class="flex flex-row justify-center gap-8">
<tk-button mode="reset" label="Reset"></tk-button>
<tk-button mode="submit" label="Submit"></tk-button>
</div>
</div>
</form>
</div>
</div>
`,
})
export class ButtonModeComponent {
handleMultiplePersistent(position: string, variant: string, id: string) {
showPersistentToast({
persistentId: id,
position: position,
header: `${variant.toUpperCase()} Persistent Toast`,
message: `Your form submitted successfully.`,
variant: variant,
type: 'filled',
removable: true,
});
}
handleSubmit(e: Event) {
e.preventDefault();
this.handleMultiplePersistent('top-right', 'info', 'persistent-info');
}
}
API
Props
| Name | Type | Default | Description |
|---|---|---|---|
boolean | null | Disables the button, preventing user interaction. | |
boolean | null | Sets the button to full-width mode, making it span the container. | |
string | null | Sets the URL the button should navigate to when clicked (for type="link" buttons). | |
IIconOptions, IMultiIconOptions, string | null | Specifies a material icon name to be displayed. | |
"left", "right" | 'left' | Defines the position of the icon. | |
string | '' | Label text displayed inside the button. | |
boolean | null | Shows a loading icon inside the button. | |
"button", "link", "reset", "submit" | 'button' | Sets the button type. | |
boolean | null | Makes the button round with an icon-only style. | |
"base", "large", "small" | 'base' | Sets size for the component. | |
string | null | Specifies where to open the linked document (for type="link" buttons). | |
"elevated", "filled", "outlined", "text" | 'filled' | This field specifies the design type of the component. | |
boolean | null | Applies underline styling to the button label regardless of mode. | |
"danger", "info", "neutral", "primary", "secondary", "success", "warning", "white" | 'primary' | Determines the button's variant for different styles. |
Events
| Name | Description |
|---|---|
| tk-click | Emitted when the button click. |