
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
floating-react-calculator
Advanced tools
A customizable React calculator component (MUI-based) designed to be published as an npm package.
Modern, minimalist React calculator component with a clean, professional design (MUI-based).
✨ Minimalist Design - Clean white background with subtle borders and soft shadows 🎨 Customizable Title - Set your own calculator title (default: "Calculator") 📜 Calculation History - View and reuse previous calculations 💾 LocalStorage Persistence - Remembers position and minimized state 🖱️ Draggable - Move the calculator anywhere on screen (floating mode) with intuitive drag handle ⌨️ Keyboard Support - Full keyboard input including Esc (clear), Backspace, Enter 🔢 Enhanced Buttons - C (clear), ⌫ (backspace), and color-coded operators 🎯 Three Display Modes - Embedded, Modal, or Floating

npm install @salihoz0/react-calculator
This component requires the following peer dependencies:
npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material
import React from 'react';
import Calculator from '@salihoz0/react-calculator';
function App() {
return (
<div>
<h1>My App</h1>
<Calculator mode="embedded" />
</div>
);
}
import React, { useState } from 'react';
import Calculator from '@salihoz0/react-calculator';
function App() {
const [result, setResult] = useState('');
return (
<div>
<Calculator
mode="embedded"
title="My Calculator"
onChange={(value) => setResult(value)}
/>
<p>Current value: {result}</p>
</div>
);
}
import React, { useState } from 'react';
import Calculator from '@salihoz0/react-calculator';
function App() {
const [isOpen, setIsOpen] = useState(false);
return (
<div>
<button onClick={() => setIsOpen(true)}>Open Calculator</button>
<Calculator
mode="modal"
title="Calculator Modal"
initiallyOpen={isOpen}
onClose={() => setIsOpen(false)}
onChange={(value) => console.log('Result:', value)}
/>
</div>
);
}
import React, { useState } from 'react';
import Calculator from '@salihoz0/react-calculator';
function App() {
const [isOpen, setIsOpen] = useState(false);
return (
<div>
<button onClick={() => setIsOpen(!isOpen)}>
{isOpen ? 'Close' : 'Open'} Calculator
</button>
<Calculator
mode="floating"
title="Floating Calculator"
initiallyOpen={isOpen}
setOpen={setIsOpen}
width={400}
height={550}
/>
</div>
);
}
import React from 'react';
import Calculator from '@salihoz0/react-calculator';
function App() {
return (
<Calculator
mode="embedded"
title="Custom Calculator"
styleOverrides={{
paper: { borderRadius: 2, boxShadow: 3 },
button: { borderRadius: 1 },
buttonByKey: {
'=': { bgcolor: 'success.main', '&:hover': { bgcolor: 'success.dark' } },
'C': { bgcolor: 'error.main', '&:hover': { bgcolor: 'error.dark' } }
},
display: { fontSize: '1.2rem' }
}}
/>
);
}
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
mode | 'embedded' | 'modal' | 'floating' | 'embedded' | No | Display mode of the calculator |
title | string | 'Calculator' | No | Title shown in the calculator header |
historyTitle | string | 'Calculation History' | No | Title for the history panel |
initiallyOpen | boolean | false | No | Initial open state (only for modal/floating modes) |
initialValue | string | number | '' | No | Initial value displayed in the calculator |
onChange | (value: string) => void | undefined | No | Callback fired when the display value changes |
onOpen | () => void | undefined | No | Callback fired when calculator opens |
onClose | () => void | undefined | No | Callback fired when calculator closes |
setOpen | (open: boolean) => void | undefined | No | External state setter for open/close (alternative to internal state) |
width | number | 380 | No | Width of the calculator in pixels |
height | number | 500 | No | Height of the calculator in pixels |
styleOverrides | object | {} | No | MUI sx prop overrides for customizing appearance |
The styleOverrides prop allows deep customization of the calculator's appearance. You can pass either:
// Flat style (applies to root Paper)
styleOverrides={{
bgcolor: 'lightblue',
border: '2px solid blue'
}}
// Nested styles
styleOverrides={{
paper: { /* Root Paper styles */ },
titleBar: { /* Title bar Box styles */ },
button: { /* General button styles */ },
buttonByKey: { /* Specific button styles by key */ },
display: { /* TextField display styles */ },
history: { /* History list container styles */ },
historyTitle: { /* History title Typography styles */ },
modal: { /* Modal inner Box styles (modal mode only) */ }
}}
0-9, ., +, -, *, / - Input numbers and operatorsEnter or = - Evaluate expressionBackspace - Delete last characterEscape or C - Clear displayTo test changes locally before publishing:
# In react-calculator directory
npm link
# In your test app directory
npm link @salihoz0/react-calculator
Function() for expression evaluation (basic arithmetic only)0-9, ., +, -, *, / - InputEnter or = - Evaluate expressionBackspace - Delete last characterEscape or C - Clear displayTo test changes locally before publishing:
# In react-calculator directory
npm link
# In your app directory
npm link react-calculator
FAQs
A customizable React calculator component (MUI-based) designed to be published as an npm package.
We found that floating-react-calculator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.