Skip to content
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

Document FlexBox gap parameter #6616

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Control the Size

COMING UP

```{pyodide}
import panel as pn
pn.extension('tabulator')
```
# Advanced Layouts

## Responsive Layouts with FlexBox

So far when we have talked about responsive layouts we have primarily focused on simple `width`/`height` responsiveness of individual components, i.e. whether they will grow and shrink to fill the available space. For a truly responsive experience however we will need responsive layouts that will reflow the content depending on the size of the screen, browser window or the container they are placed inside of, much like how text wraps when there is insufficient width to accommodate it:

Panel offers one such component out of the box, the [`FlexBox`](../../reference/layouts/FlexBox.ipynb) layout.

```{pyodide}
import panel as pn
pn.extension('tabulator')
```

```{pyodide}
import panel as pn
import random
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorials/intermediate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Embark on a deeper exploration of supplementary topics to further hone your Pane

- **[Efficient Development in Editors](develop_editor.md):** Streamline the debugging process within your preferred editor environment.
- **[Serving Panel Apps](serve.md):** Serve multi-page apps effortlessly while customizing the Panel server to suit your needs.
- **[Advanced Layouts](size.md):** Attain responsive sizing with ease using FlexBox and media queries.
- **[Advanced Layouts](advanced_layouts.md):** Attain responsive sizing with ease using FlexBox and media queries.

## Projects

Expand All @@ -83,7 +83,7 @@ interactivity
structure_data_store
develop_editor
serve
size
advanced_layouts
build_todo
test_todo
```
12 changes: 12 additions & 0 deletions examples/reference/layouts/FlexBox.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"* **``align_items``** (str): Defines the default behavior for how flex items are laid out along the cross axis on the current line. Same options as `align_content`.\n",
"* **``flex_direction``** (str): This establishes the main-axis, thus defining the direction flex items are placed in the flex container. One of 'row', 'row-reverse', 'column', 'column-reverse'.\n",
"* **``flex_wrap``** (str): Whether and how to wrap items in the flex container. One of 'nowrap', 'wrap', 'wrap-reverse'.\n",
"* **``gap``** (str): Defines the spacing between flex items, supporting various units (px, em, rem, %, vw/vh)\n",
Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core of the PR. What was missing.

An example would also have been nice. But I don't plan to contribute this.

"* **``justify_content``** (str): Defines the alignment along the main axis. One of 'flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly', 'start', 'end', 'left', 'right'.\n",
"* **``objects``** (list): The list of objects to display in the WidgetBox. Should not generally be modified directly except when replaced in its entirety.\n",
"\n",
Expand Down Expand Up @@ -125,6 +126,17 @@
"source": [
"In general a ``FlexBox`` does not have to be given a ``width``, ``height`` or ``sizing_mode``, allowing it to adapt to the size of its contents."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## References\n",
"\n",
"### Tutorials\n",
"\n",
"- [Advanced Layouts](../../tutorials/intermediate/advanced_layouts.md)"
]
}
],
"metadata": {
Expand Down
6 changes: 3 additions & 3 deletions panel/layout/flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class FlexBox(ListLike, ReactiveHTML):
'nowrap', 'wrap', 'wrap-reverse'], doc="""
Whether and how to wrap items in the flex container.""")

gap = param.String(default='', doc="""
Defines the spacing between flex items, supporting various units (px, em, rem, %, vw/vh).""")

justify_content = param.Selector(default='flex-start', objects=[
'flex-start', 'flex-end', 'center', 'space-between', 'space-around',
'space-evenly', 'start', 'end', 'left', 'right'], doc="""
Defines the alignment along the main axis.""")

gap = param.String(default='', doc="""
Defines the spacing between flex items, supporting various units (px, em, rem, %, vw/vh).""")

_template = (Path(__file__).parent / 'flexbox.html').read_text('utf-8')

def __init__(self, *objects, **params):
Expand Down
Loading