Desk accessories · component · 14K

Calculator

A desk calculator in the spirit of the classic Calculator desk accessory: a display over a keypad of square, 1px-framed keys (C, E, =, *, /, -, +, ., 0–9) that invert while pressed. Immediate execution, repeated =, full keyboard input and results rounded for display, so 0.1 + 0.2 shows 0.3.

Keyboard: digits, . or ,, + - * x /, Enter or = for equals, Esc or C to clear, E or Delete to clear the entry, Backspace to erase a digit. Clicking a key keeps focus on the display so typing carries on; Tab reaches every key. Results are announced politely. ⌘C/Ctrl+C copies the display and pasting a number enters it. Rename any key's spoken name through labels.keys.

Install

pnpm dlx shadcn@latest add @s7ui/calculator

Example

This example also uses @s7ui/window.

0

Info

Files:
components/retro/calculator.tsx
Uses:
@s7ui/theme
Packages:
—