import type { HTMLAttributes, ReactNode } from 'react'; import React from 'react'; import type { IconOrContent } from '../../util/utility-types'; import type { Size } from '../../util/variant-types'; import { type HeadingElement } from '../Heading'; export type CardProps = HTMLAttributes & { /** * Child node(s) that can be nested inside component */ children?: ReactNode; /** * CSS class names that can be appended to the component. */ className?: string; /** * CSS properties defined for the HTML element. Includes the component's CSS Custom Properties: * * - `--card__top-stripe-bg` */ style?: CardCSSProperties; /** * When `isInteractive` and has a behavior set, name is used as the name of the hidden form field. */ name?: string; /** * When `isInteractive`, describes the behavior of the card when selected. Single (radio) or multiple (checkbox) selection. */ behavior?: 'checkbox' | 'radio'; /** * Treatment for the card's container element. When using `"custom-brand"`, set the * container background and border color using the brand border/bg utility classes. * * **Default is `"default"`**. */ containerColor?: 'default' | 'call-out' | 'custom-brand'; /** * The bounding box and other container emphasis details * * **Default is `"low"`**. */ containerStyle?: 'none' | 'low' | 'high'; /** * State to trigger when the card is being dragged. Can be combined with the HTML `draggable` property, * or used programmatically with drag and drop libraries */ isDragging?: boolean; /** * Whether `Card` itself is directly interactive (code wrapping component so that clicking will perform some navigation or action) * * **Default is `false`**. */ isInteractive?: boolean; /** * Decorative top bar used to cause a highlight on a given card. When present, this * corresponds to a specified emphasis level. * * **Default is `"none"`**. * * @deprecated */ topStripe?: 'none' | 'medium' | 'high'; }; export type CardSubComponentProps = { /** * Child node(s) that can be nested inside component */ children: ReactNode; /** * CSS class names that can be appended to the component. */ className?: string; }; /** * Heading levels `Card.Header` takes for its title. * * A card always sits inside a section the page has already given a heading, so its title * goes below that heading rather than competing with it. `h2` and `h3` cover where a card * actually lands in an outline: `h1` would claim the page, and `h4` and down are deeper * than a card nests. * * Kept as a value as well as a type so the component can check a level that reached it * from untyped code, where the type alone stops nothing. */ declare const titleElements: readonly ["h2", "h3"]; export type CardHeaderTitleElement = Extract; export type CardHeaderProps = { /** * Child node(s) that can be nested inside component. Used in place of any of the above named slots. */ children?: ReactNode; /** * CSS class names that can be appended to the component. */ className?: string; /** * Component slot to add in an action-focused area to a card. Typically a button with hidden options. */ action?: ReactNode; /** * Text above the main title of the card, to add category text/information. */ eyebrow?: string; /** * Card slot sitting in front of the card header text. Takes an EDS icon name, or any * content to render in its place, sized to match `size`. */ icon?: IconOrContent; /** * Overall size treatment of the Card header */ size?: Extract; /** * Secondary text used to describe the content in more detail */ subTitle?: ReactNode; /** * The title/heading of the component */ title?: string; /** * Which heading level `title` renders at. Take it from the page outline: the level below * whatever heading introduces the section the card sits in, not the size you want the * title to read at. * * Only `h2` and `h3` are available, since a card's title sits under a heading the page * has already set. The level never changes the title's treatment, which follows `size`, * so a card can sit at the right level in the outline and still look the same. * * **Default is `"h3"`**. */ titleAs?: CardHeaderTitleElement; }; export interface CardCSSProperties extends React.CSSProperties { '--card__top-stripe-bg'?: string; } /** * ## Usage * * * **Static card**: Group related elements, including some combination of images, text, buttons, input fields, etc. * * **Interactive card**: A selectable or actionable card. * * ### Best Practices * * * Display information so that what the user needs to know first is prioritized. * * Limit call-to-action buttons and/or links, using only one primary call-to-action per card. * * Do not use a card as an action. * * ## Header titles * * `Card.Header` renders its `title` as a heading, at the level `titleAs` sets. Take that * level from the page outline, the one below whatever heading introduces the section the * card sits in. Only `h2` and `h3` are available, because a card's title always sits under * a heading the page has already set. * * | Prop | What it sets | Where the value comes from | * |------|--------------|----------------------------| * | `titleAs` | Which heading tag the title renders as, `h2` or `h3`. | The document structure: the level below the heading of the section holding the card. | * | `size` | The treatment of the title, and the rest of the header with it. | The design. | * * The two stay independent, so moving a card to a different level of the outline never * changes how its title looks. * * ## Content & Accessibility * * ### Do's * * * Group related information within separate cards. * * Use subheadings, paragraphs, and bullet lists to break up larger amounts of content. * * Use headings that make the card's purpose clear. * * Include essential, summarized information. * * Set `titleAs` to the level the page outline calls for, so a card's title doesn't skip a heading level. * * ### Don'ts * * * Don't overwhelm the card with too much content; keep it scannable. * * Avoid too many call-to-action buttons or links within the same card. * * Don't pick `titleAs` for the size it renders at. The title's treatment comes from `size`. */ export declare const Card: { ({ containerColor, behavior, className, children, containerStyle, isDragging, isInteractive, name, topStripe, ...other }: CardProps): React.JSX.Element; displayName: string; Body: { ({ children, className, ...other }: CardSubComponentProps): React.JSX.Element; displayName: string; }; Footer: { ({ children, className, ...other }: CardSubComponentProps): React.JSX.Element; displayName: string; }; Header: { ({ action, children, className, eyebrow, icon, size, subTitle, title, titleAs, ...other }: CardHeaderProps): React.JSX.Element; displayName: string; }; }; export {};