Accéder directement au contenu
Créez un compte
ou
connecter-vous
Logo de la documentation Stripe
/
Demander à l'assistant IA
Créez un compte
Connectez-vous
Démarrer
Paiements
Revenus
Plateformes et places de marché
Gestion de fonds
Outils de développement
Aperçu
Gestion des versions
Journal des modifications
Mettre à niveau votre version de l'API
Actualiser votre version du SDK
Outils de développement
SDK
API
Tests
Workbench
Destinations d'événements
Workflows
CLI Stripe
Shell Stripe
Dashboard des développeurs
Boîte à outils des agents
Intégrer des LLMStripe pour Visual Studio CodeAlertes d'intégrité de StripeChargements de fichiers
Sécurité et confidentialité
Sécurité
Confidentialité
Extensions Stripe
Stripe Apps
    Présentation
    Démarrer
    Créer une application
    Fonctionnement de Stripe Apps
    Exemples d'application
    Créer une application
    Enregistrer des clés secrètes
    Méthodes d'authentification de l'API
    Flux d'autorisation
    Logique côté serveur
    Écouter les événements
    Gérer différents modes
    Activer la prise en charge de l'environnement de test
    Page des paramètres d'application
    Concevoir une interface utilisateur
    Inscription des utilisateurs
    Distribuer votre application
    Options de distribution
    Charger votre application
    Versions
    Tester votre application
    Publier votre application
    Faire la promotion de votre application
    Ajouter des liens profonds
    Créer des liens d'installation
    Assigner des rôles dans les extensions d'interface utilisateur
    Actions post-installation
    Analyses de l'application
    Composants intégrés pour les applications
    Intégrer des applications tierces conçues pour Stripe
    Migrer vers Stripe Apps
    Migrer ou développer une extension
    Migrer un plugin vers Stripe Apps ou Stripe Connect
    Référence
    Manifeste de l'application
    Interface de ligne de commande
    SDK d'extension
    Autorisations
    Fenêtres d'affichage
    Modèles de conception
    Composants
      Accordéon
      Badge
      Bannière
      BarChart
      Composant box
      Bouton
      ButtonGroup
      Case à cocher
      Puce
      ContextView
      DateField
      Séparateur
      FocusView
      FormFieldGroup
      Icône
      Img
      Inline
      LineChart
      Link
      Liste
      Menu
      PropertyList
      Radio
      Sélectionner
      SettingsView
      SignInView
      Sparkline
      Indicateur de chargement
      Changer
      Table
      Onglets
      Liste des tâches
      TextArea
      TextField
      Message transitoire
      Infobulle
Connecteurs Stripe
Partenaires
Partner ecosystem
Certification des partenaires
AccueilOutils de développementStripe AppsComponents

Remarque

Cette page n'est pas encore disponible dans cette langue. Nous faisons tout notre possible pour proposer notre documentation dans davantage de langues et nous vous fournirons la version traduite dès qu'elle sera disponible.

Checkbox component for Stripe Apps

Use checkboxes to indicate or control boolean values.

Copier la page

To add the Checkbox component to your app:

import {Checkbox} from '@stripe/ui-extension-sdk/ui';
Chargement de l'exemple...
<Checkbox label="This is a Checkbox." onChange={(e) => { console.log(e.target.checked); }} />

Checkbox takes the following props, in addition to all the appropriate native DOM attributes.

Checkbox props

PropertyType

autoFocus

Optional

boolean | undefined

If true, React will focus the element on mount.

checked

Optional

boolean | undefined

Controls whether the input is selected. When you pass this prop, you must also pass an onChange handler that updates the passed value.

defaultChecked

Optional

boolean | undefined

Specifies the initial value that a user can change.

description

Optional

string | undefined

Descriptive text that will be rendered adjacent to the control’s label.

disabled

Optional

boolean | undefined

Sets whether or not the element should be disabled. Prevents selection.

error

Optional

string | undefined

Error text that will be rendered below the control.

form

Optional

string | undefined

Specifies the id of the <form> this input belongs to. If omitted, it’s the closest parent form.

hiddenElements

Optional

("label" | "description" | "error")[] | undefined

Visually hides the specified elements. The hidden elements will still be present and visible to screen readers.

indeterminate

Optional

boolean | undefined

Sets whether the Checkbox should be rendered as indeterminate (“partially checked”) or not. Note that this is purely visual, and will not change the actual checked state of the Checkbox. If a Checkbox is both indeterminate and checked, it will display as indeterminate.

invalid

Optional

boolean | undefined

Sets whether or not the element is in an invalid state. This is a display-only prop, and will not prevent form submission.

label

Optional

React.ReactNode

Text that describes the control. Will be both visible and clickable.

name

Optional

string | undefined

Specifies the name for this input that’s submitted with the form.

onChange

Optional

((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined

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.

readOnly

Optional

boolean | undefined

If true, the input is not editable by the user.

required

Optional

boolean | undefined

If true, the value must be provided for the form to submit.

tabIndex

Optional

number | undefined

Overrides the default tab key behavior. Avoid using values other than -1 and 0.

value

Optional

string | undefined

Controls the input’s text. When you pass this prop, you must also pass an onChange handler that updates the passed value.

You can set a Checkbox component to different states:

  • indeterminate
  • disabled
  • invalid

Indeterminate

The Checkbox component can be in an indeterminate state. This is useful when it represents the aggregated state of some other set of checkboxes, of which some may be checked and some may not. Note that this property is purely visual, and does not affect the Checkbox’s underlying checked state.

Chargement de l'exemple...
const [checked1, setChecked1] = React.useState(false); const [checked2, setChecked2] = React.useState(true); const allChecked = checked1 && checked2; const handleAggregateChange = () => { if (checked1 && checked2) { setChecked1(false); setChecked2(false); } else { setChecked1(true); setChecked2(true); } }; return ( <Box css={{ stack: 'y', }} > <Checkbox label="This Checkbox is aggregating the state of the Checkboxes below it." checked={allChecked} indeterminate={checked1 !== checked2} onChange={handleAggregateChange} /> <Checkbox label="Checkbox 1" checked={checked1} onChange={(e) => { setChecked1(e.target.checked); }} /> <Checkbox label="Checkbox 2" checked={checked2} onChange={(e) => { setChecked2(e.target.checked); }} /> </Box> )

Disabled

Checkbox can be disabled. This prevents changes.

Chargement de l'exemple...
<Checkbox label="This Checkbox is disabled." defaultChecked disabled /> <Checkbox disabled invalid label="This invalid Checkbox is disabled." />

Invalid

You can mark a Checkbox component as invalid. This is a styling-only prop, useful in form validation. It won’t prevent form submission.

Chargement de l'exemple...
<Checkbox label="This Checkbox is in an invalid state." invalid />

State management

Use the Checkbox component as an uncontrolled input:

Chargement de l'exemple...
<Checkbox onChange={(e) => { console.log(e.target.checked); }} defaultChecked label="This Checkbox is uncontrolled." />

Voir aussi

  • Design patterns to follow
  • Style your app
  • UI testing
Cette page vous a-t-elle été utile ?
OuiNon
Besoin d'aide ? Contactez le service Support.
Rejoignez notre programme d'accès anticipé.
Consultez notre log des modifications.
Des questions ? Contactez l'équipe commerciale.
LLM ? Lire llms.txt.
Propulsé par Markdoc