Layout
Layout is a flexible grid system component that allows you to organize content in a customizable grid format with configurable columns and spacing.
| Type | Resource |
|---|---|
| Design | Figma |
| Mobile | Mobile Storybook |
| Code | Gitlab |

Usage
import id.co.biofarma.binduiandroid.components.layout.LayoutLayout(
id = "basic-grid",
items = (1..4).toList(),
columns = 2
) { item ->
Box(
modifier = Modifier
.aspectRatio(1f)
.background(PrimitiveColors.InnovationBlue_200),
contentAlignment = Alignment.Center
) {
Text(
text = item.toString(),
color = PrimitiveColors.White
)
}
}Examples
Columns (optional)
Use columns to determine the number of columns in the grid (maximum 4).

Spacing (optional)
Use horizontalSpacing and verticalSpacing to adjust the gap between grid items.

Props
| Props | Required | Default | Type | Description |
|---|---|---|---|---|
| id | false | "" | String | A unique identifier for the layout |
| items | true | - | List<T> | List of items to be displayed in the grid |
| columns | false | 3 | Int | Number of columns in the grid (max 4) |
| horizontalSpacing | false | 8 | Int | Horizontal space between grid items (in dp) |
| verticalSpacing | false | 8 | Int | Vertical space between grid items (in dp) |
| modifier | false | Modifier | Modifier | Modifier for the grid container |
| itemContent | true | - | @Composable (T) -> Unit | Composable function for item display |
Notes
-
Implementation Details
- Built using
LazyVerticalGridfor efficient rendering and recycling of items - Automatically fills the maximum available size with
fillMaxSize() - Includes a
testTagwith the provided ID for UI testing purposes
- Built using
-
Column Limitations
- Maximum number of columns is capped at 4 using
columns.coerceAtMost(4) - If you specify more than 4 columns, it will automatically be adjusted to 4
- Maximum number of columns is capped at 4 using
-
Spacing
- Spacing values are in density-independent pixels (dp)
- Uses
Arrangement.spacedBy()for consistent spacing between items - Horizontal and vertical spacing can be set independently
-
Generic Type Support
- The component is generic (
<T>) and can work with any type of data - The
itemContentlambda allows for custom rendering of each item
- The component is generic (
-
Best Practices
- Provide a meaningful ID when using the component for testing purposes
- Consider screen size when choosing the number of columns
- Use consistent spacing values throughout your application
- Implement proper accessibility features in the itemContent