Upgrade to Pro to unlock this component

Access all premium components, AI-ready documentation, and lifetime access to updates.

Kanban Rails Components

Boards where cards and columns move the way your hand expects. Drag with a mouse, a finger, or the keyboard: the lifted card tilts and follows the pointer, neighbours slide out of the way, and the drop settles into place. Counts, empty states, and WIP limits stay in sync, and every move is one event (or one PATCH) away from your Rails models.

Installation

1. Stimulus Controller Setup

One dependency-free controller built on Pointer Events and the Web Animations API. No drag-and-drop library, no native drag ghost.

This code is available to Pro users only.

// Hey curious person!
// You seem to be sneaking around the code...
// I hope you're enjoying the components!
// Have a great day!

class SecretMessage {
  constructor() {
    this.message = "Thanks for checking out Rails Blocks!";
    this.compliment = "You're awesome!";
  }

  reveal() {
    console.log(this.message);
    return this.compliment;
  }
}

const secret = new SecretMessage();
secret.reveal();

2. Modal Controller (optional)

Only the Cards that open a modal example needs it: it uses the Modal component's modal_controller.js. Follow the Modal page's installation if you haven't added it yet.

Examples

Basic board

Three columns with live card counts and an empty column that invites a drop. Drag a card, or use the arrow keys to focus one, press Space, move it with the arrow keys, and press Space again to drop. Esc puts it back.

To do

3
  • Write the launch announcement

  • Record a two-minute product demo

  • Update pricing page screenshots

In progress

2
  • Migrate billing emails to the new layout

  • Fix avatar upload on Safari

Done

0

Drop a card here

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Task cards

A sprint board with labels, priority, due dates, comment and attachment counts, and assignee avatars. Columns scroll on their own; hold a card near the edge of a column or the board and it scrolls for you.

This component has to be viewed in fullscreen

Preview

Backlog

4
  • Design

    Redesign the empty state for new workspaces

    Medium Nov 21
    Comments:4 Attachments:2
    AM LT
  • Backend

    Rate-limit the public search endpoint

    High Nov 18
    Comments:1 Attachments:0
    SK
  • Docs

    Write the webhooks guide

    Low Dec 2
    Comments:0 Attachments:1
    JR
  • Growth Design

    Referral banner experiment

    Medium Nov 28
    Comments:6 Attachments:3
    LT JR

In progress

2
  • Bug Backend

    Invoices show the wrong currency after plan change

    Urgent Today
    Comments:12 Attachments:1
    SK AM
  • Design

    Keyboard shortcuts for the command menu

    High Nov 14
    Comments:3 Attachments:0
    AM

In review

1
  • Backend

    Move file uploads to direct-to-S3

    Medium Nov 13
    Comments:8 Attachments:2
    SK JR LT

Done

1
  • Growth

    Onboarding checklist for invited teammates

    Low Nov 6
    Comments:5 Attachments:1
    LT

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Sortable columns

A sales pipeline where the stages move too. Grab a column by its header to reorder it; deals still drag between stages.

This component has to be viewed in fullscreen

Preview

Lead

3 deals
  • Northwind Priya Raman $4,800
  • Lumen Labs Diego Ortiz $12,000
  • Fable & Co Hannah Weiss $2,400

Qualified

2 deals
  • Brightside Omar Haddad $18,500
  • Kettle Mia Lindqvist $7,200

Proposal

1 deals
  • Harbor Freight Co Samuel Osei $36,000

Won

1 deals
  • Tidewater Elena Popov $9,900

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

WIP limits

Set data-kanban-limit on a column and the counter fills up as it reaches the limit, then warns when you go over. Try dragging a fourth card into Doing. Review's limit is strict (data-kanban-limit-strict): once full, it turns red under the card and refuses it.

Ready

3
  • Customer can't export invoices as CSV

    Billing

  • Add SSO to the enterprise plan

    Auth

  • Dashboard loads slowly on large accounts

    Performance

Doing

3 / 3

Over the limit of 3. Finish something first.

  • Reset password email lands in spam

    Email

  • Dark mode for the mobile app

    Mobile

  • Duplicate charges on annual renewals

    Billing

Review

Strict limit: no cards past it 1 / 2

Over the limit of 2. Finish something first.

  • Upgrade to Rails 8.1

    Platform

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Add card composer

An inline composer per column. Enter submits the card to your create action and keeps the composer open for the next one; Esc closes it. Append the new card with a Turbo Stream and it is draggable right away. On this page cards are added without a server.

