The Button is a graphical user interface element that triggers an event on its click action. It can contain a text, an image, or both.
<button id="button">Button</button>
<script>
var btnObj = new Button();
btnObj.appendTo("#button");
</script>
string
Defines the text content
of the Button element.
<button id="primarybtn"></button>
import { Button } from '@syncfusion/ej2-buttons';
let button: Button = new Button({content: 'JasButton'});
button.appendTo('#normalbtn');
Defaults to ""
string
Defines class/multiple classes separated by a space in the Button element. The Button types, styles, and
size can be defined by using
this
.
<button id="flatbtn">Flat</button>
import { Button } from '@syncfusion/ej2-buttons';
let button = new Button({ cssClass: 'e-flat e-primary' });
button.appendTo('#flatbtn');
Defaults to ""
boolean
Specifies a value that indicates whether the Button is disabled
or not.
Defaults to false.
boolean
Specifies whether to enable the rendering of untrusted HTML values in the Button component. If ‘enableHtmlSanitizer’ set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
Defaults to true
boolean
Enable or disable persisting component’s state between page reloads.
Defaults to false
boolean
Enable or disable rendering component in right to left direction.
Defaults to false
string
Defines class/multiple classes separated by a space for the Button that is used to include an icon. Buttons can also include font icon and sprite image.
Defaults to ""
string
| IconPosition
Positions the icon before/after the text content in the Button. The possible values are:
Defaults to IconPosition.Left
boolean
Allows the appearance of the Button to be enhanced and visually appealing when set to true
.
Defaults to false
boolean
Makes the Button toggle, when set to true
. When you click it, the state changes from normal to active.
Defaults to false
Adds the handler to the given event listener.
Parameter | Type | Description |
---|---|---|
eventName | string |
A String that specifies the name of the event |
handler | Function |
Specifies the call to run when the event occurs. |
Returns void
Appends the control within the given HTML element
Parameter | Type | Description |
---|---|---|
selector (optional) | string | HTMLElement |
Target element where control needs to be appended |
Returns void
Adding unload event to persist data when enable persistence true
Returns void
Click the button element its native method
Returns void
When invoked, applies the pending property changes immediately to the component.
Returns void
Destroys the widget.
Returns void
Removing unload event to persist data when enable persistence true
Returns void
Sets the focus to Button its native method
Returns void
Returns the persistence data for component
Returns any
Returns the route element of the component
Returns HTMLElement
Handling unload event to persist data when enable persistence true
Returns void
Applies all the pending property changes and render the component again.
Returns void
Removes the handler from the given event listener.
Parameter | Type | Description |
---|---|---|
eventName | string |
A String that specifies the name of the event to remove |
handler | Function |
Specifies the function to remove |
Returns void
EmitType<Event>
Triggers once the component rendering is completed.