nteract elements

PlayButton

Cell execution control button that shows Play, Stop, or Loading states based on execution state

A button component for executing notebook cells. Shows different icons based on the current execution state:

  • Play icon when idle, completed, or in error state
  • Square (stop) icon when running or queued
  • Loader spinner when auto-launching the runtime

Installation

npx shadcn@latest add https://nteract-elements.vercel.app/r/play-button.json

Copy from nteract/elements.

Usage

import { PlayButton } from "@/registry/cell/PlayButton"

export function CellToolbar() {
  return (
    <PlayButton
      executionState="idle"
      cellType="code"
      onExecute={() => console.log("Execute cell")}
      onInterrupt={() => console.log("Interrupt execution")}
    />
  )
}

Examples

Idle State

<PlayButton
  executionState="idle"
  cellType="code"
  onExecute={handleExecute}
  onInterrupt={handleInterrupt}
/>

Running State

<PlayButton
  executionState="running"
  cellType="code"
  onExecute={handleExecute}
  onInterrupt={handleInterrupt}
/>

Auto-launching

<PlayButton
  executionState="idle"
  cellType="code"
  onExecute={handleExecute}
  onInterrupt={handleInterrupt}
  isAutoLaunching
/>

Focused State

<PlayButton
  executionState="idle"
  cellType="code"
  isFocused
  onExecute={handleExecute}
  onInterrupt={handleInterrupt}
/>

Props

PropTypeDefaultDescription
executionState"idle" | "queued" | "running" | "completed" | "error"Current execution state of the cell
cellTypestringType of cell (e.g., "code", "markdown") for tooltip
isFocusedbooleanfalseWhether the cell is focused
onExecute() => voidCallback when play button is clicked
onInterrupt() => voidCallback when stop button is clicked
classNamestring""Additional CSS classes
focusedClassstring"text-foreground"CSS class applied when focused
isAutoLaunchingbooleanfalseShows loading spinner and disables button

On this page