2018-02-13 03:50:31 -08:00
---
path: "docs/width-height"
title: "Width and Height"
hasPlayground: true
---
2018-02-14 07:53:07 -08:00
## Width and Height
2018-02-15 06:12:12 -08:00
The `width` property in flexbox specifies the width of the element's content area. Similarly `height` property specifies the height of the element's content area.
2018-02-14 07:53:07 -08:00
2018-02-15 06:12:12 -08:00
Both `width` and `height` can take following values
### Auto
It is the default Value, Yoga calculates the width/height for the element
### Pixels
Defines the width/height in px
### Percentage
Defines the width or height in percentage of its parents width or height respectively
Lets start to play with playground. For starter, lets try fiddling with `width` :
1. Click on the root view and set `width = auto` , you would see that it would shrink to fit its children.
2. Lets try giving pixel value. Click on any child view, and change its width(say 300), you would now see child view's width is updated
3. Say you want to make your child view half of root view's width. Type 50% in your view's width field, and voila, your view is 50% of its parent.
You can do similar things with `height` too. Keep fiddling 😉
### Width
2018-02-14 07:53:07 -08:00
< controls prop = "width" > < / controls >
2018-02-15 06:12:12 -08:00
### Height
2018-02-14 07:53:07 -08:00
< controls prop = "height" > < / controls >
2018-02-15 06:12:12 -08:00