import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = { phrase: String }
confirm(event) {
const phrase = this.phraseValue || "DELETE"
const typed = window.prompt(`Type ${phrase} to confirm`)
if (typed !== phrase) event.preventDefault()
}
}
<%= button_to "Delete", snip_path(@snip), method: :delete,
data: { controller: "confirm", confirm_phrase_value: "DELETE", action: "confirm#confirm" } %>
Turbo supports data-turbo-confirm, but sometimes you want a stronger confirmation step (type-to-confirm, extra context, multi-step). Stimulus lets you implement consistent confirmations without sprinkling JS across views.