ShadSpacing class

A spacing scale, the Dart counterpart of Tailwind's --spacing.

Every padding and gap in shadcn/ui is a multiple of one variable — p-4, gap-2 and py-1.5 are 4 × 1rem/4, 2 × and 1.5 × that same step. Modelling it the same way is what makes paddings reproducible: a component asks for spacing(6) rather than for 24, so the whole UI keeps its proportions when the step changes, and any layout written against the scale lines up with the components exactly.

final spacing = ShadTheme.of(context).spacing;
Padding(padding: spacing.all(6), child: ...); // 24px with the default step

Prefer ShadGap and ShadPadding over reading the scale by hand — they do the lookup for you.

Annotations

Constructors

ShadSpacing({double step = 4})
Creates a scale whose unit step is step logical pixels.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
lg double
no setter
md double
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sm double
no setter
step double
The size of one step on the scale.
final
xl double
no setter
xs double
Named steps, for the common cases.
no setter

Methods

all(double steps) EdgeInsets
EdgeInsets.all, in steps.
call(double steps) double
steps steps, in logical pixels. spacing(6) is 24 by default.
copyWith({double? step}) ShadSpacing
directional({double start = 0, double top = 0, double end = 0, double bottom = 0}) EdgeInsetsDirectional
EdgeInsetsDirectional.only, in steps.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
only({double left = 0, double top = 0, double right = 0, double bottom = 0}) EdgeInsets
EdgeInsets.only, in steps.
symmetric({double horizontal = 0, double vertical = 0}) EdgeInsets
EdgeInsets.symmetric, in steps.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

lerp(ShadSpacing a, ShadSpacing b, double t) ShadSpacing