A modern web app built with SvelteKit and TypeScript that helps designers and developers find the closest Tailwind CSS color to any hex color code. Perfect for ensuring design consistency and exploring Tailwind's color palette.
Tailwind CSS provides a comprehensive color palette, but when working with custom colors, it can be challenging to find the closest match. This tool simplifies that process by:
- Extracting hex color codes from user input or pasted content.
- Validating the color format (e.g.,
#FF5733
orFF5733
). - Displaying the closest matching Tailwind color.
- Offering a list of multiple close matches for exploration.
- Hex Color Validation: Ensures the entered color code is valid.
- Tailwind Color Matching: Finds the closest Tailwind CSS color.
- Multiple Matches: Displays a list of top matches for selection.
- Clipboard Support: Paste color codes directly into the input field.
- Example Colors: Try predefined color examples with a single click.
Clone the repository and install dependencies:
git clone https://github.com/yourusername/tailwind-color-matcher.git
cd tailwind-color-matcher
npm install
To run the application locally:
-
Clone the repository:
git clone https://github.com/yourusername/tailwind-color-matcher.git cd tailwind-color-matcher
-
Install the dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:3000
to start using the app.
The app leverages SvelteKit's reactive features to:
-
Input Binding: The
ColorInput
component binds the input field to avalue
state, allowing two-way data binding. -
Color Validation: The
extractHexColor
utility function validates the entered color code (e.g.,\#FF5733
orFF5733
). -
Tailwind Color Matching: The
findMultipleMatches
function finds the closest Tailwind CSS color based on the validated input. -
Dynamic Updates: Reactive statements (
\$: ...
) automatically update the UI when the input changes, ensuring a seamless user experience.
We welcome contributions to enhance this project. To get started:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature-name
-
Make your changes and commit them.
-
Push to your forked repository:
git push origin feature-name
-
Open a pull request with a clear description of your changes.
Please ensure your code adheres to the project's coding standards and includes appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for details.