Skip to content

feat: add first-class support for change handlers#48

Open
LuLaValva wants to merge 6 commits intostorybookjs:mainfrom
LuLaValva:change-handlers
Open

feat: add first-class support for change handlers#48
LuLaValva wants to merge 6 commits intostorybookjs:mainfrom
LuLaValva:change-handlers

Conversation

@LuLaValva
Copy link

Description

Adds first-class support for change handlers and Marko's controllable pattern.

Controllable args in argTypes can now include changeHandler. This does two things:

  1. Automatically add a _Change entry in the table with a default description and type that references docs, or a custom one determined by the user
  2. Wires up the arguments in storybook so they automatically sync with the preview, demonstrating how the pattern might be used.
controllable.mov
{
  argTypes: {
    value: {
      changeHandler: true,
      control: { type: "text" },
      description: "Controllable text value",
      table: {
        type: { summary: "string" },
      },
    },
    pressed: {
      changeHandler: "Control the `pressed` attribute with a hoist",
      control: { type: "boolean" },
      description: "Controllable boolean value",
      table: {
        type: { summary: "boolean" },
        defaultValue: {
          summary: "false",
        },
      },
    },
    color: {
      options: ["red", "orange", "yellow"],
      changeHandler: spanishChangeHandlerMessage,
      control: { type: "inline-radio" },
      description: "Controllable boolean value",
      table: {
        type: { summary: "boolean" },
      },
    },
  },
}

Checklist:

  • I have updated/added documentation affected by my changes.
  • I have added tests to cover my changes.

@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: 9770e12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@storybook/marko Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant