Skip to content

Latest commit

 

History

History
36 lines (19 loc) · 1.86 KB

File metadata and controls

36 lines (19 loc) · 1.86 KB

Composite Components

In addition to creating primitive style components, Lab can be used to create multi-element composite components with the other style components in your library.

To create a composite component, click the Add button in the upper right, then click the Composite Component tab.

library view

composite component tab

Next, in the Imports field start typing the name of the components that you plan to use for creating the composite component. A list of available components will appear in the text below the form field.

Note: Lab currently only supports creating composite components with primitive style components and extended components; other composite components cannot be imported.

composite component imports field

Next, in the JSX editor, start using the imported components to build a composite component. To allow the values used in the composite component to be changed dynamically, use React props.

Don't worry if the component isn't perfect at this step, you'll be able to edit it in the next step.

composite component JSX field

Give your new component a unique name, then click the Create Component button to add the component to your library and start editing it.

composite component name field

To start, make sure you add an example in the Examples editor to give your component some test content.

composite component examples

Since Lab components use styled-system you can adjust things like margin, padding and font-size for the components used in your composite component.