AI CSS Styler is a project that allows users to input HTML code, receive CSS styling suggestions, and see a live preview of the changes. This tool aims to make it easy for users to experiment with styling and instantly view the results. This tool was built using Next.js and OpenAI.
- Node.js installed on your machine:
- Make sure to use 18, you can do that using
use nvm 18
- Make sure to use 18, you can do that using
- NPM (Node Package Manager) or Yarn
- Run
npm --version
to check the version
- Run
- A web browser for live preview
-
Clone the repository:
git clone https://github.com/0xmetaschool/code-styler.git
-
Navigate to the project directory:
cd code-styler
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Create a
.env
file in the root directory with the following environment variables:OPENAI_API_KEY=
-
Configure additional settings such as API keys for advanced AI functionalities (optional).
To verify the setup:
- Open the browser and go to
http://localhost:3000
. - Ensure the CSS Styler is loading and the live preview works as expected.
Input your HTML code using the provided editor. AI CSS Styler will automatically suggest CSS styling changes. You can edit the CSS and see the changes in real time on the preview pane.
<!-- Example HTML code -->
<div class="header">Hello World</div>
AI CSS Styler uses OpenAI's API to suggest CSS changes. Make sure you have the OpenAI API key set up in your environment variables.
- Live HTML and CSS editor with instant preview
- AI-powered CSS suggestions for styling
- Customizable layout and theme options
- Responsive design previews
This project is licensed under the MIT License - see the LICENSE file for details.
For support or queries, please join our discord server and ask all relevant questions there.
<div class="box">Styled by AI</div>
The AI suggests adding the following CSS:
.box {
background-color: lightblue;
padding: 20px;
border-radius: 10px;
}
Styling a responsive navigation bar:
<nav class="navbar">Home | About | Contact</nav>
AI CSS Styler suggests this responsive CSS:
.navbar {
display: flex;
justify-content: space-between;
padding: 10px;
background-color: #333;
color: white;
}
@media (max-width: 600px) {
.navbar {
flex-direction: column;
text-align: center;
}
}
Handling empty HTML elements or invalid CSS properties:
<!-- Empty element -->
<div class="empty"></div>
.empty {
/* AI will suggest removing the empty class or adding a placeholder style */
}
- AI-generated media queries for responsive design
- Option to generate the HTML based on prompts
- Advanced customization options for AI-generated suggestions
We encourage community discussion and contributions to these potential features!