Button¶
Button
component creates a button element in the sidebar content. It will emit click event that user can subscribe to using INKAPI.addEvent
.
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import INKAPI from './inkapi.js'
INKAPI.ready(async () => {
const UI = INKAPI.ui;
const sidebarObj = await UI.create({
type: "Sidebar",
sidebarTitle: "Personal Sidebar",
icon: "./sample.svg",
children: [
{
type: "Button",
id: "myBtn",
text: "Publish",
styles: {
"border-radius": "5px",
}
},
],
});
console.log(sidebarObj);
});
|
Options¶
Name |
Type |
Description |
---|---|---|
id? |
|
You can assign a unique id to the component. It will be helpful for listening to events and removing component in future. If |
type |
|
This field should be passed |
text |
|
Text content of the button element. |
image? |
|
You can pass your image source url (relative to the assets folder in your plugin src directory) here. This will make button act like clickable image. |
rightIcon? |
|
You can pass your icon image source url here, to be placed on the right side of button. |
tooltip? |
|
The string passed in this param will be displayed as a tooltip for the button element. |
leftIcon? |
|
You can pass your icon image source url here, to be placed on the left side of button. |
styles? |
|
Custom styles for the root element. |
textStyles? |
|
Custom styles for the inner text element. |
rightIconStyles? |
|
Custom styles for the right icon element. |
leftIconStyles? |
|
Custom styles for the left icon element. |
Shadow Methods¶
Methods |
Arguments |
Description |
---|---|---|
changeText |
text: |
Using this function plugin can change the text label of the button. |
setStyles |
styles: |
This function is use to apply styles to the root of the element. |
Events¶
Event Keyword |
Description |
---|---|
click |
This event is triggered when the button is clicked. |
mouseenter |
This event is triggered when the mouse cursor enters the button element. |
mouseleave |
This event is triggered when the mouse cursor leaves the button element. |
Note
To learn more about shadow methods and shadow objects, please refer here.