Skip to main content

CLI

UI5 Web Components provides command-line tools for scaffolding projects and generating components.

Create a New Projectโ€‹

Scaffold a fully configured UI5 Web Components package with a single command:

npm create @ui5/webcomponents-package

This launches an interactive wizard that sets up a ready-to-run TypeScript project with a sample component, theming, i18n, and a dev server.

Optionsโ€‹

OptionDescriptionDefault
--namePackage name (npm-compatible, supports scopes)my-package
--tagComponent tag name (e.g., my-button)Derived from class name
--testSetupTest setup: cypress or manualmanual
--skipSkip interactive prompts and use defaultsfalse
--skipSubfolderCreate files in current directory instead of a subfolderfalse

Examplesโ€‹

Non-interactive with a custom name

npm create @ui5/webcomponents-package -- \
--name "my-components" \
--skip

Scoped package with Cypress testing

npm create @ui5/webcomponents-package -- \
--name "@scope/my-lib" \
--testSetup "cypress" \
--skip

What Gets Generatedโ€‹

The scaffolded project includes:

  • A sample web component (MyFirstComponent) with a template, styles, and i18n
  • Dev server with hot reload (npm start)
  • Build pipeline for production (npm run build)
  • TypeScript configuration
  • Cypress test setup (if selected)
  • ESLint configuration
  • Theming infrastructure (SAP Horizon)

After the project is created:

cd my-package
npm install
npm start

Generate a Componentโ€‹

Inside a scaffolded project, generate a new web component:

npm run create-ui5-element

This prompts for a PascalCase component name (e.g., MyButton) and generates three files:

FilePurpose
src/<Name>.tsComponent class with @customElement decorator
src/<Name>Template.tsxJSX template
src/themes/<Name>.cssComponent styles

The tag name is derived automatically โ€” MyButton becomes my-my-button (using the prefix from .env).

You can also pass the name directly:

npm run create-ui5-element "MyButton"

After generating, import the component in src/bundle.esm.ts:

import "./MyButton.js";

Project Commandsโ€‹

Every scaffolded project comes with these commands:

CommandDescription
npm startStart the dev server with hot reload
npm run buildProduction build
npm run create-ui5-elementGenerate a new web component
npm run lintLint the project
npm run cleanClean generated and build artifacts
npm testRun tests (if Cypress was selected)

View on npm ยท GitHub