> ## Documentation Index
> Fetch the complete documentation index at: https://docs.talosjs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# react:component:create

> Generate a new react component (with test) in a module or feature components folder.

Scaffold a React component and its matching test in a spa module: a `.tsx` component, a mirrored `.spec.tsx` test wired up with `happy-dom` and React Testing Library, and — the first time a module gets a component — the shared `happydom.ts` preload and `bunfig.toml` test setup. Required dev dependencies (`@happy-dom/global-registrator`, `@testing-library/react`, `@testing-library/jest-dom`) are installed at the project root when missing.

## Usage

```bash theme={null}
talos react:component:create [options]
```

## Examples

```bash theme={null}
# Interactive: prompts for the component name and spa module
talos react:component:create

# Provide both names as flags
talos react:component:create --name=UserCard --module=dashboard

# Scope the component to a feature's components folder
talos react:component:create --name=UserCard --module=dashboard --feature=settings

# Regenerate an existing component
talos react:component:create --name=UserCard --module=dashboard --override
```

## Options

| Option       | Description                                                                                                                               | Default                                  |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
| `--name`     | Component name. Normalized to PascalCase.                                                                                                 | Prompted if omitted                      |
| `--module`   | Target spa module the component is created in.                                                                                            | Prompted if omitted                      |
| `--feature`  | Feature the component is scoped to. Normalized to kebab-case, matching [`spa:feature:create`](/cli/commands/spa-feature-create)'s naming. | Component sits at the module's top level |
| `--override` | Overwrite the files if the component already exists.                                                                                      | `false`                                  |

## Behavior

Without `--feature`, the component and its test are written to `modules/<module>/src/components/<Name>.tsx` and `modules/<module>/tests/components/<Name>.spec.tsx`. With `--feature`, both move under `features/<feature>/components` instead, so the component sits alongside the rest of that feature's code.

The test imports the component with a relative path computed to match its location, so generated specs run unmodified. `happydom.ts` and `bunfig.toml` are only written once per module and never override an existing setup.
