mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-18 12:33:22 +00:00
23 lines
701 B
TypeScript
23 lines
701 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
|
|
className?: string
|
|
fullWidth?: boolean
|
|
variant?: 'icon' | 'link' | 'primary' | 'secondary' | 'tertiary'
|
|
} & ComponentPropsWithoutRef<T>
|
|
|
|
export const Button = <T extends ElementType = 'button'>(props: ButtonProps<T>) => {
|
|
const { as: Component = 'button', className, fullWidth, variant = 'primary', ...rest } = props
|
|
|
|
return (
|
|
<Component
|
|
className={`${s[variant]} ${fullWidth ? s.fullWidth : ''} ${className}`}
|
|
{...rest}
|
|
/>
|
|
)
|
|
}
|