{"id":13597313,"url":"https://github.com/gaucho-labs/tailwind-fuse","last_synced_at":"2025-04-12T18:42:45.139Z","repository":{"id":224607698,"uuid":"763726204","full_name":"gaucho-labs/tailwind-fuse","owner":"gaucho-labs","description":"Fuse Tailwind classes and create composite styles","archived":false,"fork":false,"pushed_at":"2025-01-19T14:31:30.000Z","size":2934,"stargazers_count":95,"open_issues_count":3,"forks_count":6,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-03T23:09:04.852Z","etag":null,"topics":["leptos","rust","tailwindcss","wasm"],"latest_commit_sha":null,"homepage":"https://tailwind-fuse.vercel.app","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaucho-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-26T20:09:55.000Z","updated_at":"2025-03-22T22:30:39.000Z","dependencies_parsed_at":"2024-04-12T15:43:26.581Z","dependency_job_id":"c92f25c6-c9a3-4468-b82e-45e3c32f2e0e","html_url":"https://github.com/gaucho-labs/tailwind-fuse","commit_stats":null,"previous_names":["gaucho-labs/tailwind-utils","gaucho-labs/tailwind-merge","gaucho-labs/tailwind-fuse"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Ftailwind-fuse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Ftailwind-fuse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Ftailwind-fuse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Ftailwind-fuse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaucho-labs","download_url":"https://codeload.github.com/gaucho-labs/tailwind-fuse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248617121,"owners_count":21134190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["leptos","rust","tailwindcss","wasm"],"created_at":"2024-08-01T17:00:30.224Z","updated_at":"2025-04-12T18:42:45.109Z","avatar_url":"https://github.com/gaucho-labs.png","language":"Rust","funding_links":[],"categories":["Styling and Design"],"sub_categories":["Unofficial"],"readme":"\u003c!-- cargo-rdme start --\u003e\n\n# Tailwind Fuse\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-gaucho--labs/tailwind--fuse-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/gaucho-labs/tailwind-fuse)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/tailwind-fuse.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/tailwind-fuse)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-tailwind--fuse-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\" height=\"20\"\u003e](https://docs.rs/tailwind-fuse)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/gaucho-labs/tailwind-fuse/ci.yml?branch=main\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/gaucho-labs/tailwind-fuse/actions?query=branch%3Amain)\n\nTwo main utils are included in this crate:\n\n1. Fuse: Fuse multiple Tailwind classes, with optional conflict resolution.\n    \u003e Inspired by [Tailwind Merge](https://github.com/dcastil/tailwind-merge)\n2. Variants: Compose type-safe variant classes\n    \u003e Inspired by [Class Variance Authority](https://github.com/joe-bell/cva)\n\n\n## Installation\n\nVariants requires the `variant` feature to be enabled.\n\n#### With variant\n```bash\ncargo add tailwind-fuse --features variant\n```\n\n#### Without variant\n```bash\ncargo add tailwind-fuse\n```\n\n## Usage: Fuse\n\nYou can use [`tw_join!`] to join Tailwind classes, and [`tw_merge!`] to merge Tailwind Classes handling conflicts.\n\n\nYou can use anything that implements [`AsTailwindClass`]\n\n```rust\nuse tailwind_fuse::*;\n\n// No conflict resolution\nassert_eq!(\n   \"flex items-center justify-center\",\n   tw_join!(\"flex\", \"items-center\", \"justify-center\")\n);\n\n// Conflict resolution\n// Right most class takes precedence\nassert_eq!(\n   \"p-4\",\n   tw_merge!(\"py-2 px-4\", \"p-4\")\n);\n\n// Refinements are permitted\nassert_eq!(\n   \"p-4 py-2\",\n   tw_merge!(\"p-4\", \"py-2\")\n);\n```\n\nYou can use Options to exclude certain classes from being merged\n\n```rust\nuse tailwind_fuse::*;\n\nassert_eq!(\n  \"flex justify-center\",\n  tw_join!(\"flex\", (false).then_some(\"items-center\"), (true).then_some(\"justify-center\"))\n)\n```\n\n### Custom Tailwind Prefix/Separator\n\nUse [`merge::set_merge_options`] to set global options for [`tw_merge!`] and variant macros.\n\nThis can only be set once. Subsequent calls will be ignored.\n\n```rust\nuse tailwind_fuse::{*, merge::*};\n\nconst OPTIONS: MergeOptions = MergeOptions {\n    prefix: \"tw-\",\n    separator: \":\",\n};\n\n// Before setting options, the default (no prefix) is used\nassert_eq!(\n  \"tw-bg-black tw-bg-white\",\n  tw_merge!(\"tw-bg-black\", \"tw-bg-white\"),\n);\n\nset_merge_options(OPTIONS);\n\nassert_eq!(\n  \"tw-bg-white\",\n  tw_merge!(\"tw-bg-black\", \"tw-bg-white\"),\n);\n\n```\n\n\n## Usage: Variants\n\nUseful for building components with first class support for tailwind. By default, conflicts are merged using [`tw_merge()`].\n\nEach [`TwClass`] represents a UI element with customizable properties (property is a \"variant\"). Each variant is represented by a [`TwVariant`], which must be an enum with a default case.\n\nThe classes are merged in the following order, with the last class takes precedence:\n1. Base class from [`TwClass`]\n2. Base class from [`TwVariant`]\n3. Enum variant class from [`TwVariant`]\n4. Override class using [`IntoTailwindClass::with_class`] on the struct or builder\n\n```rust\nuse tailwind_fuse::*;\n\n// Your Component Type\n#[derive(TwClass)]\n// Optional base class\n#[tw(class = \"flex\")]\nstruct Btn {\n    size: BtnSize,\n    color: BtnColor,\n}\n\n// Variant for size\n#[derive(TwVariant)]\nenum BtnSize {\n    #[tw(default, class = \"h-9 px-4 py-2\")]\n    Default,\n    #[tw(class = \"h-8 px-3\")]\n    Sm,\n    #[tw(class = \"h-10 px-8\")]\n    Lg,\n}\n\n// Variant for color\n#[derive(TwVariant)]\nenum BtnColor {\n    #[tw(default, class = \"bg-blue-500 text-blue-100\")]\n    Blue,\n    #[tw(class = \"bg-red-500 text-red-100\")]\n    Red,\n}\n```\n\nYou can now use the `Btn` struct to generate Tailwind classes, using builder syntax, or using the struct directly\n\n### Struct Syntax\n```rust\nlet button = Btn {\n    size: BtnSize::Default,\n    color: BtnColor::Blue,\n};\n\nassert_eq!(\n   \"flex h-9 px-4 py-2 bg-blue-500 text-blue-100\",\n   button.to_class()\n);\n\n// Conflicts are resolved (bg-blue-500 is knocked out in favor of override)\nassert_eq!(\n   \"flex h-9 px-4 py-2 text-blue-100 bg-green-500\",\n   button.with_class(\"bg-green-500\")\n);\n```\n\n### Builder Syntax\nYou access the builder using the `variants` method. Every variant that is not provided will be replaced with the default variant.\n\n```rust\n\nassert_eq!(\n   \"flex h-8 px-3 bg-red-500 text-red-100\",\n   Btn::builder()\n      .size(BtnSize::Sm)\n      .color(BtnColor::Red)\n      .to_class()\n);\n\nassert_eq!(\n   \"flex h-8 px-3 text-red-100 bg-green-500\",\n   Btn::builder()\n      .size(BtnSize::Sm)\n      .color(BtnColor::Red)\n      .with_class(\"bg-green-500\")\n);\n\n```\n\n#### VSCode Intellisense\n\nYou can enable autocompletion inside `#[tw()]` using the steps below:\n\n1. [Install the \"Tailwind CSS IntelliSense\" Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)\n\n2. Add the following to your [`settings.json`](https://code.visualstudio.com/docs/getstarted/settings):\n\n```json\n{\n  \"tailwindCSS.experimental.classRegex\": [\n    [\"#[tw\\\\\\\\([^\\\\]]*class\\\\s*=\\\\s*\\\"([^\\\"]*)\\\"\\\\)]\", \"\\\"([^\\\"]*)\\\"\"]\n  ]\n}\n```\n\n\u003c!-- cargo-rdme end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaucho-labs%2Ftailwind-fuse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaucho-labs%2Ftailwind-fuse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaucho-labs%2Ftailwind-fuse/lists"}