Ideas

3
  • Interview three churned customers

  • Changelog as a public RSS feed

  • Annual plan with two months free

This week

1
  • Ship the redesigned settings page

Shipped

0

Drop a card here

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Compact list with drag handles

A dense issue-tracker layout. Rows only drag from their grip, so titles stay selectable and a swipe on touch always scrolls.

This component has to be viewed in fullscreen

Preview

Todo

5
  • ENG-412 Paginate the audit log API
  • ENG-409 Tooltip flickers near the viewport edge
  • ENG-405 Remove the legacy importer
  • ENG-398 Add retries to the Stripe webhook job
  • ENG-391 Trim trailing spaces in team names

In progress

2
  • ENG-417 Cache the pricing page per currency
  • ENG-402 Two-factor recovery codes download

Done

2
  • ENG-388 Fix N+1 on the members page
  • ENG-380 Upgrade Postgres to 17

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Collapsible columns

A hiring pipeline with a stage tucked away. Collapse any column to a slim rail, and drop cards straight onto it.

This component has to be viewed in fullscreen

Preview

Applied

3
  • Noor Abbasi

    Senior Rails Engineer

    Referred by Sam

  • Tomás Herrera

    Product Designer

    Portfolio attached

  • Ingrid Solberg

    Senior Rails Engineer

    Applied 2 days ago

Interview

2
  • Kwame Mensah

    Support Lead

    Thu, 2:30 PM

  • Yuki Tanaka

    Product Designer

    Take-home sent

Offer

1
  • Clara Fontaine

    Senior Rails Engineer

    Offer expires Friday

Archived

2
  • Ben Whitaker

    Support Lead

    Withdrew

  • Aditi Rao

    Product Designer

    Not a fit right now

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Cards that open a modal

Each card's face is a button that is also its drag handle: click it or press Enter to open the task in a modal, drag it or press Space to move it. A click that turns into a drag never opens anything, and focus returns to the card when the modal closes. Uses the Modal component's controller; for cards that link to a page, use an <a href> as the handle and Cmd/Ctrl-click works natively.

Backlog

2
  • Design

    Redesign the onboarding emails

    The welcome series still uses the old layout. Move all four emails to the new template and tighten the copy.

    Assignee
    AM
    Due
    Nov 24
    Priority
    Medium

    Subtasks · 1/3

    • Audit the current series
    • Write the new copy
    • Build the templates
  • Backend

    Add SSO to the enterprise plan

    Support SAML for workspaces on the enterprise plan, with just-in-time user provisioning.

    Assignee
    SK
    Due
    Dec 2
    Priority
    High

    Subtasks · 1/2

    • Pick a SAML library
    • Settings page for admins

In progress

2
  • Bug

    Fix the flaky checkout test

    The checkout system test fails about one run in ten on CI, always while waiting for the payment iframe.

    Assignee
    JR
    Due
    Today
    Priority
    Urgent

    Subtasks · 2/3

    • Reproduce locally
    • Wait for the iframe to load
    • Run 50 times on CI
  • Docs

    Write the 2.0 changelog

    Collect the merged pull requests since 1.9 and group them into features, fixes and breaking changes.

    Assignee
    LT
    Due
    Nov 28
    Priority
    Low

    Subtasks · 1/2

    • List merged PRs
    • Draft the post

Done

1
  • Backend

    Upgrade to Rails 8.1

    Upgraded the app and fixed the two deprecations it surfaced. All green on CI.

    Assignee
    SK
    Due
    Nov 18
    Priority
    High

    Subtasks · 2/2

    • Bump the gem
    • Fix deprecations

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Move with a menu

Every card also has a "Move to…" menu, so any move takes a single tap or click and no dragging (WCAG 2.2, 2.5.7 Dragging Movements). It's a native <select> wired to kanban#moveTo: phones open their own picker, and the move is animated, announced and saved exactly like a drop.

To do

3
  • Write the launch announcement

  • Record a two-minute product demo

  • Update pricing page screenshots

In progress

1
  • Migrate billing emails to the new layout

Done

1
  • Fix avatar upload on Safari

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Live updates

When a teammate moves a card, it slides to its new place on everyone else's board. Add broadcasts_refreshes and turbo_stream_from, and refresh with morphing: the controller animates every card the morph moved, with no JavaScript to write. Your own saves skip the echo, and a refresh never lands in the middle of a drag. On this page the button morphs the board the way a refresh would.

