diff --git a/fasthtml/components.py b/fasthtml/components.py
index d952dce8..3b0864f8 100644
--- a/fasthtml/components.py
+++ b/fasthtml/components.py
@@ -197,7 +197,7 @@ def find_inputs(e, tags='input', **kw):
# %% ../nbs/api/01_components.ipynb #1d8a28b1
def __getattr__(tag):
if tag.startswith('_') or tag[0].islower(): raise AttributeError
- tag = tag.replace("_", "-")
+ tag = re.sub(r'(?<=[a-z0-9])(?=[A-Z])', '-', tag.replace("_", "-")).lower()
def _f(*c, target_id=None, **kwargs): return ft_hx(tag, *c, target_id=target_id, **kwargs)
return _f
diff --git a/nbs/api/01_components.ipynb b/nbs/api/01_components.ipynb
index 449b6a58..dc22427c 100644
--- a/nbs/api/01_components.ipynb
+++ b/nbs/api/01_components.ipynb
@@ -1146,7 +1146,7 @@
"#| export\n",
"def __getattr__(tag):\n",
" if tag.startswith('_') or tag[0].islower(): raise AttributeError\n",
- " tag = tag.replace(\"_\", \"-\")\n",
+ " tag = re.sub(r'(?<=[a-z0-9])(?=[A-Z])', '-', tag.replace(\"_\", \"-\")).lower()\n",
" def _f(*c, target_id=None, **kwargs): return ft_hx(tag, *c, target_id=target_id, **kwargs)\n",
" return _f"
]