import React from 'react'; import type { IconOrContent } from '../../util/utility-types'; import type { Size } from '../../util/variant-types'; type ButtonHTMLElementProps = React.ButtonHTMLAttributes; export type ButtonProps = Omit & { /** * Component used to render the element. Meant to support interaction with framework navigation libraries. * * **Default is `"button"`**. */ as?: string | React.ElementType; /** * `Button` contents or label. */ children?: string; /** * CSS properties defined for the HTML element. Includes the component's CSS Custom Properties: * * - `--button__bg` * - `--button__border` * - `--button__fg` */ style?: ButtonCSSProperties; /** * Determine the behavior of the button upon click: * - **button** `Button` is a clickable button with no default behavior * - **submit** `Button` is a clickable button that submits form data * - **reset** `Button` is a clickable button that resets the form-data to its initial values */ type?: 'button' | 'reset' | 'submit'; /** * Sets the hierarchy rank of the button * * **Default is `"primary"`**. */ rank?: 'primary' | 'secondary' | 'tertiary'; /** * The size of the button on screen */ size?: Extract; /** * The variant of the default tertiary button. */ context?: 'default' | 'standalone'; /** * Content for the icon slot, used when `iconLayout` is set. Takes an EDS icon name, or * any content to render in its place, sized to match `size`. * * Required whenever `iconLayout` is anything but `"none"`, and has no default: the layout * reserves space for an icon, so a missing one leaves a gap rather than falling back to * some arbitrary glyph. EDS warns when the two disagree. * * Custom content is rendered as-is, so it carries its own accessible treatment. With * `iconLayout="icon-only"` the button still takes its accessible name from `aria-label`, * the same as it does for an icon name. */ icon?: IconOrContent; /** * Allows configuation of the icon's positioning within `Button`. * * - When set to a value besides `"none"`, an icon must be specified. * - When `"icon-only"`, `aria-label` must be given a value. */ iconLayout?: 'none' | 'left' | 'right' | 'icon-only'; /** * Status (color) variant for `Button`. * * **Default is `"default"`**. */ variant?: 'default' | 'neutral' | 'critical' | 'inverse'; /** * Whether the width of the button is set to the full layout. */ isFullWidth?: boolean; /** * Whether `Button` is set to disabled state (disables interaction and updates appearance). * * Note: this will set the internal field to `disabled` as well. Prefer this to just setting `disabled`. */ isDisabled?: boolean; /** * Loading state passed down from higher level used to trigger loader and text change. */ isLoading?: boolean; } & ExtendedElement; export interface ButtonCSSProperties extends React.CSSProperties { /** * Custom property to customize the background color of this component (e.g., background color) */ '--button__bg'?: string; /** * Custom property to customize the border color of this component */ '--button__border'?: string; /** * Custom property to customize the foreground color of this component (e.g., text, icon, etc.) */ '--button__fg'?: string; } /** * ## Usage * * | Type/Use | Description | Example | * |----------|-------------|---------| * | Primary default | Main call-to-action with highest visual prominence. | Submit form. Complete purchase. Save changes. | * | Secondary default | Less prominent than primary, used for alternative actions. | Cancel. Edit. Learn more. Go back. | * | Tertiary default | Minimal styling (often text-only); used for low-emphasis actions. | View details. Skip. Optional settings. | * | Critical | Styled to indicate danger. | Delete. Remove. Reset. Sign out. | * | Inverse | Transparent background; used on dark surfaces or inside modals. | De-emphasized actions on colored backgrounds. | * | Icon | Icon-only or icon + tooltip; compact for toolbars or utility actions. | Favorite. Share. Settings. Search. Close. | * | Loading | Temporarily disabled with a spinner or progress indicator. | "Saving…", "Loading…". | * * ### Best Practices * * * Use one primary button per action to highlight the action the user is most likely to take. * * Use secondary buttons alongside a primary button; don't use a secondary button in isolation. * * Use tertiary buttons alongside primary or secondary actions. To use a tertiary button alone, set its `context` to `"standalone"`. * * ## Content & Accessibility * * ### Do's * * * Use a label that indicates what will happen after the button is clicked. * * Start with a verb that encourages action. * * Use sentence case and try to stay to 3 or fewer words. * * Use the *{verb} + {noun}* formula, except for common actions like "Done", "Close", "Cancel", "Add", or "Delete". * * ### Don'ts * * * Use punctuation. */ export declare const Button: React.ForwardRefExoticComponent & { /** * Component used to render the element. Meant to support interaction with framework navigation libraries. * * **Default is `"button"`**. */ as?: string | React.ElementType; /** * `Button` contents or label. */ children?: string; /** * CSS properties defined for the HTML element. Includes the component's CSS Custom Properties: * * - `--button__bg` * - `--button__border` * - `--button__fg` */ style?: ButtonCSSProperties; /** * Determine the behavior of the button upon click: * - **button** `Button` is a clickable button with no default behavior * - **submit** `Button` is a clickable button that submits form data * - **reset** `Button` is a clickable button that resets the form-data to its initial values */ type?: "button" | "reset" | "submit"; /** * Sets the hierarchy rank of the button * * **Default is `"primary"`**. */ rank?: "primary" | "secondary" | "tertiary"; /** * The size of the button on screen */ size?: Extract; /** * The variant of the default tertiary button. */ context?: "default" | "standalone"; /** * Content for the icon slot, used when `iconLayout` is set. Takes an EDS icon name, or * any content to render in its place, sized to match `size`. * * Required whenever `iconLayout` is anything but `"none"`, and has no default: the layout * reserves space for an icon, so a missing one leaves a gap rather than falling back to * some arbitrary glyph. EDS warns when the two disagree. * * Custom content is rendered as-is, so it carries its own accessible treatment. With * `iconLayout="icon-only"` the button still takes its accessible name from `aria-label`, * the same as it does for an icon name. */ icon?: IconOrContent; /** * Allows configuation of the icon's positioning within `Button`. * * - When set to a value besides `"none"`, an icon must be specified. * - When `"icon-only"`, `aria-label` must be given a value. */ iconLayout?: "none" | "left" | "right" | "icon-only"; /** * Status (color) variant for `Button`. * * **Default is `"default"`**. */ variant?: "default" | "neutral" | "critical" | "inverse"; /** * Whether the width of the button is set to the full layout. */ isFullWidth?: boolean; /** * Whether `Button` is set to disabled state (disables interaction and updates appearance). * * Note: this will set the internal field to `disabled` as well. Prefer this to just setting `disabled`. */ isDisabled?: boolean; /** * Loading state passed down from higher level used to trigger loader and text change. */ isLoading?: boolean; } & React.RefAttributes>; export {};