Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can hide storybook control per story arg

Tags:

storybook

I have rails engine project using storybook and mdx files to specify the controls but i need to hide specific control per story

<Meta
    title='Label Component'
    story='with_tooltip'
    args={{
        object: 'employee',
        field_name: 'name',
        text: 'Employee name',
        tooltip: 'Lorem ipsum dolor sit amet, consectetur adipiscing eli'
    }}
/>

I have two stories [label,with_tooltip]

in case label story i need to hide tooltip control I'm using view component preview to show components

like image 542
Amr Abu Aza Avatar asked Sep 02 '25 10:09

Amr Abu Aza


2 Answers

You can disable controls for individual properties of a story including the prop table documentation, or you can disable only the control and leave the prop table documentation intact.

To disable the control and prop table documentation for the tooltip prop:

<Meta
    title='Label Component'
    story='with_tooltip'
    args={{
        object: 'employee',
        field_name: 'name',
        text: 'Employee name',
        tooltip: 'Lorem ipsum dolor sit amet, consectetur adipiscing eli'
    }}
    argTypes={{
      tooltip: {
        table: {
          disable: true
        }
      }
    }}

/>

To disable the control but leave the prop table documentation intact for the tooltip prop:

<Meta
    title='Label Component'
    story='with_tooltip'
    args={{
        object: 'employee',
        field_name: 'name',
        text: 'Employee name',
        tooltip: 'Lorem ipsum dolor sit amet, consectetur adipiscing eli'
    }}
    argTypes={{
      tooltip: {
        control: false
      }
    }}

/>

See the Storybook docs on disabling controls for specific properties.

like image 118
morganney Avatar answered Sep 10 '25 19:09

morganney


The best approach is doing this:

export default {
  title: 'Pages/Login ',
  component: Login,
  parameters:{
    controls:{
        exclude:/.*/g
    }
  }
} as ComponentMeta<typeof Login>;
like image 39
Amirreza Avatar answered Sep 10 '25 20:09

Amirreza