tutu/src/material/Button.tsx
2024-07-14 20:28:44 +08:00

22 lines
659 B
TypeScript

import { Component, JSX, splitProps } from "solid-js";
import materialStyles from "./material.module.css";
/**
* Material-styled button.
*
* @param type Same as `<button>`'s type property, the default is 'button'
*/
const Button: Component<JSX.ButtonHTMLAttributes<HTMLButtonElement>> = (
props,
) => {
const [managed, passthough] = splitProps(props, ["class", 'type']);
const classes = () =>
managed.class
? [materialStyles.button, managed.class].join(" ")
: materialStyles.button;
const type = () => managed.type ?? 'button'
return <button type={type()} class={classes()} {...passthough}></button>;
};
export default Button;