master
 1---
 2import type { HTMLAttributes } from 'astro/types';
 3
 4type Props = (HTMLAttributes<'button'> | HTMLAttributes<'a'>) & {
 5  useDefaultClass?: boolean;
 6};
 7let { class: className, useDefaultClass, ...rest } = Astro.props;
 8
 9function isAnchor(props: Props): props is HTMLAttributes<'a'> {
10  return 'href' in props;
11}
12
13const Tag = isAnchor(rest) ? 'a' : 'button';
14---
15
16<Tag class:list={[(useDefaultClass ?? true) && 'btn', className]} {...rest as object}>
17  <slot />
18</Tag>