Captain is currently in ALPHA. We are happy to get your feedback
SDK
Run Button

Module: run-button

Table of contents

Functions

Functions

RunButton

RunButton(props): ReactElement<any, string | JSXElementConstructor<any>>

RunButton is a component that toggles between a 'Start' and 'Stop' state with an option to show progress. It provides visual feedback to the user through icons and optional progress indicators, indicating the current state of a process such as starting or stopping an operation.

Parameters

NameTypeDescription
propsObjectThe properties passed to the RunButton component.
props.disabledundefined | booleanIf true, the button will be disabled and not clickable.
props.isLoadingundefined | booleanIf true, a CircularProgress indicator will be shown on the button, indicating ongoing activity or processing.
props.isRunningundefined | booleanDetermines the state of the button. If true, the button represents a 'Stop' action, otherwise a 'Start' action.
props.labelsundefined | ObjectLabels for the button in different states.
props.onStartFunctionFunction to call when the start button is clicked, initiating a process.
props.onStopFunctionFunction to call when the stop button is clicked, terminating a process. The component switches its appearance and functionality based on the isRunning and isLoading props, showing a play icon for start and a stop icon for stop. It is designed for use in applications where start/stop actions control significant processes, like media playback or task execution.

Returns

ReactElement<any, string | JSXElementConstructor<any>>

Example

<RunButton
  isRunning={isTaskRunning}
  onStart={() => startTask()}
  onStop={() => stopTask()}
  isLoading={isTaskProcessing}
  labels={{ start: "Activate", stop: "Terminate" }}
/>

This example sets up a RunButton to control a task, with custom labels for starting and stopping the task.

Defined in

node_modules/@captn/joy/dist/esm/run-button/index.js:37