import type { ReactNode, ForwardRefExoticComponent, RefAttributes } from 'react'; import React from 'react'; import type { AnyPreset, Preset } from '../../util/variant-types'; export type TextProps = { /** * Controls which component to use when rendering copy: e.g., `p` or `span`. * * **Default is `"p"`**. */ as?: 'p' | 'span' | 'div'; children: ReactNode; className?: string; tabIndex?: number; /** * Prop to set the desired typography value used in design. Acceptable values * match those used across the design system. */ preset?: Preset; } & React.HTMLAttributes; /** * `TextProps`, widened to also accept the presets a component reserves for its own use. */ export type InternalTextProps = Omit & { preset?: AnyPreset; }; /** * ## Usage * * `Text` is strictly used to style non-heading tags used in a page. Typography presets cover body * copy, labels, captions, overlines, code, and other treatments. * * | Type/Use | Description | Example | * |----------|-------------|---------| * | Paragraph | The default. `as="p"` for a standalone block of copy. | Body text, descriptions, help text. | * | Span | `as="span"` for text that sits inline within a larger block. | A label beside an icon, inline emphasis. | * | Div | `as="div"` when the text needs to wrap other block content. | Text composed alongside nested layout. | * * Set the treatment with `preset`, which defaults to `body-md`. The preset scale is shared across * the design system, so heading-level values appear in it too. Reach for `Heading` when you need * heading semantics; `Text` only renders `p`, `span`, and `div`. * * ## Content & Accessibility * * ### Do's * * * Use `Text` for all typographical treatments, and specify a block (`
` / `

`) tag, or `` as desired. * * ### Don'ts * * * Never use TailwindCSS or other styles on raw HTML tags to style/format typography. * * Don't use a heading preset on `Text` to imitate a heading. It changes the look without adding the semantics, so the document outline stays wrong. Use `Heading` instead. * * ## Presets * * `preset` only takes the reusable presets. A handful of presets belong to one component * (`tag`, `appHeader-label`, and friends) and are not available here, since they carry * that component's own treatment and can change with it. */ export declare const Text: ForwardRefExoticComponent<{ /** * Controls which component to use when rendering copy: e.g., `p` or `span`. * * **Default is `"p"`**. */ as?: "p" | "span" | "div"; children: ReactNode; className?: string; tabIndex?: number; /** * Prop to set the desired typography value used in design. Acceptable values * match those used across the design system. */ preset?: Preset; } & React.HTMLAttributes & RefAttributes>; /** * `Text`, typed to also accept the presets components reserve for their own use. * * For use inside EDS components only. This is deliberately absent from the package * exports, so consumers get `Text` and its reusable presets instead. * * The cast widens the `preset` type; nothing changes at runtime, since the component * only ever interpolates `preset` into a class name. */ export declare const InternalText: ForwardRefExoticComponent>;