Version: 1.1.0
Grid Layout
Grid Layout is a component that arranges your components in a grid of size 12 and provides powerful features like auto adjustment, width and height spanning, and re-positioning of K2 widgets. It uses react-grid-layout
by STRML as an underlying library and abstracts out its complexity.
Live Editor
Usage
1 . Import GridLayout and Card after installation
2 . Then use in jsx/tsx as shown below:
Examples
2D Layout With Draggable Cards: Demo
1D Layout without using Cards: Demo
Click here for more variations of grid layout.
Props
Property | Type | Required | Default value | Description |
---|---|---|---|---|
noOfCols | number | no | 3 | No of columns in Grid. |
rowHeight | number | no | 8 | Height of a row in pixels. |
rowOffsets | number[] | no | [] | If some child content has custom height, it may disturb the row positioning, you may pass offsets to adjust that. |
isResponsive | boolean | no | true | Make this true to make the grid layout adjust it's layout when the passed width updates. Note that the it automatically updates on window resize regardless of this prop. So this should only be used for other cases due to performance reasons. |
isResizable | boolean | no | true | Enable to make grid resizeable. |
isDraggable | boolean | no | true | Make this true to enable Grid items to be draggable. |
draggableHandle | string | no | None | A CSS selector for tags that will act as the draggable handle. For example: draggableHandle:'.MyDragHandleClassName' . If you forget the leading . it will not work. |
gridGap | [number,number] | no | [10, 10] | X and Y margin of grid items. |
width | string | number | no | 100% | Width of grid container. |
style | CSSProperties | no | {} | Styles applied to the root element of grid. |
className | string | no | {} | Class applied to the root element of grid. |
Please see Class Specificity for correctly defining it.