Stimulus controllers

Behavior that begins in HTML.

Add a data-controller and the behavior loads itself. Use what ships, extend it, take it over or write your own.

How it loads

Discovered from HTML

The identifier in data-controller is enough. Nothing to register.

Imported only when used

Pages that never use an identifier never download it, or its npm dependencies.

Designed to compose

Several controllers share one element and reconnect safely through Turbo renders.

Choose how much you own

Start with what ships. Take on maintenance only when the app needs it.

1

Use what ships

Set a component prop, or add a package identifier to any element. Fixes and updates keep coming from the package.

Any Blade view
{{-- Components configure their controllers through props --}}
<hw:input name="phone" mask="phone-br" />

{{-- Any element can use a package controller by its identifier --}}
<a href="{{ route('posts.create') }}"
   data-controller="hotkey"
   data-action="keydown.n@window->hotkey#click">
    New post
</a>
Browse all 72 controllers
2

Extend it

Subclass a package controller under a new identifier. Import through @hotwire, keep inherited definitions and call the parent lifecycle.

resources/js/controllers/gallery_controller.js
import CarouselController from "@hotwire/carousel_controller";

export default class extends CarouselController {
    static targets = [...CarouselController.targets, "caption"];

    connect() {
        super.connect();
        this.captionTarget.textContent = "Gallery ready.";
    }
}

Try it: the Gallery and its plugins load only when this frame asks for them.

Load Gallery
3

Take it over

Publish a controller under the same identifier when the app must own the implementation. You also take on reviewing upstream changes.

Terminal
php artisan hotwire:controllers carousel
4

Write your own

For behavior only your app has. The filename becomes the identifier: my_custom_controller.js is my-custom.

$ php artisan hotwire:make-controller my-custom

resources/js/controllers/my_custom_controller.js
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
    static targets = ["message"];

    celebrate() {
        this.messageTarget.textContent = "Your controller is running.";
    }
}
Any Blade view
<div data-controller="my-custom">
    <hw:button data-action="my-custom#celebrate">
        Run controller
    </hw:button>

    <p data-my-custom-target="message"></p>
</div>

Compose everything

Package, extended and app controllers cooperate on the same markup. Keep each one focused.

HTML
<section data-controller="gallery my-custom">
    <button data-controller="tooltip" data-action="my-custom#celebrate">
        Celebrate
        <hw:tooltip>A composed experience</hw:tooltip>
    </button>

    <p data-my-custom-target="message"></p>
</section>

Controller catalog

All controllers

Each one opens the reference shipped with the version you installed.

72 controllers

Display

11 controllers

Accordion

accordion

Coordinates native disclosure items in single or multiple mode and blocks disabled items

Animated Number

animated-number

Animates numeric content immediately or once it enters the viewport

Renders responsive Apache ECharts from inline or fetched options with optional polling

echarts

Disclosure

disclosure

Toggles an inline panel, synchronizes ARIA state and emits change events

Lazy Image

lazy-image

Polls for an image URL up to a limit and then renders responsive picture content

Renders Leaflet maps with OpenStreetMap tiles, inline markers or fetched GeoJSON

leaflet

Oembed

oembed

Converts editor-generated oembed tags into YouTube or Vimeo frames and fallback links

Read More

read-more

Measures overflow and synchronizes static, collapsed and expanded preview states

Reveal

reveal

Coordinates load- or viewport-triggered reveal cascades and emits when content appears

Implements ARIA tabs with automatic activation and orientation-aware keyboard navigation

Forms

28 controllers

Auto Resize

auto-resize

Resizes a textarea to fit its content after input, window resize and Turbo renders

Auto Save

auto-save

Saves changed forms with debouncing, status feedback and queued follow-up saves

Auto Select

auto-select

Selects all text in an input when it receives focus

Auto Submit

auto-submit

Submits forms through immediate or debounced actions without duplicate IME commits

Autofocus

autofocus

Focuses a configured field or the first validation error initially and after relevant Turbo Frame loads

Char Counter

char-counter

Displays typed or remaining character counts with live updates

Checkbox

checkbox

Synchronizes native checkbox indeterminate state across changes and Turbo renders

Checkbox Select All

checkbox-select-all

Synchronizes a master checkbox with grouped selections and indeterminate state

Clean Query Params

clean-query-params

Removes empty values from GET form submissions before building the query string

Clear Input

clear-input

Clears a targeted input, controls button visibility and emits input events

Conditional Fields

conditional-fields

Shows and disables dependent fields using declarative value and checkbox-state rules

Error Scroll

error-scroll

Scrolls to the first validation error after Turbo Frame or full-page renders

File Preserve

file-preserve

Restores selected files when a submitted Turbo form re-renders with validation errors

