2024-12-19 23:30:46 +00:00
< script setup >
2024-12-18 15:51:16 +00:00
import { ref } from 'vue'
2024-12-04 15:06:34 +00:00
import Card from '~/components/ui/Card.vue'
import Alert from '~/components/ui/Alert.vue'
import Layout from '~/components/ui/Layout.vue'
2025-01-09 23:46:57 +00:00
import Spacer from '~/components/ui/Spacer.vue'
2024-12-04 15:06:34 +00:00
import Tab from '~/components/ui/Tab.vue'
import Tabs from '~/components/ui/Tabs.vue'
2024-12-15 14:06:27 +00:00
import Toggle from '~/components/ui/Toggle.vue'
2024-12-18 15:51:16 +00:00
import Button from '~/components/ui/Button.vue'
2024-12-15 14:06:27 +00:00
const isGrowing = ref(true)
const noGap = ref(true)
2024-11-26 11:59:11 +00:00
< / script >
2025-01-10 00:13:17 +00:00
```ts
import Layout from "~/components/ui/Layout.vue"
```
2024-11-26 11:59:11 +00:00
# Layout
2025-01-01 23:33:54 +00:00
CSS provides [four methods to arrange items in a container ](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout/Relationship_of_grid_layout_with_other_layout_methods ): Flow, Columns, Flex and Grid. To make typical alignment tasks in the Funkwhale Ui easier, we have created a few useful presets.
## Apply presets
2024-11-26 11:59:11 +00:00
The following containers are responsive. Change your window's size or select a device preset from your browser's dev tools to see how layouts are affected by available space.
2024-12-22 01:27:20 +00:00
< Layout flex style = "--gap:8px" >
2025-01-01 23:33:54 +00:00
< Card width = "163px" title = "flex" to = "/components/ui/layout/flex" >
2025-01-09 14:02:36 +00:00
< Layout flex style = "outline: 4px dashed var(--border-color)" >
2024-12-19 23:30:46 +00:00
< Button primary icon = "bi-eye" / >
2025-01-09 14:02:36 +00:00
< Button outline icon = "bi-eye" / >
2024-12-19 23:30:46 +00:00
< Button destructive icon = "bi-eye" / >
2024-12-04 15:06:34 +00:00
< / Layout >
2024-11-26 11:59:11 +00:00
< / Card >
2025-01-01 23:33:54 +00:00
< Card width = "163px" title = "grid" to = "/components/ui/layout/grid" >
2025-01-09 14:02:36 +00:00
< Layout grid column-width = "40" style = "outline: 4px dashed var(--border-color)" >
2024-12-19 23:30:46 +00:00
< Button primary icon = "bi-eye" / >
2025-01-09 14:02:36 +00:00
< Button outline icon = "bi-eye" style = "grid-row: span 2; height: 100%;" / >
2024-12-19 23:30:46 +00:00
< Button destructive icon = "bi-eye" / >
< / Layout >
2024-11-26 11:59:11 +00:00
< / Card >
2025-01-09 14:02:36 +00:00
< Card width = "163px" title = "stack" to = "/components/ui/layout/stack" >
< Layout stack style = "--gap:0; margin:-8px; outline: 4px dashed var(--border-color)" >
2024-12-19 23:30:46 +00:00
< Button primary icon = "bi-eye" / >
2025-01-09 14:02:36 +00:00
< Button outline icon = "bi-eye" / >
2024-12-19 23:30:46 +00:00
< Button destructive icon = "bi-eye" / >
< / Layout > < / Card >
2025-01-09 14:14:21 +00:00
< Card width = "163px" title = "columns" to = "/components/ui/layout/columns" >
2025-01-09 14:02:36 +00:00
< Layout columns column-width = "40" style = "outline: 4px dashed var(--border-color)" >
2024-12-19 23:30:46 +00:00
< Button primary icon = "bi-eye" / >
2025-01-09 14:02:36 +00:00
< Button outline icon = "bi-eye" / >
2024-12-19 23:30:46 +00:00
< Button destructive icon = "bi-eye" / >
< / Layout > < / Card >
2024-11-26 11:59:11 +00:00
< / Layout >
2024-12-15 14:06:27 +00:00
2025-01-01 23:33:54 +00:00
## Add semantics
Add one of these props to your `Layout` component to turn them into semantic containers (without affecting their presentation):
**Headings:** [`"h1" | "h2" | "h3" | "h4" | "h5"` ](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements#usage_notes )
**Sectioning:** [`"nav" | "aside" | "header" | "footer" | "main"` ](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section#usage_notes )
**Forms:** [`"label" | "form"` ](https://developer.mozilla.org/en-US/docs/Web/HTML/Element#forms )
2024-12-15 14:06:27 +00:00
## Common props
### `no-gap`: Remove the gap between items
< Layout flex >
```vue
< script setup >
const noGap = ref(true);
< / script >
< template >
< Toggle v-model = "noGap" / >
< Layout flex :no-gap = "noGap || undefined" >
2024-12-19 13:57:04 +00:00
< Card title = "A" small / >
< Card title = "B" small / >
< Card title = "C" small / >
< Card title = "D" small / >
2024-12-15 14:06:27 +00:00
< / Layout >
< / template >
```
2024-12-19 13:57:04 +00:00
< div class = "preview" style = "width:0" >
2024-12-30 12:44:38 +00:00
< Toggle v-model = "noGap" label = "no-gap" / >
2024-12-15 14:06:27 +00:00
---
< Layout flex :no-gap = "noGap || undefined" >
2024-12-22 20:19:49 +00:00
< Card title = "A" tiny / >
< Card title = "B" tiny / >
< Card title = "C" tiny / >
< Card title = "D" tiny / >
2024-12-15 14:06:27 +00:00
< / Layout >
< / div >
< / Layout >
### Add fixed or flexible Spacers
2024-12-19 13:57:04 +00:00
::: info Only available on:
- **stack**
- **flex**
:::
2024-12-15 14:06:27 +00:00
If you add a spacer with attribute `grow` , it will push the other item until the Layout fills the available space. This only works if the parent element itself grows beyond its minimal contents.
< Layout flex >
```vue
< script setup >
const isGrowing = ref(true);
< / script >
< template >
< Toggle v-model = "isGrowing" / >
2024-12-30 12:44:38 +00:00
< Layout stack style = "height:25em;" >
2024-12-19 13:57:04 +00:00
< Alert red / >
< Alert purple / >
2024-12-18 15:51:16 +00:00
< Spacer :grow = "isGrowing || undefined" / >
2024-12-19 13:57:04 +00:00
< Alert blue / >
2024-12-18 15:51:16 +00:00
< / Layout >
2024-12-15 14:06:27 +00:00
< / template >
```
< div class = "preview" >
2024-12-30 12:44:38 +00:00
< Toggle v-model = "isGrowing" label = "grow" / >
2024-12-15 14:06:27 +00:00
---
2024-12-30 12:44:38 +00:00
< Layout stack style = "height:25em" >
2024-12-19 13:57:04 +00:00
< Alert red / >
< Alert purple / >
< Spacer :grow = "isGrowing || undefined" / >
< Alert blue / >
2024-12-18 15:51:16 +00:00
< / Layout >
2024-12-15 14:06:27 +00:00
< / div >
< / Layout >
Multiple spacers will distribute their growth evenly.
2024-12-20 15:16:24 +00:00
Note that you can set the minimum space occupied by the `Spacer` with its `size` prop [(docs) ](./layout/spacer ). Negative values can offset the gap of the `Layout` (but, due to a limitation of flexbox, not eat into the space occupied by adjacent items):
2024-12-15 14:06:27 +00:00
< Layout flex >
```vue
< template >
< Toggle v-model = "isGrowing" / >
2024-12-30 12:44:38 +00:00
< Layout stack style = "height:35em;" >
2024-12-19 13:57:04 +00:00
< Alert blue / >
2024-12-18 15:51:16 +00:00
< Spacer :size = "-32" :grow = "isGrowing || undefined" / >
2024-12-19 13:57:04 +00:00
< Alert green / >
< Alert yellow / >
2024-12-18 15:51:16 +00:00
< Spacer :size = "-32" :grow = "isGrowing || undefined" / >
2024-12-19 13:57:04 +00:00
< Alert red / >
2024-12-18 15:51:16 +00:00
< / Layout >
2024-12-15 14:06:27 +00:00
< / template >
```
< div class = "preview" style = "width:0" >
< Toggle v-model = "isGrowing" / >
---
2024-12-30 12:44:38 +00:00
< Layout stack style = "height:35em;" >
2024-12-19 13:57:04 +00:00
< Alert blue / >
2024-12-18 15:51:16 +00:00
< Spacer :size = "-32" :grow = "isGrowing || undefined" / >
2024-12-19 13:57:04 +00:00
< Alert green / >
< Alert yellow / >
2024-12-18 15:51:16 +00:00
< Spacer :size = "-32" :grow = "isGrowing || undefined" / >
2024-12-19 13:57:04 +00:00
< Alert red / >
2024-12-15 14:06:27 +00:00
< / Layout >
< / div >
< / Layout >
2024-12-19 23:30:46 +00:00
---
< Tabs class = "solid" style = "border: 32px solid var(--background-color);border-radius: 8px;outline: 1px solid var(--border-color);margin: 0 -32px;" >
< Tab title = "Flex (default)" icon = "⠖" >
Items are laid out in a row and wrapped as they overflow the container
2025-01-01 23:33:54 +00:00
[Layout flex ](/components/ui/layout/flex )
2024-12-19 23:30:46 +00:00
< / Tab >
< Tab title = "Grid" icon = "ꖛ" >
Align items both vertically and horizontally
2025-01-01 23:33:54 +00:00
[Layout grid ](/components/ui/layout/grid )
2024-12-19 23:30:46 +00:00
< / Tab >
< Tab title = "Stack" icon = "𝌆" >
Add space between vertically stacked items
2025-01-01 23:33:54 +00:00
[Layout stack ](/components/ui/layout/stack )
2024-12-19 23:30:46 +00:00
< / Tab >
< Tab title = "Columns" icon = "ꔖ" >
Let text and items flow like on a printed newspaper
2025-01-01 23:33:54 +00:00
[Layout columns ](/components/ui/layout/columns )
2024-12-19 23:30:46 +00:00
< / Tab >
< / Tabs >