Easily manage the layout of your components with the responsive FlexBox utilities. If you require a utility to manage the layout of your application, refer to the Grid System instead.
An element can configured as a flexbox container using the p-d-flex or p-d-inline-flex classes.
<div class="p-d-flex">Flex Container</div>
<div class="p-d-inline-flex">Inline Flex Container</div>
Default is applied using the p-flex-{direction} class where direction can be either of the following.
<div class="p-d-flex">
<div class="p-mr-2">Item 1</div>
<div class="p-mr-2">Item 2</div>
<div>Item 3</div>
</div>
<div class="p-d-flex p-flex-column">
<div class="p-mb-2">Item 1</div>
<div class="p-mb-2">Item 2</div>
<div>Item 3</div>
</div>
Row direction for larger screens and column for smaller.
<div class="p-d-flex p-flex-column p-flex-md-row">
<div class="p-mb-2 p-mr-2">Item 1</div>
<div class="p-mb-2 p-mr-2">Item 2</div>
<div class="p-mb-2 p-mr-2">Item 3</div>
</div>
Order configures the way in which they appear in the flex container. p-order-{value} format is used where value can be a number from 0 to 6.
<div class="p-d-flex">
<div class="p-mr-2 p-order-3">Item 1</div>
<div class="p-mr-2 p-order-1">Item 2</div>
<div class="p-mr-2 p-order-2">Item 3</div>
</div>
Orders change depending on the screen size.
<div class="p-d-flex">
<div class="p-mr-2 p-order-3 p-order-md-2">Item 1</div>
<div class="p-mr-2 p-order-1 p-order-md-3">Item 2</div>
<div class="p-mr-2 p-order-2 p-order-md-1">Item 3</div>
</div>
Flex wrap defines the wrap behavior when there is not enough space in the container. The format of the class is p-flex-{value} and the value field can be either of the listed alternatives.
<div class="p-d-flex">
<div class="p-mr-2 p-mb-2">Item 1</div>
<div class="p-mr-2 p-mb-2">Item 2</div>
<div class="p-mr-2 p-mb-2">Item 3</div>
<div class="p-mr-2 p-mb-2">Item 4</div>
<div class="p-mr-2 p-mb-2">Item 5</div>
<div class="p-mr-2 p-mb-2">Item 6</div>
</div>
<div class="p-d-flex p-flex-wrap">
<div class="p-mr-2 p-mb-2">Item 1</div>
<div class="p-mr-2 p-mb-2">Item 2</div>
<div class="p-mr-2 p-mb-2">Item 3</div>
<div class="p-mr-2 p-mb-2">Item 4</div>
<div class="p-mr-2 p-mb-2">Item 5</div>
<div class="p-mr-2 p-mb-2">Item 6</div>
</div>
<div class="p-d-flex p-flex-wrap-reverse">
<div class="p-mr-2 p-mb-2">Item 1</div>
<div class="p-mr-2 p-mb-2">Item 2</div>
<div class="p-mr-2 p-mb-2">Item 3</div>
<div class="p-mr-2 p-mb-2">Item 4</div>
<div class="p-mr-2 p-mb-2">Item 5</div>
<div class="p-mr-2 p-mb-2">Item 6</div>
</div>
Justify content is the alignment along the main axis and defined using the p-jc-{value} format with responsive alternatives. Value field accepts the options below.
<div class="p-d-flex p-jc-between">
<div>Item 1</div>
<div>Item 2</div>
</div>
<div class="p-d-flex p-jc-center">
<div class="p-mr-2">Item 1</div>
<div>Item 2</div>
</div>
Align Items configuration is the alignment along the cross axis and defined using the p-ai-{value} format with responsive alternatives. Value field accepts the options below.
<div class="p-d-flex p-ai-start">
<div class="p-mr-2" style="height:100px">Item 1</div>
<div style="height:50px">Item 2</div>
</div>
<div class="p-d-flex p-ai-center">
<div class="p-mr-2" style="height:100px">Item 1</div>
<div style="height:50px">Item 2</div>
</div>
Align self configuration is the alignment along the cross axis for a particular element and defined using the p-as-{value} format with responsive alternatives. Value field accepts the options below.
<div class="p-d-flex" style="height: 150px;">
<div class="p-mr-2 p-as-start">Start</div>
<div class="p-mr-2 p-as-center">Center</div>
<div class="p-mr-2 p-as-end">End</div>
<div class="p-mr-2 p-as-stretch">Stretch</div>
</div>
Align content is the alignment along the cross axis and defined using the p-ac-{value} format with responsive alternatives. Value field accepts the options below.
When combined with spacing utilities, flexbox offers endless possibilities.
<div class="p-d-flex p-p-3 card">
<p:button icon="pi pi-check" styleClass="p-mr-2" />
<p:button icon="pi pi-trash" styleClass="ui-button-danger"/>
<p:button icon="pi pi-search" styleClass="p-ml-auto ui-button-help"/>
</div>
<div class="p-d-flex p-flex-column" style="height:150px">
<div>Item 1</div>
<div class="p-mt-auto">Item 2</div>
</div>