···11+---
22+title: Higher-Order Layout Components
33+---
44+55+Quartz provides several higher-order components that help with layout composition and responsive design. These components wrap other components to add additional functionality or modify their behavior.
66+77+## `Flex` Component
88+99+The `Flex` component creates a [flexible box layout](https://developer.mozilla.org/en-US/docs/Web/CSS/flex) that can arrange child components in various ways. It's particularly useful for creating responsive layouts and organizing components in rows or columns.
1010+1111+```typescript
1212+type FlexConfig = {
1313+ components: {
1414+ Component: QuartzComponent
1515+ grow?: boolean // whether component should grow to fill space
1616+ shrink?: boolean // whether component should shrink if needed
1717+ basis?: string // initial main size of the component
1818+ order?: number // order in flex container
1919+ align?: "start" | "end" | "center" | "stretch" // cross-axis alignment
2020+ justify?: "start" | "end" | "center" | "between" | "around" // main-axis alignment
2121+ }[]
2222+ direction?: "row" | "row-reverse" | "column" | "column-reverse"
2323+ wrap?: "nowrap" | "wrap" | "wrap-reverse"
2424+ gap?: string
2525+}
2626+```
2727+2828+### Example Usage
2929+3030+```typescript
3131+Component.Flex({
3232+ components: [
3333+ {
3434+ Component: Component.Search(),
3535+ grow: true, // Search will grow to fill available space
3636+ },
3737+ { Component: Component.Darkmode() }, // Darkmode keeps its natural size
3838+ ],
3939+ direction: "row",
4040+ gap: "1rem",
4141+})
4242+```
4343+4444+## `MobileOnly` Component
4545+4646+The `MobileOnly` component is a wrapper that makes its child component only visible on mobile devices. This is useful for creating responsive layouts where certain components should only appear on smaller screens.
4747+4848+### Example Usage
4949+5050+```typescript
5151+Component.MobileOnly(Component.Spacer())
5252+```
5353+5454+## `DesktopOnly` Component
5555+5656+The `DesktopOnly` component is the counterpart to `MobileOnly`. It makes its child component only visible on desktop devices. This helps create responsive layouts where certain components should only appear on larger screens.
5757+5858+### Example Usage
5959+6060+```typescript
6161+Component.DesktopOnly(Component.TableOfContents())
6262+```
+3-1
docs/layout.md
···35353636Quartz **components**, like plugins, can take in additional properties as configuration options. If you're familiar with React terminology, you can think of them as Higher-order Components.
37373838-See [a list of all the components](component.md) for all available components along with their configuration options. You can also checkout the guide on [[creating components]] if you're interested in further customizing the behaviour of Quartz.
3838+See [a list of all the components](component.md) for all available components along with their configuration options. Additionally, Quartz provides several built-in higher-order components for layout composition - see [[layout-components]] for more details.
3939+4040+You can also checkout the guide on [[creating components]] if you're interested in further customizing the behaviour of Quartz.
39414042### Layout breakpoints
4143