---
title: "Aside · Base UI — StyleX Blocks"
description: "Contextual side panels with a titled header and scrollable body in two densities."
url: "https://stylexblocks.com/components/base-ui/aside/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Aside

Contextual side panels with a titled header and scrollable body in two densities.

- Behavior engine: Base UI
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/aside.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/aside.md)
- Category: Layout
- Sizes: md, lg
- HTML page: https://stylexblocks.com/components/base-ui/aside/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style base-ui
```

Then add the item as source you own:

```sh
npx stylexblocks add aside
```

Equivalent: `npx shadcn add @stylexblocks/aside`. Registry item JSON: https://stylexblocks.com/r/base-ui/aside.json

## Usage

```tsx
import { Aside } from "#components/ui/base-ui/aside.tsx";

export function Example() {
  return (
    // size resolves once on Root; every part inherits it via context —
    // composition per part via render
    <Aside.Root size="md">
      <Aside.Header>
        <Aside.Title>Details</Aside.Title>
      </Aside.Header>
      <Aside.Body>…</Aside.Body>
    </Aside.Root>
  );
}
```

## Source

`components/ui/base-ui/aside.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createSlotRecipeContext } from "#lib/base-ui/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'
import { fontWeights } from '@stylexblocks/ui/tokens/font-weights.stylex.ts'
import { sizes } from '@stylexblocks/ui/tokens/sizes.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const asideRoot = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    minHeight: 0,
    position: 'relative',
    transitionProperty: 'margin-right',
  },
})

const asideHeader = stylex.create({
  base: {
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'stretch',
    minHeight: sizes._12,
    borderBottomWidth: '1px',
  },
})

const asideHeaderSizes = stylex.create({
  md: {
    padding: spacing._4,
  },
  lg: {
    padding: spacing._6,
  },
})

const asideTitle = stylex.create({
  base: {
    fontWeight: fontWeights.medium,
  },
})

const asideTitleSizes = stylex.create({
  md: {
    fontSize: fontSizes.md,
  },
  lg: {
    fontSize: fontSizes.lg,
  },
})

const asideBody = stylex.create({
  base: {
    flex: 1,
    overflow: 'auto',
  },
})

const asideBodySizes = stylex.create({
  md: {
    padding: spacing._4,
  },
  lg: {
    padding: spacing._6,
  },
})

export type AsideSize = keyof typeof asideHeaderSizes

// defineSlotRecipe validates the shape at compile time: default values must
// exist in the axis maps, and slot keys must be `styles` or a declared axis
const asideSlotRecipe = defineSlotRecipe({
  slots: {
    root: { styles: asideRoot },
    header: { styles: asideHeader, sizes: asideHeaderSizes },
    title: { styles: asideTitle, sizes: asideTitleSizes },
    body: { styles: asideBody, sizes: asideBodySizes },
  },
  defaultVariants: { size: "md" },
});

/**
 * Aside — recipe and component colocated in one file. `<Aside.Root size>`
 * resolves the recipe once and every part inherits it through context; each
 * part composes via `render`.
 */
const { withProvider, withContext } = createSlotRecipeContext(asideSlotRecipe);

export const Aside = {
  // slot names resolve mechanically from the recipe maps above
  Root: withProvider("aside", "root", "AsideRoot"),
  Header: withContext("header", "header", "AsideHeader"),
  Title: withContext("h2", "title", "AsideTitle"),
  Body: withContext("div", "body", "AsideBody"),
};
```
