# LayoutChildComponent

Class · extends [`Component`](https://api.playcanvas.com/engine/classes/Component.md) · category: User Interface

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/framework/components/layout-child/component.js#L35

The LayoutChildComponent enables an [Entity](https://api.playcanvas.com/engine/classes/Entity.md) to control the sizing and fitting behavior
applied to it by its parent [LayoutGroupComponent](https://api.playcanvas.com/engine/classes/LayoutGroupComponent.md). It allows per-child overrides of
minimum and maximum dimensions as well as fit proportions.

You should never need to use the LayoutChildComponent constructor directly. To add a
LayoutChildComponent to an [Entity](https://api.playcanvas.com/engine/classes/Entity.md), use [Entity#addComponent](https://api.playcanvas.com/engine/classes/Entity.md#addcomponent):

```javascript
const entity = new Entity();
entity.addComponent('element', {
    type: ELEMENTTYPE_IMAGE
});
entity.addComponent('layoutchild', {
    minWidth: 50,
    maxWidth: 200,
    fitWidthProportion: 1
});
```

Once the LayoutChildComponent is added to the entity, you can access it via the
[Entity#layoutchild](https://api.playcanvas.com/engine/classes/Entity.md#layoutchild) property:

```javascript
entity.layoutchild.minWidth = 80; // Increase the minimum width

console.log(entity.layoutchild.minWidth); // Get the minimum width and print it
```

## Accessors

### excludeFromLayout

```ts
get excludeFromLayout(): boolean
set excludeFromLayout(value: boolean)
```

Gets whether the child will be excluded from all layout calculations.

### fitHeightProportion

```ts
get fitHeightProportion(): number
set fitHeightProportion(value: number)
```

Gets the amount of additional vertical space that the element should take up, if necessary to
satisfy a Stretch/Shrink fitting calculation.

### fitWidthProportion

```ts
get fitWidthProportion(): number
set fitWidthProportion(value: number)
```

Gets the amount of additional horizontal space that the element should take up, if necessary to
satisfy a Stretch/Shrink fitting calculation.

### maxHeight

```ts
get maxHeight(): number | null
set maxHeight(value: number | null)
```

Gets the maximum height the element should be rendered at.

### maxWidth

```ts
get maxWidth(): number | null
set maxWidth(value: number | null)
```

Gets the maximum width the element should be rendered at.

### minHeight

```ts
get minHeight(): number
set minHeight(value: number)
```

Gets the minimum height the element should be rendered at.

### minWidth

```ts
get minWidth(): number
set minWidth(value: number)
```

Gets the minimum width the element should be rendered at.

## Inherited from [Component](https://api.playcanvas.com/engine/classes/Component.md)

- `entity: Entity`
- `system: ComponentSystem`
- `get enabled(): boolean` · `set enabled(value: boolean)`
- `fire(name: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, arg6?: any, arg7?: any, arg8?: any): EventHandler`
- `hasEvent(name: string): boolean`
- `off(name?: string, callback?: HandleEventCallback, scope?: any): EventHandler`
- `on(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
- `once(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
