Two Column Layout
Two Column Layout
The TwoColumnLayout component creates a responsive two-column grid layout with a main content area and a sidebar. The sidebar can optionally be sticky, staying visible as users scroll through long content.
Features
- Responsive Design: Automatically switches to single column on mobile/tablet
- Sticky Sidebar: Optional sticky positioning for the sidebar
- Customizable Ratio: Adjust the width ratio between columns
- Flexible Content: Accepts any React components as children
Basic Usage
import TwoColumnLayout from '@site/src/components/Layout/TwoColumnLayout';
<TwoColumnLayout
sidebar={<div>Sidebar content here</div>}
>
<div>Main content here</div>
</TwoColumnLayout>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | required | Main content for the left column |
sidebar | ReactNode | required | Content for the right sidebar |
sidebarSticky | boolean | true | Whether the sidebar should stick when scrolling |
sidebarTop | string | '2rem' | Top offset for sticky sidebar (CSS value) |
ratio | string | '2:1' | Column width ratio (e.g., '2:1', '3:1') |
centerVertically | boolean | false | Vertically center the two columns relative to each other |