mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-16 12:33:18 +00:00
20 lines
640 B
TypeScript
20 lines
640 B
TypeScript
import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react'
|
|
|
|
import s from './button.module.scss'
|
|
|
|
export type ButtonProps<T extends ElementType = 'button'> = {
|
|
as?: T
|
|
children: ReactNode
|
|
variant?: 'primary' | 'secondary' | 'tertiary' | 'link'
|
|
fullWidth?: boolean
|
|
className?: string
|
|
} & ComponentPropsWithoutRef<T>
|
|
|
|
export const Button = <T extends ElementType = 'button'>(props: ButtonProps<T>) => {
|
|
const { variant = 'primary', fullWidth, className, as: Component = 'button', ...rest } = props
|
|
|
|
return (
|
|
<Component className={`${s[variant]} ${fullWidth ? s.fullWidth : ''} ${className}`} {...rest} />
|
|
)
|
|
}
|