DevExtreme Angular - DevExtreme CLI (2024)

DevExtreme CLI is a set of command-line tools to be used with the DevExtreme controls library.

Requirements

  • Node.js v12.6.0 or later
  • npm v6.2.0 or later

Installation

npm i -g devextreme-cli

Alternatively, you can use npx to execute DevExtreme CLI commands without installing the CLI globally. Examples in this article illustrate both approaches.

Add DevExtreme to an Existing Application

Angular
devextreme add devextreme-angular// ===== or without installing the DevExtreme CLI =====npx devextreme-cli add devextreme-angular

This command does the following:

  • Adds the devextreme and devextreme-angular npm packages to the dependencies in package.json and installs their latest versions.
  • References the dx.light.css DevExtreme stylesheet in angular.json.

These steps are explained in the Add DevExtreme to an Angular CLI Application article.

Once the command is executed, import DevExtreme modules.

Vue
devextreme add devextreme-vue// ===== or without installing the DevExtreme CLI =====npx devextreme-cli add devextreme-vue

This command does the following:

  • Adds the devextreme and devextreme-vue npm packages to the dependencies in package.json and installs their latest versions.
  • Imports the dx.light.css DevExtreme stylesheet in src/main.js.

These steps are explained in the Add DevExtreme to a Vue Application article.

Once the command is executed, import DevExtreme components.

React
devextreme add devextreme-react// ===== or without installing the DevExtreme CLI =====npx devextreme-cli add devextreme-react

This command does the following:

  • Adds the devextreme and devextreme-react npm packages to the dependencies in package.json and installs their latest versions.
  • Imports the dx.light.css DevExtreme stylesheet in src/App.js.

These steps are explained in the Add DevExtreme to a React Application article.

Once the command is executed, import DevExtreme components.

DevExtreme Application

Create a New Application

Angular

Creates a new DevExtreme Angular application that uses the DevExtreme layout template:

devextreme new angular-app app-name [--layout][--empty]// ===== or without installing the DevExtreme CLI =====npx devextreme-cli new angular-app app-name [--layout][--empty]

Arguments:

  • --layout
    Specifies the DevExtreme layout. Available values:

    • side-nav-outer-toolbar (default)
    • side-nav-inner-toolbar

    See the following topic to review both layouts: Layouts.

  • --empty
    Specifies whether to skip sample view generation (default: false).

Vue

Creates a new DevExtreme Vue application that uses the DevExtreme layout template:

devextreme new vue-app app-name [--layout][--empty][--version]// ===== or without installing the DevExtreme CLI =====npx devextreme-cli new vue-app app-name [--layout][--empty][--version]

Arguments:

  • --layout
    Specifies the DevExtreme layout. Available values:

    • side-nav-outer-toolbar (default)
    • side-nav-inner-toolbar

    See the following topic to review both layouts: Layouts.

  • --empty
    Specifies whether to skip sample view generation (default: false).

  • --version, -v
    Specifies whether to generate a Vue 2 or Vue 3 application. Available values: 2 and 3.

React

Creates a new DevExtreme React application that uses the DevExtreme layout template:

devextreme new react-app app-name [--layout][--empty]// ===== or without installing the DevExtreme CLI =====npx devextreme-cli new react-app app-name [--layout][--empty]

Arguments:

  • --layout
    Specifies the DevExtreme layout. Available values:

    • side-nav-outer-toolbar (default)
    • side-nav-inner-toolbar

    See the following topic to review both layouts: Layouts.

  • --empty
    Specifies whether to skip sample view generation (default: false).

  • --templateSpecifies whether to create an application template with TypeScript support. Available values: javascript and typescript.

Add the DevExtreme Layout to an Existing Application

Add the DevExtreme layout template to an existing Angular application:

devextreme add angular-template [--layout][--empty][--resolve-conflicts]// ===== or =====npx devextreme-cli add angular-template [--layout][--empty][--resolve-conflicts]

