squircler
v2.0.0
Published
� The MOST PERFECT React squircle component ever created. Zero ovals, infinite possibilities.
Maintainers
Readme
� Squircler
The MOST PERFECT React squircle component ever created. Zero ovals, infinite possibilities.
🔥 Revolutionary v2.0 - The Oval Problem is SOLVED!
Squircler v2.0 brings mathematically perfect squircles that maintain their shape across ANY dimension, ANY aspect ratio, ANY responsive behavior. We've completely eliminated the oval distortion problem that plagued every previous squircle implementation.
🎯 What Makes v2.0 Special
- ⚡ ZERO OVALS EVER: Revolutionary coordinate system prevents ANY oval distortion
- 🎮 Interactive Global Controls: Real-time sliders control all squircles simultaneously
- 📱 Perfect Responsive Behavior: Maintains mathematical precision during resize
- 🔬 ResizeObserver Integration: Tracks actual DOM dimensions in real-time
- 🎨 120+ Live Examples: Every possible use case demonstrated
- 💎 True Mathematical Borders: Borders that follow exact squircle curves
- 🚀 Extreme Aspect Ratios: Perfect curves from 50×250 to 500×40 dimensions
🚀 What is Squircler?
Squircler delivers authentic Apple-style squircles with mathematical perfection. Unlike CSS border-radius approximations, Squircler uses real Bézier curve mathematics to create true superellipse shapes with precision tension control.
✨ Revolutionary Features
- 🎯 TRUE mathematical squircles - real superellipse formulas, not CSS hacks
- ⚡ Tension control (0.05-2.0) - from sharp squircles to super-circular shapes
- 🔄 Perfect responsiveness - maintains curves during any resize operation
- � Extreme aspect ratios - works flawlessly from ultra-wide to ultra-tall
- 🎨 Mathematical borders - borders follow the exact squircle path
- 💎 Glass effects ready - backdrop-filter and modern UI compatible
- 📱 Container adaptive - works with CSS Grid, Flexbox, percentage widths
- 🔷 TypeScript native - complete type safety and IntelliSense
- ⚡ Lightweight - <8KB gzipped with all features
- 🎮 Interactive demo - real-time playground to perfect your settings
📦 Installation
npm install squircleryarn add squirclerpnpm add squircler🏃♂️ Quick Start
import { Squircle } from 'squircler';
function App() {
return (
<Squircle
borderRadius={25}
tension={0.6}
width={120}
height={40}
style={{
background: 'linear-gradient(135deg, #667eea, #764ba2)',
color: 'white',
padding: '12px 24px',
border: 'none',
cursor: 'pointer',
fontWeight: '600'
}}
>
Perfect Button!
</Squircle>
);
}Result: A mathematically perfect squircle button that maintains its curves at any size! 🎯
🎮 Interactive Demo & Playground
Want to see the magic in action? Check out our interactive demo with global controls:
// Every squircle on the page responds to these state variables!
const [borderRadius, setBorderRadius] = useState(25);
const [tension, setTension] = useState(0.6);
// All your squircles will update simultaneously
<Squircle borderRadius={borderRadius} tension={tension} width={100} height={100} />
<Squircle borderRadius={borderRadius} tension={tension} width={200} height={80} />
<Squircle borderRadius={borderRadius} tension={tension} stretch={true} />🎛️ Try it yourself: Live Interactive Demo
📐 Core Props & API
Essential Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| borderRadius | number | 25 | Corner roundness percentage (5-50) |
| tension | number | 0.6 | Curve tension (0.05-2.0) |
| width | number | - | Fixed width in pixels |
| height | number | - | Fixed height in pixels |
| stretch | boolean | false | Makes squircle responsive to container |
Advanced Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| squircleBorder | number | - | Mathematical border width |
| squircleBorderColor | string | #000 | Mathematical border color |
| as | string | 'div' | HTML element type |
| style | CSSProperties | - | Standard CSS styles |
| className | string | - | CSS class name |
🎯 Understanding Tension Values
The tension prop controls the mathematical curve characteristics:
| Range | Effect | Best For | |-------|--------|----------| | 0.05 - 0.3 | 🟦 True Squircles | App icons, Apple-style UI | | 0.4 - 0.7 | 🔷 Soft Curves | Modern buttons, cards | | 0.8 - 0.95 | ⭕ Nearly Circular | Profile avatars, badges | | 1.0 | ⭕ Perfect Circle | Exact mathematical circles | | 1.1 - 2.0 | 🔵 Super Circular | Unique modern effects |
💎 Perfect Use Cases
📱 App Icons
<Squircle
width={80}
height={80}
borderRadius={22}
tension={0.6}
style={{ background: 'linear-gradient(45deg, #667eea, #764ba2)' }}
>
📧
</Squircle>🔘 Modern Buttons
<Squircle
width={140}
height={50}
borderRadius={25}
tension={0.5}
style={{
background: 'linear-gradient(45deg, #ff6b6b, #ee5a24)',
color: 'white',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
cursor: 'pointer'
}}
>
Call to Action
</Squircle>📄 Responsive Cards
<Squircle
stretch={true}
borderRadius={20}
tension={0.4}
style={{
background: 'white',
padding: '1.5rem',
boxShadow: '0 4px 6px rgba(0,0,0,0.1)'
}}
>
<h3>Perfect Card</h3>
<p>This card maintains perfect squircle curves as it resizes!</p>
</Squircle>🎨 Mathematical Borders
<Squircle
width={120}
height={120}
borderRadius={25}
tension={0.6}
squircleBorder={4}
squircleBorderColor="#007bff"
style={{ background: 'linear-gradient(45deg, #74b9ff, #0984e3)' }}
>
Perfect Border!
</Squircle>📱 Responsive Behavior
Fixed Size Mode (Default)
<Squircle width={200} height={100} borderRadius={25} tension={0.6} />- ✅ Exact pixel dimensions
- ✅ Perfect for buttons, icons, badges
- ✅ Maintains aspect ratio always
Stretch Mode (Responsive)
<Squircle stretch={true} borderRadius={25} tension={0.6} />- ✅ Adapts to container size
- ✅ Perfect for cards, containers, layouts
- ✅ Works with CSS Grid, Flexbox, percentages
- ✅ NO OVAL DISTORTION EVER
⚠️ What You CAN and CANNOT Do
✅ WHAT YOU CAN DO
- Perfect Curves: Create mathematically accurate squircles at any size
- Extreme Aspect Ratios: Use ratios from 1:10 to 10:1 with perfect curves
- Responsive Design: Stretch squircles that adapt to any container size
- Real-time Control: Change borderRadius and tension dynamically
- Mathematical Borders: Add borders that follow the exact squircle path
- Any Content: Put any HTML/React content inside squircles
- Modern Styling: Use gradients, shadows, backdrop-filter, transforms
- Accessibility: All standard accessibility props work normally
❌ WHAT YOU CANNOT DO
- CSS Border Override: Cannot use CSS
border- usesquircleBorderinstead - Border-radius Override: CSS
border-radiusis ignored (useborderRadiusprop) - Clip-path Override: Cannot override the SVG clip-path manually
- Nested Squircle Clipping: Nested squircles won't clip each other
- Transform Origins: Some complex transform-origin behaviors may not work as expected
🎯 BEST PRACTICES
// ✅ DO: Use squircleBorder for borders
<Squircle squircleBorder={2} squircleBorderColor="#blue" />
// ❌ DON'T: Use CSS border
<Squircle style={{ border: '2px solid blue' }} />
// ✅ DO: Use stretch for responsive layouts
<Squircle stretch={true} style={{ width: '100%' }} />
// ✅ DO: Use fixed dimensions for precise components
<Squircle width={40} height={40} /> // Perfect for icons
// ✅ DO: Combine with modern CSS
<Squircle style={{
background: 'rgba(255,255,255,0.1)',
backdropFilter: 'blur(10px)'
}} />🔬 Technical Deep Dive
Mathematical Foundation
Squircler uses true superellipse mathematics with Bézier curve approximation:
- Superellipse Formula:
|x/a|^n + |y/b|^n = 1 - Tension Mapping:
n = tension × mathematical_scaling - Bézier Approximation: 8-point curve construction for perfect rendering
- Real-time Calculation: ResizeObserver integration for pixel-perfect responsiveness
Revolutionary Coordinate System
- userSpaceOnUse: All coordinates in pixel space for mathematical precision
- ResizeObserver: Tracks actual DOM dimensions in real-time
- Dual Mode Support: Unified system for fixed and responsive squircles
- Zero Oval Distortion: Completely eliminated through coordinate unification
🛠️ Advanced Examples
Dynamic Tension Control
function TensionDemo() {
const [tension, setTension] = useState(0.6);
return (
<>
<input
type="range"
min="0.05"
max="2"
step="0.05"
value={tension}
onChange={(e) => setTension(Number(e.target.value))}
/>
<Squircle
width={100}
height={100}
borderRadius={25}
tension={tension}
style={{ background: '#667eea' }}
>
T: {tension}
</Squircle>
</>
);
}Responsive Grid System
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))', gap: '1rem' }}>
<Squircle stretch={true} borderRadius={20} tension={0.4} style={{ padding: '1.5rem' }}>
<h4>Card One</h4>
<p>Perfect responsive squircle that adapts to grid changes!</p>
</Squircle>
<Squircle stretch={true} borderRadius={20} tension={0.4} style={{ padding: '1.5rem' }}>
<h4>Card Two</h4>
<p>Maintains mathematical precision during any resize!</p>
</Squircle>
</div>Complex Nested Layouts
<Squircle
stretch={true}
borderRadius={15}
tension={0.6}
style={{ padding: '2rem', background: 'linear-gradient(135deg, #667eea, #764ba2)' }}
>
<div style={{ display: 'flex', gap: '1rem' }}>
<Squircle width={60} height={60} borderRadius={30} tension={1.0} style={{ background: 'white' }}>
👤
</Squircle>
<div>
<h3 style={{ color: 'white', margin: 0 }}>Perfect Layout</h3>
<p style={{ color: 'rgba(255,255,255,0.8)', margin: 0 }}>
Nested content with perfect mathematical curves!
</p>
</div>
</div>
</Squircle>🎯 Migration from v1.x
Great news: v2.0 is 100% backward compatible! Your existing code will work immediately with perfect results.
// v1.x code works perfectly in v2.0
<Squircle width={100} height={100} borderRadius={25} tension={0.6} />
// Enhanced v2.0 features
<Squircle
stretch={true} // New responsive mode
borderRadius={25}
tension={0.6}
squircleBorder={3} // New mathematical borders
squircleBorderColor="#blue"
/>⚡ Performance
- Lightweight: <8KB gzipped (including all features)
- Optimized SVG: Efficient clip-path generation
- ResizeObserver: Only recalculates when dimensions actually change
- No Re-renders: Stable clip-path IDs prevent unnecessary updates
- Memory Efficient: Minimal DOM overhead
🔧 TypeScript Support
Full TypeScript support with complete IntelliSense:
import { Squircle, SquircleProps } from 'squircler';
interface CustomSquircleProps extends SquircleProps {
variant?: 'primary' | 'secondary';
}
const CustomSquircle: React.FC<CustomSquircleProps> = ({ variant, ...props }) => {
return (
<Squircle
{...props}
borderRadius={variant === 'primary' ? 25 : 15}
tension={variant === 'primary' ? 0.6 : 0.4}
/>
);
};📚 Resources
- 🎮 Interactive Demo - Try all features live
- 📖 API Documentation - Complete reference
- 🔬 Mathematical Background - Superellipse theory
- 🎨 Design Examples - Real-world usage
- 🐛 Issues & Support - Get help
🤝 Contributing
We welcome contributions! Please see our Contributing Guide.
📄 License
MIT © CodeSwan.org
🌟 Why Choose Squircler?
- ✅ Mathematical Accuracy: Real superellipse mathematics, not CSS approximations
- ✅ Zero Ovals: Revolutionary coordinate system eliminates distortion forever
- ✅ Perfect Responsiveness: Maintains curves during any resize operation
- ✅ Production Ready: Used in modern applications with millions of users
- ✅ Developer Experience: TypeScript native, comprehensive documentation
- ✅ Future Proof: Built for modern React with latest web standards
Join thousands of developers creating perfectly curved interfaces! 🎯✨
## 🆕 NEW: Mathematical Borders
Create borders that follow the exact squircle curves - not clipped CSS borders!
```tsx
<Squircle
borderRadius={30}
tension={0.3}
squircleBorder={4}
squircleBorderColor="#007AFF"
style={{
background: 'white',
padding: '20px'
}}
>
Perfect mathematical border!
</Squircle>🎮 Interactive Demo
Experiment with border radius and tension values to see real-time squircle generation!
🛠️ API Reference
Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| borderRadius | number | 25 | Corner radius as percentage (0-50%) |
| tension | number | 0.5 | Curve tension (0-1): 0=squircle, 1=circular |
| width | number \| string | 200 | Width in pixels or CSS value |
| height | number \| string | 200 | Height in pixels or CSS value |
| squircleBorder | number | - | NEW: Mathematical border width following squircle curves |
| squircleBorderColor | string | '#000000' | NEW: Color of the mathematical squircle border |
| as | keyof JSX.IntrinsicElements | 'div' | HTML element to render |
| stretch | boolean | false | Fill parent container |
| className | string | '' | CSS class name |
| style | CSSProperties | {} | Inline styles |
| children | ReactNode | - | Content to render inside |
Tension Values Guide
- 0-0.2: Pronounced squircle effect (flatter curves)
- 0.2-0.5: Balanced squircle-to-round transition
- 0.5-0.8: Subtle squircle with rounded feel
- 0.8-1.0: Nearly circular (smooth curves)
🆕 Mathematical Borders
Unlike CSS borders that get clipped by the squircle shape, squircleBorder creates true mathematical borders that follow the exact curve of the squircle. Perfect for:
- Outlined buttons and cards
- Form elements with precise styling
- Design systems requiring mathematical precision
🎨 Examples
Modern Button
<Squircle
borderRadius={30}
tension={0.25}
as="button"
style={{
background: '#007AFF',
color: 'white',
padding: '12px 24px',
border: 'none',
fontWeight: '600'
}}
>
Get Started
</Squircle>🆕 Mathematical Border Button
<Squircle
borderRadius={25}
tension={0.3}
squircleBorder={2}
squircleBorderColor="#007AFF"
as="button"
style={{
background: 'transparent',
color: '#007AFF',
padding: '12px 24px',
border: 'none',
fontWeight: '600'
}}
>
Outlined Button
</Squircle>Glass Card
<Squircle
borderRadius={35}
tension={0.4}
style={{
background: 'rgba(255, 255, 255, 0.1)',
backdropFilter: 'blur(20px)',
border: '1px solid rgba(255, 255, 255, 0.2)',
padding: '24px'
}}
>
<h3>Glass Effect Card</h3>
<p>Perfect backdrop-filter support</p>
</Squircle>🆕 Glass Card with Mathematical Border
<Squircle
borderRadius={35}
tension={0.4}
squircleBorder={1}
squircleBorderColor="rgba(255, 255, 255, 0.3)"
style={{
background: 'rgba(255, 255, 255, 0.1)',
backdropFilter: 'blur(20px)',
padding: '24px'
}}
>
<h3>Perfect Glass Border</h3>
<p>Mathematical border follows the exact curve</p>
</Squircle>Avatar Container
<Squircle
borderRadius={45}
tension={0.2}
width={80}
height={80}
style={{
background: 'linear-gradient(135deg, #FF6B6B, #4ECDC4)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'white',
fontSize: '24px',
fontWeight: 'bold'
}}
>
JT
</Squircle>Progress Bar
<Squircle
borderRadius={50}
tension={1.0}
width={200}
height={8}
style={{ background: '#E5E5E5', overflow: 'hidden' }}
>
<div style={{
width: '70%',
height: '100%',
background: 'linear-gradient(90deg, #00C851, #007E33)'
}} />
</Squircle>🔬 How It Works
Squircler generates mathematical Bézier curves using the superellipse formula principles:
- Border Radius controls the corner size (0-50% of smallest dimension)
- Tension adjusts control point distances:
- Low tension = tighter control points = flatter curves (squircle)
- High tension = standard control points = rounder curves (circular)
- SVG clip-path applies the mathematical shape to any content
This creates authentic squircles that match Apple's design language perfectly.
🎯 Use Cases
- 🔘 Buttons - Premium feel over standard rectangles
- 🎴 Cards - Modern card designs with authentic curves
- 👤 Avatars - Unique profile image containers
- 📊 Data visualization - Progress bars, charts, indicators
- 🖼️ Image containers - Photo galleries, thumbnails
- 🌟 Glass effects - Backdrop-filter compatible shapes
- 📱 Mobile UI - iOS-style interface elements
⚡ Performance
- Lightweight: <7KB gzipped
- Efficient: Uses CSS clip-path for hardware acceleration
- Scalable: Vector-based shapes scale perfectly with responsive design
- Memory friendly: Minimal DOM overhead
🆕 What's New in v1.1.0
- 🎨 True Mathematical Borders:
squircleBorderandsquircleBorderColorprops create borders that follow exact squircle curves - 📏 Perfect Responsive Scaling: Squircles now automatically adapt to any container size with mathematical precision
- 🔧 Enhanced Performance: Optimized SVG implementation using normalized coordinates
- 🐛 Bug Fixes: Resolved clipping issues and border rendering problems
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
📄 License
MIT © Silver J. Teichman - CODESWAN brand of lepigeon
🔗 Links
Built with ❤️ by CODESWAN
Bringing mathematical precision to web design
