Skip to content
\n

Additional information

\n

React 18, SB9

\n

Create a reproduction

\n

No response

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"\n

Hi @JesusTheHun! I'm Dosu and I’m helping the storybook team.

\n\n

Storybook 9 has trouble auto-generating or parsing union types that involve generics or arrays (like string | string[]), which is why you see unknown in the UI. This happens because Storybook’s type extraction and conversion logic can’t always interpret these complex types, so it falls back to unknown and the Docs UI just displays that as-is (source).

\n

A practical workaround is to manually set the type summary for docs using the summary/detail fields in argTypes. For example:

\n
argTypes: {\n  value: {\n    description: 'The current value of the element.',\n    table: {\n      type: {\n        summary: 'string | string[]',\n        detail: 'A single string or an array of strings.',\n      },\n    },\n  },\n}
\n

This won’t enable controls for both types, but it will document the prop clearly in the ArgsTable. If you want controls, you’ll need to pick one type (e.g., string) for the control and explain array usage in the description.

\n

There’s no official support for union types with arrays/generics in argTypes as of SB9, so this manual summary is the best option for now (docs). Keep an eye on future Storybook releases for improvements in this area.

\n\n

To reply, just mention @dosu.

\n
\n

How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  \"Join \"Share

","upvoteCount":0,"url":"https://github.com/storybookjs/storybook/discussions/31990#discussioncomment-13698304"}}}

ArgType type: union #31990

Answered by dosubot bot
JesusTheHun asked this question in Help
Discussion options

You must be logged in to vote

Hi @JesusTheHun! I'm Dosu and I’m helping the storybook team.

Storybook 9 has trouble auto-generating or parsing union types that involve generics or arrays (like string | string[]), which is why you see unknown in the UI. This happens because Storybook’s type extraction and conversion logic can’t always interpret these complex types, so it falls back to unknown and the Docs UI just displays that as-is (source).

A practical workaround is to manually set the type summary for docs using the summary/detail fields in argTypes. For example:

argTypes: {
  value: {
    description: 'The current value of the element.',
    table: {
      type: {
        summary: 'string | string[]',
        detail

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JesusTheHun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant