The extension automatically creates folder for react component containing :
index.ts
ComponentName.tsx
ComponentName.styles.js
(forstyled
-component oremotion
option)ComponentName.css
(forcss
style option)ComponentName.scss
(forsass
style option)ComponentName.less
(forless
style option)ComponentName.module.css
(formodule css
style option)ComponentName.module.scss
(formodule sass
style option)ComponentName.module.less
(formodule less
style option)
The extension can also automatically create SSG, SSR and normal pages for next.js
- Right click on the file or folder in the file explorer
- Select one of following options the generate new files and templated code
- Enter a component name in the pop up in camelCase or PascalCase. If you enter the component name as in camelCase, then extension will convert it PascalCase automatically.
You can access to the extension's settings through VSCode settings. You can customize:
config item | default | options | description |
---|---|---|---|
ComponentGenerator.global.generateFolder |
true | boolean | Generate or not separate folder for newly created component |
ComponentGenerator.global.quotes |
single |
single , double |
Controls the quotes for the imports in the files. |
ComponentGenerator.global.case |
pascal |
pascal , param |
Controls the casing that the files should be generated in. |
ComponentGenerator.indexFile.create |
true | boolean | Whether to generate component's index file or not. |
ComponentGenerator.indexFile.extension |
ts |
string | The extension of generated component index file. e.g.: index.(extension ) |
ComponentGenerator.nextPage.extension |
tsx |
string | The extension of generated nextjs page file. e.g.: my-page.tsx(extension ) |
ComponentGenerator.mainFile.create |
true | boolean | Whether to generate component's main file or not. |
ComponentGenerator.mainFile.extension |
tsx |
string | The extension of generated component file. e.g.: ComponentName.(extension ) |
ComponentGenerator.styleFile.create |
false | boolean | Whether to generate component's stylesheet file or not. |
ComponentGenerator.styleFile.extension |
ts |
string | The extension of generated stylesheet file. e.g.: ComponentName.styles.(extension ) |
ComponentGenerator.styleFile.suffix |
`` | string | The suffix to add to the end of the stylesheet filename. Default: ComponentName.styles .(extension) |
ComponentGenerator.styleFile.type |
module.css (.module.css) |
options below | The type of stylesheet file to create |
- "css (.css)" - ComponentName.styles.
css
- "scss (.scss)" - ComponentName.styles.
scss
- "less (.less)" - ComponentName.styles.
less
- "module.css (.module.css)" - ComponentName.styles.module.
css
- "module.scss (.module.scss)" - ComponentName.styles.module.
scss
- "module.less (.module.less)" - ComponentName.styles.module.
less