Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>React Component GeneratorNew to Visual Studio Code? Get it now.
React Component Generator

React Component Generator

Roberth G

|
217 installs
| (1) | Free
Generates files for new React components
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Marketplace

All Contributors

Github Twitter buymeacoffee

React Component Generator

Generate React components:

  • src
    • /components
      • /NewComponent
        • index.ts|.js
        • NewComponent.css|.scss|.module.css|.module.scss
        • NewComponent.ts|.js
        • /tests
          • NewComponent.test.ts|.js

Features

Right click on a folder in the explorer and click Generate React component to scaffold out a new React component with all the files you need. Or choose Generate React component from Command Palette while in an Active Editor.

Using Component Templates

If you are not happy with the default component template, you can bring your own using the reactComponentGenerator.componentTemplate in your settings.

Consider following example component template:

"reactComponentGenerator.componentTemplate": [
    "import React from 'react';",
    "",
    "import styles from './${componentName}.${stylesLanguage}';",
    "",
    "type Props = {",
    "  //",
    "}",
    "",
    "export function ${componentName}(props: Props) {",
    "  return (<div className={styles.container}></div>)",
    "}"
  ]

This would generate components like this:

import React from "react";

import styles from "./SuperCoolComponent.module.scss";

type Props = {
  //
};

export function SuperCoolComponent(props: Props) {
  return <div className={styles.container}></div>;
}

Settings

Name Description Default
reactComponentGenerator.language Specifies if components should be generated in TypeScript or JavaScript. ts
reactComponentGenerator.stylesLanguage Specifies what language will be used for styles. scss
reactComponentGenerator.useIndexFile Specifies if the components folder should have an index file to export all of its components. true
reactComponentGenerator.createTestsFile Specifies if the components should have test files. false
reactComponentGenerator.componentTemplate Specifies a temlate for components using a string-array. none

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Hans
Hans

💻 📖 🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft