Generate Component
Generates a new React or React Native component with a matching index file for clean imports.
Usage
Interactive:
remodel
# then select "Create Component"Non-interactive:
remodel component --name UserProfile --ts --platform reactShort alias:
remodel c --name UserProfile --tsOptions
| Flag | Type | Default | Description |
|---|---|---|---|
--name <name> | string | (required) | Component name in PascalCase (e.g., UserProfile) |
--dir <directory> | string | ./src/components | Directory where the component folder is created |
--ts | boolean | from config | Use TypeScript (.tsx) |
--js | boolean | from config | Use JavaScript (.jsx) |
--platform <platform> | string | from config | react or react-native |
💡
Component names must be PascalCase (e.g., UserProfile, TodoList). The CLI validates this and will prompt you to re-enter if the name doesn’t match.
Generated Files
Running remodel component --name UserProfile --ts --platform react creates:
src/components/
UserProfile/
UserProfile.tsx
index.tsReact Component
src/components/UserProfile/UserProfile.tsx
import React from 'react';
interface UserProfileProps {}
export function UserProfile({}: UserProfileProps) {
return (
<div>
<h1>UserProfile</h1>
</div>
);
}React Native Component
When --platform react-native is used:
src/components/UserProfile/UserProfile.tsx
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
interface UserProfileProps {}
export function UserProfile({}: UserProfileProps) {
return (
<View style={styles.container}>
<Text>UserProfile</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {},
});Index File
src/components/UserProfile/index.ts
export { UserProfile } from './UserProfile';This barrel file allows clean imports:
import { UserProfile } from './components/UserProfile';Interactive Flow
When running interactively, the Create Component screen walks you through:
- Component name — text input with PascalCase validation
- Language — skipped if
.remodelconfig has a language set - Platform — skipped if
.remodelconfig has a platform set - Directory — directory picker with filesystem autocomplete, defaults to
./src/components - Generate — creates the component files
- Success — shows a summary of created files