Skip to content

Auto width docs #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,33 @@ $menu = (new CliMenuBuilder)
->build();
```

If you want to use the full width of the terminal, you can grab the terminal object and ask/set it from there like so:

```php
<?php

use PhpSchool\CliMenu\Builder\CliMenuBuilder;

$menu = ($builder = new CliMenuBuilder)
->setWidth($builder->getTerminal()->getWidth())
->build();
```

If you want to use the full width of the terminal and apply a margin you will need to perform a little calculation yourself
since we use a box model like the `box-sizing: border-box;` in CSS. The example below will use the full width of the terminal plus a margin of 2 on the
left and right sides:

```php
<?php

use PhpSchool\CliMenu\Builder\CliMenuBuilder;

$menu = ($builder = new CliMenuBuilder)
->setWidth($builder->getTerminal()->getWidth() - 2 * 2)
->setMargin(2)
->build();
```

#### Padding

The padding can be set for all sides with one value or can be set individually for top/bottom and left/right.
Expand Down