Skip to content

Top / Right / Bottom / Left

Use inset utilities like top-0, -left-4, and inset-s-0 to offset absolutely-positioned children from the edges of their relative parent. Logical-direction utilities (inset-s-*, inset-e-*) resolve against the ambient Flutter Directionality. Percentage forms (1/2, full) resolve against the parent Stack’s constraints.

Style('relative ...', child: Style('absolute top-0 left-0 size-16 ...', child: Text('01')))
Style('relative ...', child: Style('absolute inset-x-0 top-0 h-16 ...', child: Text('02')))
Style('relative ...', child: Style('absolute top-0 right-0 size-16 ...', child: Text('03')))
Style('relative ...', child: Style('absolute inset-y-0 left-0 w-16 ...', child: Text('04')))
Style('relative ...', child: Style('absolute inset-0 ...', child: Text('05')))
Style('relative ...', child: Style('absolute inset-y-0 right-0 w-16 ...', child: Text('06')))
Style('relative ...', child: Style('absolute bottom-0 left-0 size-16 ...', child: Text('07')))
Style('relative ...', child: Style('absolute inset-x-0 bottom-0 h-16 ...', child: Text('08')))
Style('relative ...', child: Style('absolute right-0 bottom-0 size-16 ...', child: Text('09')))
Style('relative ...', child: Style('absolute -top-4 -left-4 ...'))
class InsetLogicalExample extends StatelessWidget {
const InsetLogicalExample({super.key});
@override
Widget build(BuildContext context) {
return Style(
'grid grid-cols-2 place-items-center gap-x-4',
children: [
Style(
'flex flex-col items-start gap-y-4',
children: [
const Style('text-sm font-medium', child: Text('Left-to-right')),
Directionality(
textDirection: TextDirection.ltr,
child: Style(
'relative size-18 rounded-lg sm:size-32',
children: [
Style(
'absolute inset-0',
child: Stripes('h-full rounded-lg', border: true),
),
const Style(
'absolute top-0 left-0 flex size-14 items-center'
' justify-center rounded-lg bg-purple-500 p-4',
child: SizedBox.shrink(),
),
],
),
),
],
),
Style(
'flex flex-col items-end gap-y-4',
children: [
const Style('text-sm font-medium', child: Text('Right-to-left')),
Directionality(
textDirection: TextDirection.rtl,
child: Style(
'relative size-18 rounded-lg sm:size-32',
children: [
Style(
'absolute inset-0',
child: Stripes('h-full rounded-lg', border: true),
),
const Style(
'absolute top-0 right-0 flex size-14 items-center'
' justify-center rounded-lg bg-purple-500 p-4',
child: SizedBox.shrink(),
),
],
),
),
],
),
],
);
}
}
class InsetLogicalPage extends StatelessWidget {
const InsetLogicalPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(body: const InsetLogicalExample());
}
}
FamilyFlutterNotes
inset-*all 4 sidestop + right + bottom + left
inset-x-*horizontalleft + right
inset-y-*verticaltop + bottom
inset-s-*logical startLTR → left, RTL → right
inset-e-*logical endLTR → right, RTL → left
inset-bs-*block startalias to top (horizontal writing mode only)
inset-be-*block endalias to bottom (horizontal writing mode only)
top-* right-* bottom-* left-*per-sidedirect
<class>-<num>spacing scaletop-4 → 16 px
-<class>negative-top-4 → -16 px; Stack uses Clip.none, overflow visible
<class>-<n>/<m>fraction of parenttop-1/2 → 50% of parent height
<class>-full100%resolved against parent size
<class>-autounconstrainedsame effect as omitting the class; useful to override earlier utility
<class>-px1 px
<class>-[<N>]arbitrary pixelsnumeric only, no CSS units
  • Non-horizontal writing modes — inset-bs / inset-be alias to top / bottom; Flutter has no vertical writing mode.

The CSS custom property form (top-(--foo)) is resolved against theme-defined StyleThemeData.customProperties — e.g. top-(--foo) behaves like top-[20px] when the theme defines --foo: '20px'. Cascade-inherited or JS-set CSS variables remain out of scope.