tutu/src/material/Button.tsx
2024-08-05 15:33:00 +08:00

21 lines
660 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;