Create Engaging Component Playgrounds with Args and Controls

Michael Chan
InstructorMichael Chan
Share this video with your friends

Social Share Links

Send Tweet
Published a year ago
Updated 2 months ago

Create dynamic and engaging component playgrounds in Storybook with Args and Controls. Learn how these powerful tools create an engaging and interactive documentation experience.

[00:00] When we define stories with CSF object syntax, we get controls for free. Remember just go into our settings cog and enable show add ons anytime you have a story selected. From there, we just click on the controls tab to see all of the interactive controls we have for this button. This happens because we provided our button [00:20] component via component meta to Storybook and it knows how to map the args of our story as props to that button for all of these stories. With storybook involved we get all of these controls for free. So let's create another instance of this story. We'll make a Luke Skywalker [00:40] button. The moment that he finds out that Darth Vader is his father. Sorry, spoilers. Now, once we have an expression of this component that we like, we can actually create a new story for it. We simply export a new constant, the name will become the name of the story, and we provide [01:00] the args that we want. So label is gonna be no, primary true, background color red, and size large. Save. And now we have a dedicated I am your father story with this unique configuration of args. Now, anytime [01:19] we wanna reset a story there's a handy little refresh button here which will take us back to the default state of that story.

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today