To do

3
  • Write the launch announcement

  • Record a two-minute product demo

  • Update pricing page screenshots

In progress

1
  • Migrate billing emails to the new layout

Done

1
  • Fix avatar upload on Safari

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Long columns, loaded in pages

A column with hundreds of cards shows the first few and a "Load more" link that fetches the next page as a Turbo Stream. The count includes the cards still on the server, and moving cards in and out never makes the next page skip or repeat one: the controller keeps the link's ?offset= in step. On this page the link is answered without a server.

To do

2
  • Write the launch announcement

  • Record a two-minute product demo

In progress

1
  • Migrate billing emails to the new layout

Done

12

This code is available to Pro users only.

<!-- Hey curious person! -->
<!-- You seem to be sneaking around the code... -->
<!-- I hope you're enjoying the components! -->
<!-- Have a great day! -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Secret Message from Rails Blocks</title>
  <style>
    .secret-message {
      font-family: 'Comic Sans MS', cursive;
      text-align: center;
      padding: 2rem;
      background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    .wiggle { animation: wiggle 0.5s ease-in-out infinite; }
    @keyframes wiggle {
      0%, 100% { transform: rotate(0deg); }
      25% { transform: rotate(1deg); }
      75% { transform: rotate(-1deg); }
    }
  </style>
</head>
<body>
  <div class="secret-message">
    <h1>🎉 Hello, Code Detective! 🕵️</h1>
    <p>Thanks for checking out Rails Blocks!</p>
    <p>You're clearly someone who pays attention to details.</p>
    <p>That's exactly the kind of developer we love!</p>

    <div class="cta-section">
      <button class="awesome-btn wiggle">You're awesome!</button>
      <p><small>Seriously, keep being curious! 🚀</small></p>
    </div>

    <footer>
      <p>Built with ❤️ by the Rails Blocks team</p>
      <p>Now go build something amazing!</p>
    </footer>
  </div>

  <script>
    console.log("🎊 Bonus points for opening the console!");
    console.log("Keep exploring and happy coding! 💻");
  </script>
</body>
</html>

Rails integration

Give every column a data-kanban-column-id (your status) and every card a data-kanban-card-id. Then either set data-kanban-url-value and let the controller send the request, or listen for kanban:move and do it yourself. If the request fails, the card animates back to where it came from.

<%# app/views/tasks/index.html.erb %>
<div data-controller="kanban" data-kanban-url-value="/tasks/:id/move">
  <% Task.statuses.each_key do |status| %>
    <section data-kanban-target="column" data-kanban-column-id="<%= status %>" aria-label="<%= status.humanize %>">
      <h3><%= status.humanize %> <span data-kanban-target="count"></span></h3>
      <ul data-kanban-target="list" id="tasks_<%= status %>">
        <%= render @tasks.select { |task| task.status == status } %>
      </ul>
    </section>
  <% end %>
</div>

<%# app/views/tasks/_task.html.erb %>
<li id="<%= dom_id(task) %>" data-kanban-target="card" data-kanban-card-id="<%= task.id %>">
  <p data-kanban-title><%= task.title %></p>
</li>
# config/routes.rb
resources :tasks do
  patch :move, on: :member
end

# app/controllers/tasks_controller.rb
# Receives { "from": "todo", "to": "in_progress", "index": 1, "position": 2,
#            "ids": ["17", "42", "8"], "fromIds": ["3", "9"] }
def move
  task = Current.user.tasks.find(params[:id])
  status = params.require(:to)
  return head :unprocessable_entity unless Task.statuses.key?(status)

  # `ids` is the column's full new order. Scope it to the user, so a request
  # can't reorder anyone else's tasks.
  ids = Array(params[:ids]).map(&:to_i)
  Task.transaction do
    task.update!(status: status)
    tasks = Current.user.tasks.where(id: ids, status: status).index_by(&:id)
    ids.each_with_index { |id, index| tasks[id]&.update_column(:position, index + 1) }
  end
  head :no_content
end

# Using acts_as_list? Replace the transaction with:
#   task.update!(status: status)
#   task.insert_at(params[:position].to_i) # position is 1-based
document.addEventListener("kanban:move", (event) => {
  const { id, from, to, oldIndex, index, position, ids, fromIds } = event.detail
  // event.preventDefault() here sends the card back
})

Reference

Targets

  • column with data-kanban-column-id, and optionally an aria-label used in announcements.
  • list is the element whose direct children are cards. card needs data-kanban-card-id.
  • handle (inside a card) and columnHandle (inside a column) restrict where a drag can start. Without a handle the whole card drags, except for links, buttons, form fields, and anything marked data-kanban-no-drag.
  • count and empty inside a column are kept in sync, including when cards arrive through Turbo Streams.
  • more is the last row of a paged column's list: a "Load more" link (or a row around one) with data-kanban-remaining, the number of cards not loaded yet. Counts, limits and announcements include them, and the link's offset query parameter is kept equal to the number of cards loaded. Moved cards always land above it.
  • composer (the form) and composerToggle power the inline composer. Add turbo:submit-end->kanban#composerSubmitted to the form to clear it after each card.

Column and card attributes

  • Mark each card's title with data-kanban-title: the focused card is then named by its title (the controller adds aria-labelledby), and announcements use it. An aria-label on the card wins. Columns use their aria-label.
  • data-kanban-accepts="todo bug" on a column only takes cards coming from one of those columns, or whose data-kanban-type (space-separated) has one of those tokens. A card can always go back to its own column.
  • data-kanban-limit="5" on a column is a soft limit (see State attributes below); add data-kanban-limit-strict to refuse cards once it is full. For anything else, cancel kanban:accept. A column that refuses the card gets data-kanban-refusing while the card is over it, and keyboard moves skip it.
  • data-kanban-disabled on a card pins it in place: it can’t be dragged or moved with the move actions, but it still makes room for others.

Values

  • url and column-url: endpoints with an :id placeholder, replaced with the URL-encoded card or column id. Sent as JSON with the CSRF token; method defaults to PATCH. Cards send { from, to, index, position, ids, fromIds }, columns { index, position, ids }. Reply with a Turbo Stream and it is rendered. A non-2xx response, or a redirect, animates the item back to where it came from.
  • delay: press-and-hold time before a touch starts dragging (default 200 ms). Handles with touch-none skip it.
  • distance: how far (px) a mouse or pen must travel before a press becomes a drag, so clicks still work (default 4).
  • start-at: the number of the first position, so position in events and requests is index + start-at (default 1, like acts_as_list).
  • disabled: turns dragging off, for read-only boards. Cards stay focusable and the arrow keys still move between them; the root gets data-kanban-disabled so you can drop the grab cursor with in-data-[kanban-disabled]:cursor-default. It can change at any time.
  • messages: overrides for everything said to screen readers (see Translations below).

Actions

  • kanban#toggleColumn on a button inside a column collapses or expands it.
  • kanban#openComposer and kanban#closeComposer show and hide a column's composer; keydown->kanban#composerKeydown on its field makes Enter submit, Shift + Enter add a line and Esc close.
  • turbo:submit-end->kanban#composerSubmitted on the composer form clears and refocuses it after each card.
  • kanban#movePrevious, kanban#moveNext, kanban#moveFirst and kanban#moveLast on a button inside a card move it one place, or to the top or bottom of its column. A button that can't move its card any further gets aria-disabled="true". Same actions as the Drag and drop component.
  • change->kanban#moveTo on a <select> inside a card moves it to the chosen option: "done" (end of that column), "done:0" (its top), or ":0" / ":-1" (top / bottom of the card's own column). On a button, use click->kanban#moveTo with data-kanban-column-param and data-kanban-index-param (0-based, negative counts from the end). Outside the card, name it with data-kanban-id-param, as for every move action.
  • kanban#refresh recounts every column (counts, empty states, WIP limits). It runs on its own when cards connect or disconnect; call it after changing the board some other way.

Methods

moveCard(cardOrId, column, index) and moveColumn(columnOrId, index) move things from JavaScript, the way a drop does: animated, announced, kanban:move dispatched and saved. index counts from the end when negative (default -1). Pass { silent: true } for moves made elsewhere, like another user's move arriving through your own channel (page refreshes and morph streams are animated without it, see Live updates): it only animates, with no drop rules, event, request or announcement. Both return whether anything moved.

const board = document.querySelector("[data-controller~='kanban']")
const kanban = window.Stimulus.getControllerForElementAndIdentifier(board, "kanban")

kanban.moveCard("42", "done", 0)                    // top of Done, saved
kanban.moveCard("42", "done", -1, { silent: true }) // just animate it there

Keyboard

  • The board is one Tab stop for its cards (and one for its column headers): the arrow keys move focus between them when nothing is lifted.
  • Space lifts the focused card or column handle, and drops it. Enter does the same, except on a card that is (or whose handle is) a link or a button: there Enter opens it, like a click.
  • While an item is lifted, ↑ ↓ reorder within a column, ← → move across columns (opening a collapsed column on the way, skipping columns that refuse the card), Home / End send it to the top or bottom, Space or Enter drops it, and Tab drops it where it is.
  • Esc cancels and returns the item, for pointer drags too. Every step is announced to screen readers.

State attributes

Every visual state is a data attribute, so you style it with Tailwind data-[…]: and group-data-[…]: variants.

  • data-kanban-pressed, data-kanban-dragging (the slot it leaves in the board), data-kanban-overlay (the copy following the pointer), and data-kanban-lifted (picked up with the keyboard) on cards and columns. When a card has a handle, data-kanban-pressed lands on the handle (style the card with has-[[data-kanban-pressed]]:).
  • data-kanban-over, data-kanban-at-limit, data-kanban-over-limit, and data-kanban-collapsed on columns. data-kanban-over-limit-at-rest only updates once a drop has landed: use it for anything that changes the layout, like a warning line, so the column doesn't resize under the pointer mid-drag.
  • data-kanban-refusing on a column while the dragged card is over it and the column doesn't take it.
  • data-kanban-saving on a card (plus aria-busy="true") while its save request is in flight, and on the root while any request is.
  • data-kanban-active on the root while anything is being dragged, and data-kanban-disabled while dragging is off.
  • While a card or column is in the air, the board can grow but never gets shorter (its min-height is held), so nothing below it moves under the pointer. It settles once the drop has landed. Column heights are deliberately not animated: they are drop targets, and a target that resizes mid-drag is one you chase.

Events

  • kanban:start, kanban:end and kanban:cancel with { item, id, kind } (start also has from) when a drag or keyboard lift begins, ends, or is cancelled.
  • kanban:move with { item, id, from, to, oldIndex, index, position, ids, fromIds }, cancelable, after a drop or a one-click move. from and to are column ids, index is zero-based, position is index + start-at, ids is the destination column's order and fromIds the source column's. preventDefault() puts the card back.
  • kanban:column-move with { item, id, oldIndex, index, position, ids }, cancelable.
  • kanban:accept with { item, id, from, to, column } the first time a dragged card reaches another column, and before a one-click move into one, cancelable: event.preventDefault() makes the column refuse it.
  • kanban:toggle with { id, collapsed, source, item } when a column collapses or expands. source is "user" for the toggle button and "keyboard" when a keyboard move opens a column on the way and folds it back.
  • kanban:saved with the move's detail plus the response once the request succeeds, and kanban:error with the same detail plus error and response when it fails. A redirect counts as a failure (an expired session sent to the sign-in page saved nothing). Requests go out one at a time, in order; a queued request is skipped when a newer move of the same card replaced it.

Translations

Everything said to screen readers can be replaced through data-kanban-messages-value, a JSON object with any of these keys: instructions, pickedUp, lifted, moving, dropped, moved, cancelled, notAllowed, rejected, saveFailed, blocked, position, positionInColumn, unnamed, cardRole and columnRole. Placeholders use Rails' i18n syntax, so a locale file can be passed as it is: %{label}, %{position}, %{column}, %{index} and %{count}. The Drag and drop component uses the same keys. The defaults are at the top of the controller.

<%# config/locales/de.yml has a kanban: section with the same keys %>
<div data-controller="kanban"
     data-kanban-messages-value="<%= t("kanban").transform_keys { |key| key.to_s.camelize(:lower) }.to_json %>">

Remembering collapsed columns

kanban:toggle tells you when a column collapses or expands, so you can keep the choice between visits.

// Remember which columns were collapsed (a cookie read by Rails avoids a flash on load)
board.addEventListener("kanban:toggle", ({ detail }) => {
  if (detail.source !== "user") return // ignore columns a keyboard move opened on the way
  const collapsed = new Set(JSON.parse(localStorage.getItem("collapsed") || "[]"))
  detail.collapsed ? collapsed.add(detail.id) : collapsed.delete(detail.id)
  localStorage.setItem("collapsed", JSON.stringify([...collapsed]))
})

Table of contents

Powered by

Get notified when new components come out