Creating a New Component

How to Create a New Component

  1. To create a new component, run the generator from the root folder of the monorepo:
Copy

or

Copy

You'll be prompted for a component name (make sure to use PascalCase) and an optional description. The generator will automatically:

  • Create files according to structure defined in the Component Structure page.
  • Add the necessary export statements in these two files:
Copy
Copy

Additionally, the generator will create a sample .story.js file. You can find more about using story.js here.

  1. Make sure to rearrange the stories/index.js as needed. The order of require statements in that file will reflect in the rendered Storybook sidebar.

API (Props)

Mandatory Props

PropRuleDescription
dataHookRequiredEvery component should accept a dataHook property, which is applied as a data-hook attribute on the component's root element. This attribute is used as a selector in tests.
classNameRequiredThe convention for styling the component's root element is to expose a className property. NOTE: This prop is only used internally by WDS.

Props Guidelines

PropRuleDescription
initialPropNameConventionProps that set an initial value to an identical uncontrolled state should be named with an initial prefix.
xxxPropsConventionIf the component is wrapping another component (or native DOM element) and its props are needed, pass them using the convention xxxProps. For example: inputProps, tooltipProps, etc.

Styling

We use Stylable. Check the documentation to learn how to use it effectively.


Typography

  • For common typography, components should use the Text or Heading components.
  • If you absolutely can't use those components, you can use the Typography.st.css file directly.

Documentation

  • Document each property with a /** */ comment above their TypeScript definitions in the *.types.ts file. AutoDocs will utilize this information.





Last updated: 26 October 2026

Did this help?