Stack
Stack layers children on top of each other, mirroring Flutter's Stack widget. It provides precise control over absolute and relative positioning, z-index ordering, and alignment using a declarative API built on CSS positioning.

Tsx

import { Stack } from '@dynshift/layr';

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
1. Basic Usage
1a. Simple Layering
Children are painted in order: first child at the bottom, last child on top.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
1b. With Positioned Children
Use Positioned to control exact placement.

Tsx

import { Stack, Positioned } from '@dynshift/layr';

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
2. Alignment
The alignment prop controls how non-positioned children are aligned within the stack.
2a. Top Left (Default)

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
2b. Center
Center all non-positioned children.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
2c. All Alignment Options
topLeft — Top-left corner (default) • topCenter — Top edge, horizontally centered • topRight — Top-right corner • centerLeft — Left edge, vertically centered • center — Centered both horizontally and vertically • centerRight — Right edge, vertically centered • bottomLeft — Bottom-left corner • bottomCenter — Bottom edge, horizontally centered • bottomRight — Bottom-right corner
3. Stack Fit
The fit prop controls how non-positioned children are sized.
3a. Loose (Default)
Children are allowed to be as large as they want.

Tsx

import { StackFit } from '@dynshift/layr';

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
Available values:
StackFit.loose — Children size themselves (default) • StackFit.expand — Fill all available space • StackFit.passthrough — Minimal size
4. Clip Behavior
Control how overflowing content is handled.
4a. Hard Edge (Default)
Clip without anti-aliasing.

Tsx

import { Clip } from '@dynshift/layr';

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
4b. Anti-Alias
Clip with anti-aliasing for smoother edges.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
4c. None
Do not clip overflowing content.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
Available values:
Clip.hardEdge — Clip without anti-aliasing (default) • Clip.antiAlias — Clip with anti-aliasing • Clip.antiAliasWithSaveLayer — Clip with anti-aliasing and save layer • Clip.none — No clipping
5. Text Direction (RTL Support)
Control alignment behavior for right-to-left languages.
5a. LTR (Default)
Normal left-to-right behavior.

Tsx

import { TextDirection } from '@dynshift/layr';

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
5b. RTL
Right-to-left behavior (mirrors alignment).

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
When textDirection is rtl, topLeft becomes topRight and vice versa.
6. Complete Examples
6a. Badge on Avatar
Notification badge positioned on top-right corner.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
6b. Play Button on Video Thumbnail
Video thumbnail with centered play button.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
6c. Watermark on Image
Semi-transparent watermark on bottom-right.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
6d. Status Indicator on Icon
Online status indicator on avatar.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
6e. Image Comparison
Before/after image.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
6f. Notification Toast
Toast notification on top-right.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
7. Layout Behavior
Stack follows Flutter's layout specification:
• Non-positioned children are positioned according to alignment • Stack sizes itself to contain all non-positioned children • Positioned children are placed relative to stack edges • Children are painted in order (first = bottom, last = top)
Important: Stack children are painted in order. To change z-index, reorder children in the array.
8. Z-Index Ordering
Children are automatically assigned z-index based on their order.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
To change stacking order, reorder the children.
9. Custom Styling
9a. Tailwind Classes

Tsx

<Stack
style={{ width: 200, height: 200 }}
className="bg-gray-100 rounded-lg p-4">
<span>Styled with Tailwind</span>
</Stack>
9b. Inline Styles

Tsx

<Stack
style={{
backgroundColor: '#f3f4f6',
borderRadius: '8px',
padding: '16px'
}}
>
<span>Custom styles</span>
</Stack>
10. TypeScript
Stack is fully typed with comprehensive IntelliSense support.

Tsx

import type { StackProps } from '@dynshift/layr';
import { Stack, StackFit, Clip } from '@dynshift/layr';
const LayeredCard: React.FC<StackProps> = (props) => {
return (
<Stack
alignment="center"
fit={StackFit.loose}
clipBehavior={Clip.hardEdge}
{...props}
/>
);
};
11. API Reference
11a. StackProps
PropTypeDefaultDescription
childrenReactNodeWidgets to stack (first = bottom, last = top)
alignmentStackAlignment'topLeft'How to align non-positioned children
fitStackFitlooseHow to size non-positioned children
textDirectionTextDirectionltrText direction for alignment resolution
clipBehaviorCliphardEdgeHow to clip overflowing content
classNamestring''Additional CSS classes
styleCSSProperties{}Custom inline styles
idstringHTML id attribute
onTap() => voidClick handler (Flutter-style)
onClick() => voidClick handler
11b. StackAlignment Type
ValueDescription
'topLeft'Top-left corner (default)
'topCenter'Top edge, centered horizontally
'topRight'Top-right corner
'centerLeft'Left edge, centered vertically
'center'Centered both horizontally and vertically
'centerRight'Right edge, centered vertically
'bottomLeft'Bottom-left corner
'bottomCenter'Bottom edge, centered horizontally
'bottomRight'Bottom-right corner
11c. StackFit Enum
ValueBehaviorDescription
looseSized by childrenChildren size themselves (default)
expandFill parentFill all available space
passthroughMinimal sizeMinimal size
11d. Clip Enum
ValueBehavior
hardEdgeClip without anti-aliasing (default)
antiAliasClip with anti-aliasing
antiAliasWithSaveLayerClip with anti-aliasing and save layer
noneNo clipping
11e. TextDirection Enum
ValueDescription
ltrLeft-to-right (normal)
rtlRight-to-left (mirrors alignment)
12. Next Steps
• Positioned — Precise positioning within Stack • Positioned Fill — Fill-positioned children