UNPKG

@hypothesis/frontend-shared

Version:

Shared components, styles and utilities for Hypothesis projects

39 lines (38 loc) 1.37 kB
import type { JSX } from 'preact'; import type { IconComponent, PresentationalProps } from '../../types'; type ComponentProps = { /** * Is the element associated with this button expanded? * (sets `aria-expanded` attribute) */ expanded?: boolean; /** * Optional icon to display at left of button label text. */ icon?: IconComponent; /** * Is this button currently "active"? * (sets `aria-pressed` or `aria-selected` depending on button `role`) */ pressed?: boolean; /** * Button title (sets `aria-label` attribute) */ title?: string; /** Use `expanded` prop instead */ 'aria-expanded'?: never; /** Use `pressed` prop instead */ 'aria-pressed'?: never; /** Use `title` prop instead */ 'aria-label'?: never; size?: 'xs' | 'sm' | 'md' | 'lg' | 'custom'; variant?: 'primary' | 'secondary' | 'custom'; unstyled?: boolean; }; export type HTMLButtonAttributes = Omit<JSX.ButtonHTMLAttributes<HTMLButtonElement>, 'icon' | 'size'>; export type ButtonProps = PresentationalProps & ComponentProps & HTMLButtonAttributes; /** * Render a button with optional icon */ export default function Button({ children, classes, elementRef, expanded, pressed, title, icon: Icon, size, variant, unstyled, role, ...htmlAttributes }: ButtonProps): JSX.Element; export {};