File Upload

file-upload

Uploads validated files through queued requests with JSON or Turbo Stream responses

Input Mask

input-mask

Applies Maska static, dynamic, reverse and custom-token masks to text inputs

maska

Input OTP

input-otp

One-time code editing with digit filtering, paste, visual selection and completion events on a native input

Money Input

money-input

Formats locale-aware money entry and exposes canonical minor-unit values

Multi Select

multi-select

Enhances a native multiple select with search, limits, select-all and floating positioning

@floating-ui/dom

Remote Form

remote-form

Submits a form from a decoupled trigger while preserving submitter metadata

Reset Files

reset-files

Clears opted-in file inputs after successful form submission and a render without validation errors

Rich Text

rich-text

Runs a Tiptap editor with form sync, read-only mode and optional image-upload events

@tiptap/core @tiptap/starter-kit @tiptap/extensions @tiptap/extension-link @tiptap/extension-underline @tiptap/pm

Rich Text Toolbar

rich-text-toolbar

Formats a linked Tiptap editor and synchronizes toolbar ARIA pressed states

Slider

slider

Synchronizes a native range input visual fill after input, reset and Turbo morphs

Autofills and sanitizes a slug from a source field until manual editing, with optional length limits

Toggle

toggle

Synchronizes a two-state button ARIA state and optional hidden form input

Toggle Group

toggle-group

Coordinates single or multiple pressed-button groups and synchronizes form inputs

Unsaved Changes

unsaved-changes

Confirms Turbo Drive navigation away from forms with unsaved changes

Overlay

9 controllers

Alert Dialog

alert-dialog

Guards click actions with an accessible confirmation dialog

Drawer

drawer

Controls an accessible off-canvas overlay with optional Turbo Frame content

Dropdown

dropdown

Controls a responsive floating disclosure panel with selectable-item dismissal

@floating-ui/dom

Hover Card

hover-card

Shows a delayed floating preview on hover or focus with Escape dismissal

@floating-ui/dom

Image Viewer

image-viewer

Enhances image galleries with zoom, pan, pinch and double-tap gestures, rotation/flips, keyboard, side-arrow and thumbnail navigation, tap-to-hide controls on touch screens, and automatic updates after Turbo renders

Controls an accessible modal with optional Turbo Frame-driven content

Popover

popover

Controls an interactive floating panel with focus and dismissal management

@floating-ui/dom

Controls an accessible sheet overlay with optional Turbo Frame content

Tooltip

tooltip

Creates non-interactive ARIA tooltips from templates with anchored positioning

@floating-ui/dom

Feedback

2 controllers

Emits one configured notification through a Toaster

Toaster

toaster

Manages an accessible toast stack with timed dismissal and Turbo Drive persistence

Navigation

3 controllers

Pagination

pagination

Appends server-rendered paginator pages manually or when the fallback link enters view

Side Panel

side-panel

Controls nested inline panel state with ARIA synchronization and optional persistence

Sidebar

sidebar

Controls persisted desktop sidebar state and an accessible mobile overlay

Utility

8 controllers

Back To Top

back-to-top

Reveals a control after a scroll threshold and returns to the top with reduced-motion support

Color Scheme

color-scheme

Persists light, dark or system mode across tabs with optional View Transitions

Copy To Clipboard

copy-to-clipboard

Copies targeted text or input values and shows temporary success feedback

Loads Google Tag Manager immediately or on interaction and pushes data layer events

Hotkey

hotkey

Clicks or focuses its element from shortcuts while ignoring editable input

Scroll Progress

scroll-progress

Updates a progress bar from the document scroll position with optional throttling

Timeago

timeago

Formats localized relative times with optional suffixes and automatic refresh

Turbo

9 controllers

Optimistic / Form

optimistic--form

Applies optimistic Turbo Stream templates before a form request begins

Turbo / Frame Src

turbo--frame-src

Sends the Turbo Frame source URL with same-frame form submissions

Turbo / Morph Guard

turbo--morph-guard

Preserves the nearest Turbo Frame during outer morphs while the user is editing

Turbo / Polling

turbo--polling

Reloads a Turbo Frame at configurable intervals with pause and refresh controls

Turbo / Progress

turbo--progress

Shows the Turbo progress bar for Turbo Frame and Turbo Stream requests

Turbo / View Transition

turbo--view-transition

Animates Turbo Frame updates with View Transitions when supported, using normal renders while modal dialogs are stacked

Dev

2 controllers

Dev / Duplicate Ids

dev--duplicate-ids

Warns during development when duplicate DOM IDs appear within its render root

Dev / Log

dev--log

Logs action events to the browser console for development debugging

Make it look like your product

Start from a preset and change the tokens your brand cares about.

Continue to theming