ButtonComponent
9 Jul 20263 minutes to read
Represents the Angular Button Component.
<button ejs-button>Button</button>Properties
content string
Defines the text content of the Button element.
<button ejs-button [content]="content_normal">Normal</button>import { Component, ViewEncapsulation } from "@angular/core";
import { ButtonComponent } from "@syncfusion/ej2-angular-buttons";
/**
* Default Button Controller
*/
@Component({
selector: "app-root",
templateUrl: "app.component.html",
styleUrls: ["app.component.css"],
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
public content_normal = "Normal";
constructor() {}
}Defaults to ””
cssClass 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 ejs-button [cssClass]="flat_class" isPrimary="true">Flat</button> import { Component, ViewEncapsulation } from "@angular/core";
import { ButtonComponent } from "@syncfusion/ej2-angular-buttons";
/**
* Default Button Controller
*/
@Component({
selector: "app-root",
templateUrl: "app.component.html",
styleUrls: ["app.component.css"],
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
public flat_class = "e-flat";
constructor() {}
}Defaults to ””
disabled boolean
Specifies a value that indicates whether the Button is disabled or not.
Defaults to false.
enableHtmlSanitizer 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
enablePersistence boolean
Enable or disable persisting component’s state between page reloads.
Defaults to false
enableRepeat boolean
Enables hold-to-repeat behavior on the Button when set to true.
While the button is held down (pointer or keyboard), repeated clicked events are fired
at the rate controlled by repeatDelay and repeatInterval.
Defaults to false
enableRtl boolean
Enable or disable rendering component in right to left direction.
Defaults to false
iconCss 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 ””
iconPosition string|IconPosition
Positions the icon before/after the text content in the Button.
The possible values are:
- Left: The icon will be positioned to the left of the text content.
- Right: The icon will be positioned to the right of the text content.
Defaults to IconPosition.Left
isPrimary boolean
Allows the appearance of the Button to be enhanced and visually appealing when set to true.
Defaults to false
isToggle boolean
Makes the Button toggle, when set to true. When you click it, the state changes from normal to active.
Defaults to false
repeatDelay number
Specifies the delay in milliseconds before repeat firing begins after the initial press.
Only applicable when enableRepeat is true.
Changes to this property take effect on the next hold cycle.
Defaults to 400
repeatInterval number
Specifies the interval in milliseconds between repeated clicked fires during a hold.
When set to 0 (default), pointer repeat uses 100ms; keyboard repeat defers to the native OS rate.
Changes to this property take effect on the next hold cycle.
Defaults to 0
Methods
click
Click the button element
its native method
Returns void
destroy
Destroys the widget.
Returns void
focusIn
Sets the focus to Button
its native method
Returns void
Events
clicked EmitType<ClickedEventArgs>
Triggers on every click fire — both the initial press and each repeat while the button is held.
The event argument carries originalEvent (the originating DOM event) and isRepeat
(false for the first press, true for subsequent repeat fires).
Only emitted when enableRepeat is true.
created EmitType<Event>
Triggers once the component rendering is completed.