ComponentsShape
Rectangle
Draw a rectangular shape with square corners.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { Rectangle } from '@swiftuijs/ui';
export default function Example() {
return (<Rectangle fill="#007AFF" style={{ width: '200px', height: '100px' }}></Rectangle>);
}With Stroke
Add a stroke to the rectangle:
Colors
Display rectangles with different colors:
Usage and limitations
- Set width and height explicitly.
fillis optional;strokeandstrokeWidthadd a border. - Use for backgrounds or visual containers with sufficient contrast; use RoundedRectangle for rounded corners.
More examples
With Stroke
Colors
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
fill | string | No | Fill color |
stroke | string | No | Stroke color |
strokeWidth | number | No | Stroke width |
Inherits additional props from IBaseComponent.