# 1. sds-grid()

### Structure

Much like the CSS Flexbox, CSS Grid is not applied directly to the elements you wish to position. Instead, Grid and most of its complementary CSS properties are declared on the "parent" of the elements to be affected. The following example illustrates this.

```markup
<div class="parent">
  <div class="column"></div>
  <div class="column"></div>
  <div class="column"></div>
  <div class="column"></div>
</div>
```

```scss
// Correct grid application

.parent {
  display: grid;
}


// Incorrect

.parent {
  .column{
    display: grid;
  }
}
```

### Implementation

This mixin is one of the most commonly used because it offers developers an easy and automatic way of implementing {`n`} number of columns while also controlling the space between them.&#x20;

```css
@include sds-grid($columns, $gap);
```

This mixin accepts two parameters: `$columns` and `$gap`. The `$columns` parameter is required, and should be a number that expresses the amount of columns desired in the grid (it's important to reference). The `$gap` parameter is optional, and its default value is set to 0. This parameter accepts a number value that should be specified in measurable units such a pixels, percentages, rem, etc.

Basic implementation of `sds-grid` :

<pre class="language-scss"><code class="lang-scss">.parent {
<strong>  @include sds-grid(4);
</strong>  
  .column {
    border: 1px solid sds-color(red, 80);
  }
}
</code></pre>

![](/files/-MdcDPyG5ETzK5ioBaQx)

Providing a value for the `$gap` parameter will control the space between columns:

<pre class="language-scss"><code class="lang-scss">.parent {
<strong>  @include sds-grid(4, 8px);
</strong>  
  .column {
    border: 1px solid sds-color(red, 80);
  }
}
</code></pre>

![](/files/-MdcDh_r_zlywmT9aNGA)

{% hint style="warning" %}
When specifying a value for the `$gap` parameter, it is strongly recommended to use [Sipster's `sds-spc()` function](/sds/sds-3.0/sds-core/layout-system/spacing.md#development-scss-spacing-function) for most instances. The following example illustrates this method.
{% endhint %}

```scss
.parent {
  @include sds-grid(4, sds-spc(8));
}
```

which compiles to:

```css
.parent {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 0.5rem;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://2600hz.gitbook.io/sds/sds-3.0/sds-core/layout-system/css-grid/sds-grid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
