CxJS

ClipRect

import { ClipRect } from 'cx/svg'; Copied

The ClipRect component clips its inner contents to its bounded object area. Any content that extends beyond the clip rectangle will be hidden.

In this example, the ellipse has a negative margin causing it to extend beyond the container, but the ClipRect clips it to a smaller area defined by margin={15}.

<Svg style="width: 200px; height: 200px; border: 1px dashed #ddd">
  <ClipRect margin={15}>
    <Ellipse margin={-10} fill="red" />
  </ClipRect>
</Svg>

Configuration

PropertyTypeDescription
anchorsstring/numberPosition within parent bounds. Format: "t r b l". See Svg for details.
offsetstring/numberTranslate edges in pixels. Format: "t r b l". See Svg for details.
marginstring/numberCSS-like margin. See Svg for details.
paddingstring/numberPadding applied before passing bounds to children.