# MathFormula

LaTeX formulas, rendered with KaTeX and readable by screen readers.

- **Use it for**: LaTeX formulas with accessible MathML.
- **Not for**: Whole Markdown replies. Try [RichMarkdownResponse](https://unseenui.com/components/rich-markdown-response/).

## Installation

```bash
npm install @stackunseen/ui katex
```

## Usage

```tsx
import { MathFormula } from '@stackunseen/ui/math';
import '@stackunseen/ui/styles.css';
import 'katex/dist/katex.min.css';

<MathFormula variant="block" formula={latex} label="Quadratic formula" />
```

## Props

- `formula` (`string`): TeX source, up to 10,000 characters. Invalid or longer input shows a source preview and message.
- `label` (`string (optional)`): An accessible name. Defaults to Mathematical formula.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `className` | `string` | Added to the root element, after the component's own classes. |
| `formula` (required) | `string` |  |
| `label` | `string` |  |
| `variant` | `"inline" \| "scroll" \| "block"` |  |

## Keyboard

Tab reaches the formula or fallback source for keyboard reading and scrolling. The output includes MathML; test it with the screen readers you support.

## Works with

[MarkdownResponse](https://unseenui.com/components/markdown-response/), [MarkdownCodeBlock](https://unseenui.com/components/markdown-code-block/), [RichMarkdownResponse](https://unseenui.com/components/rich-markdown-response/), [MermaidDiagram](https://unseenui.com/components/mermaid-diagram/)

Page: https://unseenui.com/components/math-formula/
