Stripe Apps の Switch コンポーネント
Checkbox と同様に、Switch を使用して boolean 値の指定または制御を行うことができます。
Switch
コンポーネントをアプリに追加するには、以下のようにします。
import {Switch} from '@stripe/ui-extension-sdk/ui';
Switch (スイッチ) は一般に、すぐに保存する設定に使用されます。そのため、Switch
が、別々に送信する必要がある大規模なフォームの構成部分になることは稀です。
Switch
の単純な例を次に示します。
<Switch label="This is a Switch." onChange={(e) => { console.log(e.target.checked); }} />
Switch props
プロパティー | タイプ |
---|---|
| オプション
If |
| オプション
Controls whether the input is selected. When you pass this prop, you must also pass an |
| オプション
Specifies the initial value that a user can change. |
| オプション
コントロールのラベルの横にレンダリングされる説明テキスト。 |
| オプション
要素を無効化するかどうかを設定します。選択できなくなります。 |
| オプション
コントロールの下に表示されるエラーテキスト。 |
| オプション
Specifies the |
| オプション
指定した要素を視覚的に非表示にします。非表示の要素は引き続き存在しており、スクリーンリーダーに表示されます。 |
| オプション
要素が無効な状態であるかどうかを設定します。これは、表示専用のプロパティであり、フォーム送信を妨げるものではありません。 |
| オプション
コントロールを説明するテキスト。表示され、クリック可能になります。 |
| オプション
Specifies the name for this input that’s submitted with the form. |
| オプション
Required for controlled inputs. Fires immediately when the input’s value is changed by the user (for example, it fires on every keystroke). Behaves like the browser input event. |
| オプション
If |
| オプション
If |
| オプション
Overrides the default tab key behavior. Avoid using values other than |
| オプション
Controls the input’s text. When you pass this prop, you must also pass an |
ステータス管理
Use the Switch
component as an uncontrolled input:
<Switch onChange={(e) => { console.log(e.target.checked); }} defaultChecked label="This Switch is uncontrolled." />
無効化
Switch
コンポーネントは無効化でき、これにより変更できなくなります。
<Switch label="This Switch is disabled." defaultChecked disabled />