This repository is dedicated to practicing and mastering Styled Components in React.
Main features:
- Learn and implement Styled Components
- Gain practical experience in organizing styles for scalable applications.
Are you interested in React and styling techniques? See my other project.
The project uses Node.js and npm. To run the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/devmentor-pl/practice-react-styling.git
-
Navigate to the project directory:
cd practice-react-styling -
Install dependencies:
npm install
-
Start the development server:
npm start
The application will be available at http://localhost:3000.
The project contains several tasks organized in folders 01 to 05, each demonstrating different styling methods. Below is an overview of the tasks:
- 01 – Create an
<Alert>component styled with Styled Components. The component should support variants likeprimaryandsecondary. - 02 – Build a
<Button>component similar to React Bootstrap, supporting props likevariant,size,active, anddisabled. - 03 – Implement a
<Breadcrumb>component with<Breadcrumb.Item>for navigation. It should supporthrefandactiveprops. - 04 – Develop
<Tabs>and<Tab>components to manage tabbed content. The active tab should dynamically update the displayed content. - 05 – Create a
<Card>component composed of subcomponents like<Card.Img>,<Card.Body>,<Card.Title>, and<Card.Text>. Use the previously created<Button>component within the card.
Each task includes specific instructions in its respective README.md file.
The <Card> component is a complex and reusable component built with subcomponents like <Card.Img>, <Card.Body>, <Card.Title>, and <Card.Text>. It demonstrates advanced component composition and integration with the previously created <Button> component.
<Card>
<Card.Img src="image.jpg" alt="Example" />
<Card.Body>
<Card.Title>Card Title</Card.Title>
<Card.Text>Some example text to build on the card title and make up the bulk of the card's content.</Card.Text>
<Button variant="primary">Go somewhere</Button>
</Card.Body>
</Card>This example showcases:
- Dynamic styling: Styled Components are used to style the card and its subcomponents.
- Component composition: The
<Card>component is composed of smaller, reusable subcomponents. - Integration: The
<Button>component created in Task 02 is reused within the<Card>component.
For more details, refer to the implementation in Task05.js and the corresponding README.md.
- Dynamic styling: Styled Components were used extensively to enable dynamic and reusable styling across components.
- Component composition: Components like
<Card>and<Tabs>were designed with subcomponents for better modularity and reusability. - Scalability: The project demonstrates how to organize styles and components for scalable React applications.
- Theming: The use of
ThemeProviderallows for centralized theme management, making it easier to maintain consistent styling.
This project provides a solid foundation for mastering React component styling techniques.
If you have any questions or feedback, feel free to reach out!
Find me on GitHub or LinkedIn.
Thanks to my Mentor - devmentor.pl – for providing me with this task and for code review.
