@spark-web/button
Version:
--- title: Button storybookPath: forms-buttons-button--default isExperimentalPackage: true ---
45 lines (44 loc) • 1.74 kB
TypeScript
import type { CSSObject } from '@emotion/react';
import type { BackgroundTone } from '@spark-web/a11y';
import type { IconProps } from '@spark-web/icon';
import type { DataAttributeMap } from '@spark-web/utils/internal';
import type { ButtonHTMLAttributes, ReactElement } from 'react';
import type { mapTokens } from "./utils.js";
export type ButtonSize = keyof (typeof mapTokens)[keyof typeof mapTokens];
export type ButtonProminence = 'high' | 'low' | 'none';
export type ButtonTone = Exclude<BackgroundTone, 'disabled'>;
type ChildrenWithText = {
label?: never;
children: string | number | [ReactElement<IconProps>, string | number] | [string | number, ReactElement<IconProps>];
};
type IconOnly = {
/**
* Implicit label for buttons only required for icon-only buttons
* for accessibility reasons.
*/
label: string;
children: ReactElement<IconProps>;
};
export type ButtonChildrenProps = ChildrenWithText | IconOnly;
export type NativeButtonProps = ButtonHTMLAttributes<HTMLButtonElement>;
export type CommonButtonProps = {
/** Sets data attributes for the element. */
data?: DataAttributeMap;
/** Unique identifier for the underlying element. */
id?: string;
} & ButtonStyleProps & ButtonChildrenProps;
export type ButtonStyleProps = {
/** Sets override styles for the button. */
css?: CSSObject;
/** Sets the visual prominence of the button. */
prominence?: ButtonProminence;
/** Sets whether the button has rounded sides. */
rounded?: boolean;
/** Sets the size of the button. */
size?: ButtonSize;
/** Sets the tone of the button. */
tone?: ButtonTone;
/** Sets the background color of the button. */
filled?: boolean;
};
export {};