metacubexd/src/components/Button.tsx

22 lines
563 B
TypeScript
Raw Normal View History

import { JSX, ParentComponent, Show, splitProps } from 'solid-js'
import { twMerge } from 'tailwind-merge'
export const Button: ParentComponent<
2023-09-03 02:22:38 +08:00
JSX.ButtonHTMLAttributes<HTMLButtonElement> & { loading?: boolean }
> = (props) => {
const [local, others] = splitProps(props, ['class', 'loading'])
return (
<button
class={twMerge('btn', local.loading ? 'btn-disabled' : local.class)}
{...others}
>
<Show when={local.loading}>
<span class="loading loading-spinner" />
</Show>
{props.children}
</button>
)
}