Arguments:

  • --layout
    Specifies the DevExtreme layout to add. Available values:

    • side-nav-outer-toolbar (default)
    • side-nav-inner-toolbar

    Both layouts are illustrated in the Layouts article.

  • --empty
    Specifies whether to skip sample views generation (default: false).

  • --resolve-conflicts
    Specifies whether to override the existing app.component or create a component with another name. Available values:

    • createNew (default)
    • override (NOTE: all changes in the overridden files will be lost)

    If you created a new component, register it in app.module.ts:

    app.module.ts

    // ...import { AppComponent } from './app1.component';// ...

Add a View to the Application

The following command adds a view to an application that uses the DevExtreme layout template:

devextreme add view view-name [--icon]// ===== or =====npx devextreme-cli add view view-name [--icon]

Arguments:

  • --icon
    Specifies the view's icon (default: folder). You can choose an icon from the DevExtreme icon library.

ThemeBuilder

The ThemeBuilder UI is a tool that allows you to create custom themes in the browser; its CLI counterpart allows you to do the same with commands.

IMPORTANT

If your application uses npm v7 or later, open package.json and ensure the following:

  • The devextreme package is listed in dependencies.
  • The devextreme-themebuilder package is listed in devDependencies.
  • Both packages have the same version.

If these conditions are not met, run the following commands to install the packages:

npm i devextreme@23.2 --save --save-exactnpm i devextreme-themebuilder@23.2 --save-dev --save-exact

Build a Custom Color Scheme

devextreme build-theme [--base-theme][--input-file][--make-swatch][--output-file][--version][--widgets][--assetsBasePath][--output-color-scheme][--help]// ===== or without installing the DevExtreme CLI =====npx devextreme-cli build-theme [--base-theme][--input-file][--make-swatch][--output-file][--version][--widgets][--assetsBasePath][--output-color-scheme]

Export Theme Variables

The following command exports theme variables as a .less or .scss file:

devextreme export-theme-vars [--base-theme][--input-file][--output-format][--output-file][--version][--base][--help]// ===== or =====npx devextreme-cli export-theme-vars [--base-theme][--input-file][--output-format][--output-file][--version][--base]

Export Theme Metadata

Theme metadata is a JSON object that describes the theme. It is used to export or import a theme in the ThemeBuilder UI. Below is an example of theme metadata.

{ "items": [ { "key": "$base-text-color", "value": "rgba(94, 33, 33, 0.87)" }, { "key": "$base-accent", "value": "rgba(64, 156, 199, 1)" } ], "baseTheme": "material.blue.light.compact", "outputColorScheme": "custom-scheme", "makeSwatch": true, "version": "23.2.5", "widgets": ["datagrid","treelist","selectbox"], "assetsBasePath": "../../../node_modules/devextreme/dist/css/"}

The metadata object contains the following properties:

  • items
    An array that describes customized theme variables.

    • key
      A theme variable's name.
    • value
      The theme variable's value.
  • baseTheme
    A predefined DevExtreme theme which the custom theme is based on.

  • outputColorScheme
    The custom theme's color scheme.

  • makeSwatch
    A flag that indicates whether the theme is a color swatch.

  • version
    The target DevExtreme version.

  • widgets
    A list of UI components whose styles are included in the resulting CSS file.

  • assetsBasePath
    A path to the folder that contains the DevExtreme icons and fonts folders. This property is used only if the icons and fonts are not in the same folder as your custom theme.

Run the following command to export the metadata as a .json file:

devextreme export-theme-meta [--base-theme][--input-file][--output-file][--base][--help]// ===== or =====npx devextreme-cli export-theme-meta [--base-theme][--input-file][--output-file][--base]

