From 6747c4aa7083dab8893a71404debd13531d7ca58 Mon Sep 17 00:00:00 2001
From: Eryk Mika <eryk.mika@wpdesk.eu>
Date: Fri, 14 Mar 2025 15:29:01 +0100
Subject: [PATCH] fix: support for floats

---
 src/NumberWithUnit/NumberWithUnit.jsx | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/NumberWithUnit/NumberWithUnit.jsx b/src/NumberWithUnit/NumberWithUnit.jsx
index 981ac5b..9ab0fda 100644
--- a/src/NumberWithUnit/NumberWithUnit.jsx
+++ b/src/NumberWithUnit/NumberWithUnit.jsx
@@ -14,19 +14,21 @@ export default function NumberWithUnit({
 	const splitValues = function (fontSize) {
 
 		if (!fontSize) {
-			return {size: "0", unit: "px"};
+			return { size: "0", unit: "px" };
 		}
 
-		const match = fontSize.match(/^(\d+)([a-z%]+)$/i);
+		const match = fontSize.match(/^(\d*\.?\d+)([a-z%]+)$/i);
 
 		if (!match) {
-			return {size: "16", unit: "px"};
+			return { size: "16", unit: "px" };
 		}
+
 		return {
 			size: match[1],
 			unit: match[2]
 		};
-	}
+	};
+
 
 	const [unit, setUnit] = useState(splitValues(value).unit);
 	const [size, setSize] = useState(splitValues(value).size);
-- 
GitLab