#types for li html tag
3 messages · Page 1 of 1 (latest)
Hi @keen prism. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
You can use Astro’s HTMLAttributes utility type from astro/types and pass it the tag name "li".
For example, to make a component whose props are all valid <li> attributes plus your own:
---
// src/components/MyLi.astro
import type { HTMLAttributes } from "astro/types";
interface Props extends HTMLAttributes<"li"> {
// your extra props here
isActive?: boolean;
}
const { isActive, ...attrs } = Astro.props;
---
<li {...attrs} class={isActive ? "active" : attrs.class}>
<slot />
</li>