Command-Line Arguments

  • --base-theme
    Specifies a base theme's name (default: generic.light).

  • --input-file
    Specifies the name of the file that contains input data (a .json file with metadata or a .less or .scss file with Bootstrap variables).

  • --output-file
    Specifies the output file name.

  • --output-format
    Specifies the format of the output variables: less or scss (default: less or the extension extracted from the --output-file value (if it contains any)).

  • --output-color-scheme
    Specifies the custom color scheme name (default: custom-scheme).

  • --make-swatch
    When present, creates a color swatch, i.e., adds a CSS scope to each CSS rule (.dx-swatch-xxx, where xxx is the value from the --output-color-scheme parameter).

  • --base
    Exports only base variables used to produce derived variables.

  • --version
    Specifies the target DevExtreme version or a tag that points to it (the default value is latest).

  • --widgets
    Specifies a comma-separated list of UI components whose styles should be included in the resulting CSS file. If this argument is not specified, styles of all UI components are included. Syntax example:

    --widgets=datagrid,treelist,selectbox
  • --assetsBasePath
    Specifies a path to the folder that contains the DevExtreme icons and fonts folders. Use this argument if the icons and fonts are not in the same folder as your custom theme.

  • --remove-external-resources
    When present, removes links to external resources, such as fonts. The theme will use local fallbacks instead.

  • --bootstrap-version
    Specifies Bootstrap version 4 or 5 if --input-file is a .scss file (default: 4).

Examples

Generate a new custom color swatch that uses Generic Dark as a base theme:

npx devextreme-cli build-theme --base-theme="generic.dark" --make-swatch --output-color-scheme="custom"

Generate a new pink color scheme based on the Material Blue Light theme, use constants from the pink.json file:

npx devextreme-cli build-theme --base-theme="material.blue.light" --input-file="pink.json" --output-color-scheme="pink"

Export base variables for the Generic Carmine theme in LESS format:

npx devextreme-cli export-theme-vars --base-theme="generic.carmine" --output-format="less" --base

Was this topic helpful?

Feel free toshare topic-related thoughts here.
Ifyou have technical questions, please create asupport ticket inthe DevExpress Support Center.

Thank you for the feedback!

DevExtreme Angular - DevExtreme CLI (2024)

FAQs

How to use DevExtreme with angular? ›

DevExtreme Angular - Add DevExtreme to an Angular CLI Application
  1. One-Command Setup. ...
  2. Install DevExtreme. ...
  3. Configure Stylesheets. ...
  4. Register 3rd-Party Dependencies.
  5. Import DevExtreme Modules. ...
  6. Run the Application. ...
  7. Add the DevExtreme Layout (Optional) ...
  8. Demos and Code Examples.

What is scaffolding in Angular? ›

In a larger application, what you'd want to do is divide the pieces into the separate components, and that's actually called scaffolding. So we're going to scaffold our application into its different pieces, and I'll also show you how you can reorganize your application to make things a little bit easier to work with.

Is DevExtreme angular free? ›

To use DevExtreme in a commercial project, you must purchase a license. For pricing/licensing options, please visit DevExtreme Purchase page.

What is the difference between DevExpress and DevExtreme? ›

While both are server-side ASP.NET MVC controls, the DevExtreme MVC Controls will render client-side UI because of they wrap client-side DevExtreme JavaScript controls in ASP.NET MVC controls. On the other hand, the DevExpress ASP.NET MVC controls will render server-side HTML and then deliver this to the client.

What is DevExtreme in Angular? ›

DevExtreme allows you to focus on business requirements rather than initial boilerplate code. Our interactive CLI tool is built atop Angular CLI. Create new responsive Angular applications with navigation menu/authentication forms via a single CLI command.

How to add script dynamically in Angular? ›

The steps are simple:
  1. Create a new script element.
  2. Copy the attributes from the template to the new script element.
  3. Copy the text node from the template to the new script element.
  4. Remove the template.
  5. Append the new script element to the DOM of the host element.
Aug 24, 2022

How to use embed code in Angular? ›

Embedding code anywhere on the page
  1. In the terminal, use the following command `ng generate component EmbedSocialWidget` to create an angular component called `EmbedSocialWidget`
  2. After the component is created, open `EmbedSocialWidget.

Top Articles
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 6854

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.