Ask questions[Question] When do we use knobs over control?

I'm new and keep seeing knobs tutorial but I've read we should use control instead, is there any instances when I would prefer this over controls? or is this eventually going to be deprecated.


Answer questions cybervaldez

controls was introduced in 6.0 to replace knobs. the two areas it falls short currently:

  • knobs are fully dynamic, e.g. you can conditionally show and hide knobs based on the value of other knobs
  • knobs can be saved on the URL and initialized from the URL. this is coming to controls in 6.1 #12291

if you don't need either of these immediately, use controls

I'm very interested in the former, conditionally show/hide knobs based on a state.

const [isEnabled, toggleEnabled]= useState(true)

return <>{isEnabled && text('enabledLabel', 'enabled')} {!isEnabled && text('disabledLabel', 'disabled')} <button onClick={()=>toggleEnabled(isEnabled)}>Toggle</button></>

I'm expecting to hide/show enabledLabel and disabledLabel in the knobs panel depending on the state.

Github User Rank List