Documentation

Report Edit

Rectangle

import {Rectangle} from 'cx/svg';

Rectangle is a Cx version of SVG rect object which can be used in responsive scenarios.

Rectangles
<Svg style="width:400px;height:400px;background:white" padding={5}>
   <Rectangle anchors="0 .25 .25 0" margin={5} colorIndex={0} rx={5} />
   <Rectangle anchors="0 .5 .25 .25" margin={5} colorIndex={1} ry="5%" />
   <Rectangle anchors="0 .75 .25 .5" margin={5} colorIndex={2} rx="9px" ry="25" />
   <Rectangle anchors="0 1 .25 .75" margin={5} colorIndex={3} rx="3em"/>

   <Rectangle anchors=".25 .25 .5 0" margin={5} colorIndex={7} />
   <Rectangle anchors=".25 .5 .5 .25" margin={5} colorIndex={6} />
   <Rectangle anchors=".25 .75 .5 .5" margin={5} colorIndex={5} />
   <Rectangle anchors=".25 1 .5 .75" margin={5} colorIndex={4} />

   <Rectangle anchors=".5 .25 .75 0" margin={5} colorIndex={8} />
   <Rectangle anchors=".5 .5 .75 .25" margin={5} colorIndex={9} />
   <Rectangle anchors=".5 .75 .75 .5" margin={5} colorIndex={10} />
   <Rectangle anchors=".5 1 .75 .75" margin={5} colorIndex={11} />

   <Rectangle anchors=".75 .25 1 0" margin={5} colorIndex={15} />
   <Rectangle anchors=".75 .5 1 .25" margin={5} colorIndex={14} />
   <Rectangle anchors=".75 .75 1 .5" margin={5} colorIndex={13} />
   <Rectangle anchors=".75 1 1 .75" margin={5} colorIndex={12} />
</Svg>
Copied!Cx Fiddle
PropertyDescriptionType
fill

A color used to paint the box.

string
rx

The horizontal corner radius of the rect. Defaults to ry if ry is specified.

string/number
ry

The vertical corner radius of the rect. Defaults to rx if rx is specified.

string/number
stroke

A color used to paint the outline of the box.

string
anchors

Anchor defines how child bounds are tied to the parent. Zero aligns with the top/left edge. One aligns with the bottom/right edge. See Svg for more information.

string/number/rect
class
className

Additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list.

string/object
colorIndex

Index of the color in the default color palette. Setting this property will set both fill and stroke on the object. Use style or CSS class to remove stroke or fill if they are not necessary.

number
items
children

List of child elements.

array
margin

Apply margin to the given boundaries. See Svg for more information.

string/number/rect
mod

Appearance modifier. For example, mod="big" will add the CSS class .cxm-big to the block element.

string/array
offset

Move boundaries specified by the offset. See Svg for more information.

string/number/rect
outerLayout

Defines the outer layout which wraps the widget.

widget
padding

Padding to be applied to the boundaries rectangle before passing to the children.

string/number/rect
plainText

Set to true to avoid converting inner strings to templates. Default is false.

boolean
preserveWhitespace
ws

Keep whitespace in text based children. Default is false. See also trimWhitespace.

boolean
putInto
contentFor

Used with outer layouts. Specifies the name of the content placeholder which should render the widget.

string
style

Style object applied to the wrapper div. Used for setting the dimensions of the element.

string/object
trimWhitespace

Remove all whitespace in text based children. Default is true. See also preserveWhitespace.

boolean
vdomKey

Key that will be used as the key when rendering the React component.

string
visible
if

Visibility of the widget. Defaults to true.

boolean