PyModel/pythinker-code / .agents/skills/opentui
opentui
VerifiedBuild terminal UIs with OpenTUI. Covers core, components, audio, keymaps, React, Solid, plugins, testing, standalone executables, QR encoding, SSH, and Three.js WebGPU.
docs/components/time-to-first-draw.mdx
View on GitHub---
title: TimeToFirstDraw
description: Display the performance timestamp captured on the first draw
order: 18
skill:
intents: [time-to-first-draw, first-draw, startup-timing, performance]
---
# TimeToFirstDraw
`TimeToFirstDrawRenderable` captures and displays a `performance.now()` reading the first time it draws. OpenTUI exports the renderable from core and wrapper components from both React and Solid.
Despite its name and default label, the displayed value is the first-draw timestamp from the runtime's performance time origin. The implementation does not subtract renderer creation time or application start time, so it is **not an elapsed startup duration**.
## Core API
```typescript
import { TimeToFirstDrawRenderable } from "@opentui/core"
const firstDraw = new TimeToFirstDrawRenderable(renderer, {
label: "First draw timestamp",
precision: 1,
fg: "#94a3b8",
})
renderer.root.add(firstDraw)
```
On its first `renderSelf()` call, the renderable stores `performance.now()` in `runtimeMs`. Later draws continue to display that same value. `reset()` clears it and requests another render; the next draw captures a new timestamp.
```typescript
console.log(firstDraw.runtimeMs) // null before the first draw
firstDraw.reset()
```
## React
```tsx
import { TimeToFirstDraw } from "@opentui/react"
function App() {
return <TimeToFirstDraw label="First draw timestamp" precision={1} fg="#94a3b8" />
}
```
The React binding exports `TimeToFirstDraw` and `TimeToFirstDrawProps`. It also registers the `time-to-first-draw` intrinsic element internally; the exported component is the direct public wrapper.
## Solid
```tsx
import { TimeToFirstDraw } from "@opentui/solid"
const App = () => <TimeToFirstDraw label="First draw timestamp" precision={1} fg="#94a3b8" />
```
The Solid binding exports `TimeToFirstDraw` and `TimeToFirstDrawProps`. It also registers the `time_to_first_draw` intrinsic element internally; the exported component is the direct public wrapper.
## Options
The core renderable and both framework wrappers accept these options in addition to standard [renderable layout options](/docs/core-concepts/renderables#layout-properties):
| Option | Type | Default | Description |
| ------------ | ---------------- | ---------------------- | ----------------------------------------------------------------------- |
| `fg` | `ColorInput` | `"#AAAAAA"` | Text color |
| `label` | `string` | `"Time to first draw"` | Text before the timestamp |
| `precision` | `number` | `2` | Decimal places passed to `toFixed()`; use an integer from 0 through 100 |
| `width` | layout dimension | `"100%"` | Renderable width |
| `height` | layout dimension | `1` | Renderable height |
| `flexShrink` | `number` | `0` | Layout shrink factor |
| `alignSelf` | layout alignment | `"center"` | Cross-axis alignment |
User-supplied layout values override the width, height, shrink, and alignment defaults. `precision` is floored and clamped to zero; a non-finite value becomes `2`. The implementation does not clamp the upper bound, so values above JavaScript's `toFixed()` limit of 100 throw when the renderable draws.
The rendered line is `${label}: ${runtimeMs.toFixed(precision)}ms`. It is centered within the renderable width and truncated when it exceeds that width.
## Runtime properties
| Member | Description |
| ------------------- | ------------------------------------------------------------------ |
| `runtimeMs` | Read-only `number \| null`; first-draw `performance.now()` reading |
| `fg = value` | Change the text color and request a render |
| `color = value` | Alias for the `fg` setter |
| `textLabel = value` | Change the displayed label |
| `decimals = value` | Change the normalized display precision |
| `reset()` | Clear `runtimeMs`; capture another timestamp on the next draw |
The constructor/JSX option names are `label` and `precision`; the corresponding post-construction setter names are `textLabel` and `decimals`.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |