Polymer-paper-checkbox

提供:Dev Guides
移動先:案内検索

ポリマー-ペーパーチェックボックス

paper-checkboxは、チェックボックスをオンまたはオフにします。 通常、チェックボックスはセットから複数のオプションを選択するために使用されます。 ディレクトリでpaper-checkboxを取得するには、コマンドプロンプトで次のコマンドを使用する必要があります。

bower install --save PolymerElements/paper-checkbox

次の例では、Polymer.jsでpaper-checkbox要素の使用を指定しています。 indexlファイルを作成し、その中に次のコードを追加します。

<!doctype html>
<html>
   <head>
      <link rel = 'import' href = 'my-appl'>
   </head>

   <body>
      <h2>Paper-Card Example</h2>
      <my-app></my-app>
   </body>
</html>

次に、my-applファイルを開き、次のコードを含めます。

<link rel = 'import' href = 'bower_components/polymer/polymerl'>
<link rel = "import" href = "bower_components/paper-button/paper-buttonl">
<link rel = "import" href = "bower_components/paper-styles/paper-stylesl">
<link rel = "import" href = "bower_components/paper-card/paper-cardl">
<link rel = "import" href = "bower_components/iron-icons/iron-iconsl">
<link rel = "import" href = "bower_components/iron-icons/communication-iconsl">
<link rel = "import" href = "bower_components/paper-checkbox/paper-checkboxl">
<dom-module id = 'my-app'>

   <template>
      <style is = "custom-style">
         paper-checkbox {
            font-family: 'Roboto', sans-serif;
            margin: 24px;
         }
         paper-checkbox.styled {
            align-self: center;
            border: 1px solid var(--paper-green-200);
            padding: 8px 16px;
            --paper-checkbox-checked-color: var(--paper-green-500);
            --paper-checkbox-checked-ink-color: var(--paper-green-500);
            --paper-checkbox-unchecked-color: var(--paper-green-900);
            --paper-checkbox-unchecked-ink-color: var(--paper-green-900);
            --paper-checkbox-label-color: var(--paper-green-500);
            --paper-checkbox-label-spacing: 0;
            --paper-checkbox-margin: 8px 16px 8px 0;
            --paper-checkbox-vertical-align: top;
         }
      </style>

      <paper-checkbox class = "styled">
         Checkbox With a long label
      </paper-checkbox>
      <paper-checkbox disabled>Disabled</paper-checkbox>
   </template>

   <script>
      Polymer ({
         is: 'my-app',
         ready: function() {
            this.async(function() {
            });
         }
      });
   </script>
</dom-module>

出力

アプリケーションを実行するには、作成されたプロジェクトディレクトリに移動し、次のコマンドを実行します。

polymer serve

ここでブラウザを開き、 http://127.0.0.1:8081/ に移動します。 出力は次のようになります。

ポリマーpaper_checkbox