> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ploterr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a floor slab

> Put a plate with thickness below your walls.

export const LiveExample = ({path, title = 'Live example', height = 460}) => {
  return <Frame>
      <iframe src={`https://floorkit-examples.ploterr.com/floorkit/${path}?embed=1`} ref={frame => {
    if (!frame || !['localhost', '127.0.0.1'].includes(window.location.hostname)) return;
    const local = `http://localhost:5555/${path}?embed=1`;
    if (frame.src !== local) frame.src = local;
  }} title={title} loading="lazy" allow="fullscreen" style={{
    width: '100%',
    height: `${height}px`,
    border: 0,
    display: 'block'
  }} />
    </Frame>;
};

A slab is a flat plate. You give its outline and its thickness. Use a slab for a floor plate, a terrace or a ceiling.

<LiveExample path="guides/add-a-floor-slab" />

## Before you start

You have a session from [Start a building](/floorkit/guides/start-a-building).

## Write the slab

This slab goes below the room from [Draw a wall](/floorkit/guides/draw-a-wall). The path of a wall is its centre line, and those walls are 0.2 metres thick. Thus the slab outline is 0.1 metres outside the wall path, at the outer face of the walls. The slab is 0.2 metres thick. Its top is at the storey elevation, so its bottom is 0.2 metres below.

```typescript theme={null}
import type { BmSlab, BuildingSession } from '@opengeometry/floorkit';

export const groundFloor: BmSlab = {
  id: 'ground-floor',
  role: 'slab',
  profile: {
    outerRing: [
      [-0.1, -0.1],
      [6.1, -0.1],
      [6.1, 4.1],
      [-0.1, 4.1],
    ],
  },
  thickness: 0.2,
  baseOffset: -0.2,
};
```

## Add it to the storey

A slab is an entry in the `slabs` list of its storey.

```typescript theme={null}
export function addFloorSlab(session: BuildingSession): void {
  session.apply(
    {
      kind: 'add-element',
      buildingId: 'building',
      storeyId: 'ground',
      list: 'slabs',
      element: groundFloor,
    },
    session.revision,
  );
}
```

The `add-element` command adds the slab to the list, and the session builds it. You keep the session and its undo history. The command rejects an id that the list has.

## Rules

* `outerRing` is a list of `[x, z]` points in metres. Do not repeat the first point.
* A wall path is the centre line of the wall. To put the edge of a slab at the outer face of a wall, move the outline half of the wall thickness out from the path.
* `baseOffset` is the distance from the storey elevation to the bottom of the slab.
* `role` can be `'slab'`, `'floor'` or `'ceiling'`. The role names the element. It does not change the shape.
* For a hole, such as a stair opening, add a ring to `profile.holes`.

## Move the slab

A slab that is in the model has a move command:

```typescript theme={null}
export function moveSlab(session: BuildingSession): void {
  session.apply(
    {
      kind: 'transform-slab',
      buildingId: 'building',
      storeyId: 'ground',
      slabId: 'ground-floor',
      origin: [0, 0],
      translation: [1, 0],
      yawDeg: 0,
    },
    session.revision,
  );
}
```

## Next

<CardGroup cols={2}>
  <Card title="Add a roof" icon="house" href="/floorkit/guides/add-a-roof">
    Close the building at the top.
  </Card>

  <Card title="Slab API" icon="code" href="/floorkit/api/architecture/slab">
    See each option of a slab.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.