Responsive
Lays out children in a vertically or horizontally spaced layout based on given breakpoint (default is 720px).
<= $bp
behaves like a Column> $bp
behaves like an Row
You'll have to resize the browser window to see the following examples in action 👍
As an example, resize your browser window to see the following layout change from horizontal to vertical at 600px:
Here is an example with left and right buttons collapsing into two rows at breakpoint:
Another similar example is a common layout in designs is tabular data that collapses:
Another example is form inputs:
Responsive props are categorized into Root, Mode (h/v mode) and Overridable.
RootProps
These are props that impact the root tag generated by the Responsive
.
export interface RootProps extends
DivProps,
BreakpointProp {
}
export interface BreakpointProp {
/**
* windowWidth <= breakpoint : it is vertical (mobile)
* else : it is horizontal (desktop)
**/
$bp?: number;
}
DivProps
is covered in common props.$bp
is simply the breakpoint you've already seen.
ModeProps
ModeProps
consists of v
and h
mode customizations:
export interface ModeProps {
/** Vertical mode configuration */
$v?: VProps;
/** Horizontal mode configuration */
$h?: HProps;
}
The only difference between VProps
and HProps
is alignment
$v
supports the same ($vAlign, $hAlign
) options offered the Column component.$h
supports the same ($vAlign, $hAlign, $reverse
) options offered the Row component.
The rest of the props are the same, and considered "Overridable".
OverridableProps
These props can be specified at the root or as v
/h
options. Some ways you could use these props:
- Only at the root (used for both modes).
- For specfic modes (used only in those mode).
- Combination: root + override-in-specific-mode.
The following props are supported:
SpaceProp
: supports the$space
prop as explained in the space principle.ScaleProp
: supports the$scale
prop as explained in the scale principle.BaseProps
: supports the base props as explained in common types.
As an example, below we have an Responsive
with a default space of 40px
but in v mode it has it changed to 10px
Pseudocode: (<Responsive $space=40 $v={$space:10}/>
):
Reverse
Sometimes you want to reverse the order of components between the V and the H mode. You can do this with H mode's $reverse
property e.g.