メインコンテンツまでスキップ
バージョン: 1.17.0

Button

Overview

Button は、ボタンを表示します。


Specification

Property

使用できるプロパティの一覧です。プロパティを指定して値を更新することができます。

NameTypeDefaultDescriptionRemark
classNamestring""コンポーネントの class 名
idstring""コンポーネントの id 名
textstring""ボタンに表示するテキストcontent が未指定の場合、text が表示される
その他の場合、text は無視される
typestring"normal"ボタンのデザインタイプ以下を指定できる
"normal" : Gray(#f7f9fA)
"submit" : Blue(#3498db)
"alert" : Red(#e74c3c)
content *1string/HTMLElement""ボタン内の DOMHTML が記載された string を指定した場合、自動的に HTML に変換してそのまま表示される
disabledbooleanfalseコンポーネントの編集可/不可設定
visiblebooleantrueコンポーネントの表示/非表示設定
注意

*1: kintone UI Component はこのプロパティの値を内部的にサニタイズしていません。ユーザー入力を受け付けるような実装でこのプロパティを使用する場合は、開発者自身で XSS 対策をしてください。

Event

指定できるイベントの一覧です。

NameTypeDescriptionRemark
clickfunctionクリックされた時のイベントハンドラ引数には Event の event オブジェクトをとる

Constructor

Button(options)
使用できるコンストラクタの一覧です。

Parameter

NameTypeDefaultDescriptionRemark
optionsobject{}コンポーネントのプロパティを含むオブジェクト

Custom CSS

ヒント

Custom CSS をご確認ください。

コンポーネントのスタイルを変更するために使用できるプロパティの一覧です。

Property

Name
--kuc-button-width
--kuc-button-height
--kuc-button-background-color
--kuc-button-background-color-hover
--kuc-button-background-color-active
--kuc-button-background-color-focus
--kuc-button-font-size
--kuc-button-text-color

Sample Code

ヒント

導入と実装方法 をご確認ください。

全てのパラメータを指定した場合のサンプルコードです。

const Kuc = Kucs['1.x.x'];

const header = kintone.app.getHeaderMenuSpaceElement();

const button = new Kuc.Button({
text: 'Submit',
type: 'submit',
content: `<div>
<svg>...</svg>
<span>Search</span>
</div>;`,
className: 'options-class',
id: 'options-id',
visible: true,
disabled: false
});
header.appendChild(button);

button.addEventListener('click', event => {
console.log(event);
});