@playcanvas/pcui
Version:
User interface component library for the web
70 lines (69 loc) • 1.98 kB
TypeScript
import { Element, ElementArgs } from '../Element';
/**
* The arguments for the {@link Button} constructor.
*/
interface ButtonArgs extends ElementArgs {
/**
* If `true`, the {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML innerHTML} property will be
* used to set the text. Otherwise, {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent textContent}
* will be used instead. Defaults to `false`.
*/
unsafe?: boolean;
/**
* Sets the text of the button. Defaults to ''.
*/
text?: string;
/**
* The CSS code for an icon for the button. e.g. 'E401' (notice we omit the '\\' character). Defaults to ''.
*/
icon?: string;
/**
* Sets the 'size' type of the button. Can be 'small' or `null`. Defaults to `null`.
*/
size?: 'small';
}
/**
* User input with click interaction.
*/
declare class Button extends Element {
protected _unsafe: boolean;
protected _text: string;
protected _icon: string;
protected _size: string | null;
/**
* Creates a new Button.
*
* @param args - The arguments.
*/
constructor(args?: Readonly<ButtonArgs>);
destroy(): void;
protected _onKeyDown: (evt: KeyboardEvent) => void;
protected _onClick(evt: Event): void;
focus(): void;
blur(): void;
/**
* Sets the text of the button.
*/
set text(value: string);
/**
* Gets the text of the button.
*/
get text(): string;
/**
* Sets the CSS code for an icon for the button. e.g. 'E401' (notice we omit the '\\' character).
*/
set icon(value: string);
/**
* Gets the CSS code for an icon for the button.
*/
get icon(): string;
/**
* Sets the 'size' type of the button. Can be null or 'small'.
*/
set size(value: string);
/**
* Gets the 'size' type of the button.
*/
get size(): string;
}
export { Button, ButtonArgs };