The following are the approaches for creating custom components in Experience Builder:
- Overriding an existing component: This approach uses an existing component as a starting point, essentially creating a clone that you can customize. This is the easier approach and is recommended when you need a component that is similar to an existing one but with modifications.
- Creating a component from scratch: This approach provides you complete control to build a custom component to your exact specifications. It requires more technical knowledge but provides maximum flexibility.
Sharing custom components across sites¶
The Experience Builder CLI tool enables you to create, build, and manage code components outside of the browser-based code editor provided by Acquia Source. It also enables you to manage a single component library used by multiple sites.
In a terminal window, run the following command to install the CLI tool:
npm install @drupal/xb-cli -g
- Access your site.
- In the left sidebar, click API > API clients.
- Click Add API client.
- Enter a name.
- Select the Client Credentials checkbox and add
xb:asset_library
and xb:js_component
as scopes. - Save the client to generate credentials.
Use the credentials to download and upload components such as npx xb download.
For detailed usage information, refer to the npm package.