2018-08-04 03:28:27 +01:00
# Tab Stops
> Tab stops are useful, if you are unclear of what they are, [here is a link explaining](https://en.wikipedia.org/wiki/Tab_stop). It enables side by side text which is nicely laid out without the need for tables, or constantly pressing space bar.
2019-09-30 22:56:21 +01:00
!> **Note** : The unit of measurement for a tab stop is in [DXA ](https://stackoverflow.com/questions/14360183/default-wordml-unit-measurement-pixel-or-point-or-inches )
2018-08-04 03:28:27 +01:00

Simply call the relevant methods on the paragraph listed below. Then just add a `tab()` method call to a text object. Adding multiple `tabStops` will mean you would have to chain `tab()` until the desired `tabStop` is selected. Example is shown below.
## Example
2019-08-06 17:51:13 +01:00
```ts
2019-09-30 22:56:21 +01:00
const paragraph = new Paragraph({
2019-11-21 01:02:46 +00:00
children: [new TextRun("Hey everyone").bold(), new TextRun(\t"11th November 1999")],
2019-10-09 20:56:31 +01:00
tabStops: [
{
type: TabStopType.RIGHT,
2019-09-30 22:56:21 +01:00
position: TabStopPosition.MAX,
},
2019-10-09 20:56:31 +01:00
],
2019-09-30 22:56:21 +01:00
});
2018-08-04 03:28:27 +01:00
```
2019-09-30 22:56:21 +01:00
The example above will create a left aligned text, and a right aligned text on the same line. The laymans approach to this problem would be to either use text boxes or tables. Not ideal!
2018-08-04 03:28:27 +01:00
2019-08-06 17:51:13 +01:00
```ts
2019-09-30 22:56:21 +01:00
const paragraph = new Paragraph({
2019-11-21 01:02:46 +00:00
children: [new TextRun("Second tab stop here I come!")],
2019-10-09 20:56:31 +01:00
tabStops: [
{
type: TabStopType.RIGHT,
2019-09-30 22:56:21 +01:00
position: TabStopPosition.MAX,
},
2019-10-09 20:56:31 +01:00
{
type: TabStopType.LEFT,
2019-09-30 22:56:21 +01:00
position: 1000,
},
2019-10-09 20:56:31 +01:00
],
2019-09-30 22:56:21 +01:00
});
2018-08-04 03:28:27 +01:00
```
The above shows the use of two tab stops, and how to select/use it.
2019-10-09 20:56:31 +01:00
You can add multiple tab stops of the same `type` too.
```ts
const paragraph = new Paragraph({
2019-11-21 01:02:46 +00:00
children: [new TextRun("Multiple tab stops!")],
2019-10-09 20:56:31 +01:00
tabStops: [
{
type: TabStopType.RIGHT,
position: TabStopPosition.MAX,
},
{
type: TabStopType.RIGHT,
position: 1000,
},
],
});
```
2018-08-04 03:28:27 +01:00
## Left Tab Stop
2019-09-30 22:56:21 +01:00
2019-08-06 17:51:13 +01:00
```ts
2019-09-30 22:56:21 +01:00
const paragraph = new Paragraph({
2019-10-09 20:56:31 +01:00
tabStops: [
{
type: TabStopType.LEFT,
2019-09-30 22:56:21 +01:00
position: 2268,
},
2019-10-09 20:56:31 +01:00
],
2019-09-30 22:56:21 +01:00
});
2018-08-04 03:28:27 +01:00
```
2019-09-30 22:56:21 +01:00
2018-08-04 03:28:27 +01:00
2268 is the distance from the left side.
## Center Tab Stop
2019-09-30 22:56:21 +01:00
2019-08-06 17:51:13 +01:00
```ts
2019-09-30 22:56:21 +01:00
const paragraph = new Paragraph({
2019-10-09 20:56:31 +01:00
tabStops: [
{
type: TabStopType.CENTER,
2019-09-30 22:56:21 +01:00
position: 2268,
},
2019-10-09 20:56:31 +01:00
],
2019-09-30 22:56:21 +01:00
});
2018-08-04 03:28:27 +01:00
```
2019-09-30 22:56:21 +01:00
2268 is the distance from the center.
2018-08-04 03:28:27 +01:00
## Right Tab Stop
2019-09-30 22:56:21 +01:00
2019-08-06 17:51:13 +01:00
```ts
2019-09-30 22:56:21 +01:00
const paragraph = new Paragraph({
2019-10-09 20:56:31 +01:00
tabStops: [
{
type: TabStopType.RIGHT,
2019-09-30 22:56:21 +01:00
position: 2268,
},
2019-10-09 20:56:31 +01:00
],
2019-09-30 22:56:21 +01:00
});
2018-08-04 03:28:27 +01:00
```
2019-09-30 22:56:21 +01:00
2268 is the distance fro0oum the left side.
2018-08-04 03:28:27 +01:00
## Max Right Tab Stop
2019-09-30 22:56:21 +01:00
2019-08-06 17:51:13 +01:00
```ts
2019-09-30 22:56:21 +01:00
const paragraph = new Paragraph({
2019-10-09 20:56:31 +01:00
tabStops: [
{
type: TabStopType.RIGHT,
2019-09-30 22:56:21 +01:00
position: TabStopPosition.MAX,
},
2019-10-09 20:56:31 +01:00
],
2019-09-30 22:56:21 +01:00
});
2018-08-04 03:28:27 +01:00
```
2019-09-30 22:56:21 +01:00
2018-08-04 03:28:27 +01:00
This will create a tab stop on the very edge of the right hand side. Handy for right aligning and left aligning text on the same line.