Build and maintain React websites using Create React App, Material-UI, and React Router with custom Babel configuration
Guide for working with React-based websites built using Create React App, Material-UI (MUI), React Router, and custom Babel configuration. This skill helps you understand the architecture, make changes safely, and follow project conventions.
This skill applies to React projects with the following structure:
Before making changes, familiarize yourself with:
When modifying code:
1. **Read existing files first**: Always use the Read tool to examine current implementation before proposing changes
2. **Check dependencies**: Review `package.json` to understand available libraries
3. **Test locally**: Run `npm start` and verify changes at `http://localhost:3000`
4. **Follow existing patterns**: Match the coding style, component structure, and naming conventions already in use
5. **Respect custom config**: Don't modify `.babelrc` or `config-overrides.js` unless explicitly requested
#### Adding a New Page
1. Create page component in `src/pages/NewPage/index.js`
2. Add route in `src/Router.js` using `<Route path="/new-page" element={<NewPage />} />`
3. Import necessary MUI components: `import { Container, Typography, Box } from '@mui/material';`
4. Use theme breakpoints for responsive design: `theme.breakpoints.down('sm')`
#### Adding a New Project/Content Item
1. Create component in appropriate subfolder (e.g., `src/pages/Projects/ProjectList/NewProject.js`)
2. Add assets to corresponding folder (e.g., `src/assets/photos/projects/new-project/`)
3. Import and include in parent component's list/grid
4. Ensure modal or detail view follows existing CardModal pattern if applicable
#### Styling Components
1. Use MUI's `sx` prop for inline styles: `<Box sx={{ padding: 2, margin: 'auto' }}>`
2. Reference theme values: `sx={{ color: 'primary.main', backgroundColor: 'background.paper' }}`
3. Use MUI breakpoints: `sx={{ fontSize: { xs: '14px', md: '16px' } }}`
4. For complex styles, consider creating a styled component with `@mui/material/styles`
#### Adding Icons
1. Import from FontAwesome: `import { faIconName } from '@fortawesome/free-solid-svg-icons';`
2. Use FontAwesomeIcon component: `<FontAwesomeIcon icon={faIconName} />`
3. Style with `sx` prop or `style` attribute
#### Working with Images
1. Place images in appropriate `src/assets/photos/` subfolder
2. Import in component: `import imageName from '../../assets/photos/path/to/image.jpg';`
3. Use in `<img>` tag or MUI `<CardMedia>` component
4. For carousels, use the installed `react-responsive-carousel` package
1. **Component organization**: Keep page components in `src/pages/`, reusable components in `src/components/`
2. **Asset management**: Organize images by feature/project in `src/assets/photos/`
3. **Responsive design**: Always test at different breakpoints (mobile, tablet, desktop)
4. **Theme consistency**: Use theme values from `src/assets/theme.js` rather than hardcoding colors/spacing
5. **Code simplicity**: Avoid over-engineering; keep solutions minimal and focused on the requested task
6. **Git commits**: Only commit when explicitly asked; stage specific files rather than using `git add .`
```javascript
// 1. Read the existing Home page component
// Use Read tool: src/pages/Home/index.js
// 2. Add new section using MUI components
import { Container, Typography, Grid, Card, CardContent } from '@mui/material';
// 3. Insert new section following existing pattern
<Container maxWidth="lg" sx={{ py: 8 }}>
<Typography variant="h3" component="h2" gutterBottom align="center">
New Section Title
</Typography>
<Grid container spacing={4}>
<Grid item xs={12} md={6}>
<Card>
<CardContent>
<Typography variant="h5">Item 1</Typography>
<Typography variant="body2" color="text.secondary">
Description text
</Typography>
</CardContent>
</Card>
</Grid>
</Grid>
</Container>
// 4. Test locally with npm start
// 5. Commit only if user requests it
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/react-website-development-with-mui/raw