Doc Math
Display math as LaTeX source in a monospace box.
npx shadcn@latest add @velaui/doc-mathpnpm dlx velaui add @velaui/doc-mathyarn dlx shadcn@latest add @velaui/doc-mathbunx --bun shadcn@latest add @velaui/doc-mathveni add doc-mathInstalls the copy of vela-ui that veni-builder serves to Venizia apps; veni-builder serves the Radix UI copy only, so this tab exists for that base alone.
npx shadcn@latest add @velaui/doc-mathpnpm dlx velaui add @velaui/doc-mathyarn dlx shadcn@latest add @velaui/doc-mathbunx --bun shadcn@latest add @velaui/doc-mathExamples
- Default
Usage
Props
| Prop | Type | Default |
|---|---|---|
className | string | — |
onChange | (value: string) => void | — |
readOnly | boolean | — |
valuerequired | string | — |
Takes these and every prop of DocMathProps.
Dependencies
- npm
- none besides React
- Installs with it
- nothing else
Source
components/ui/doc-math.tsx
import { cn } from "@/lib/utils";
export interface DocMathProps {
/** LaTeX source. */
value: string;
readOnly?: boolean;
onChange?: (value: string) => void;
className?: string;
}
/** Display math as LaTeX source in a monospace box (no typeset preview). */
function DocMath({ value, readOnly, onChange, className }: DocMathProps) {
return (
<div className={cn("my-2 overflow-hidden rounded-md border border-border-default", className)}>
<div className="px-2 py-1 text-xs text-text-muted">LaTeX · $$</div>
<textarea
spellCheck={false}
aria-label="LaTeX"
value={value}
readOnly={readOnly}
onChange={(e) => onChange?.(e.target.value)}
className="block min-h-12 w-full resize-none bg-transparent p-2 font-mono text-sm outline-none field-sizing-content"
/>
</div>
);
}
export { DocMath };