---
title: "Splitter · UI SDK — StyleX Blocks"
description: "Resizable panel dividers with a separator line and a raised drag handle."
url: "https://stylexblocks.com/components/ui-sdk/splitter/"
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/"
---

# Splitter

Resizable panel dividers with a separator line and a raised drag handle.

- Behavior engine: UI SDK
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/splitter.md), [Base UI](https://stylexblocks.com/components/base-ui/splitter.md)
- Category: Layout
- Used in blocks: [AI Chat Conversation](https://stylexblocks.com/block/ui-sdk/ai-chat.md), [Canvas Editor](https://stylexblocks.com/block/ui-sdk/canvas-editor.md), [File Explorer](https://stylexblocks.com/block/ui-sdk/file-explorer.md), [Filterable Table](https://stylexblocks.com/block/ui-sdk/filterable-table.md), [Grouped Table](https://stylexblocks.com/block/ui-sdk/grouped-table.md), [IDE Workspace](https://stylexblocks.com/block/ui-sdk/ide.md), [Inbox Table](https://stylexblocks.com/block/ui-sdk/inbox-table.md), [Incident Console](https://stylexblocks.com/block/ui-sdk/incident-console.md), [Messaging Shell](https://stylexblocks.com/block/ui-sdk/messaging-shell.md), [Page Editor](https://stylexblocks.com/block/ui-sdk/page-editor.md)
- HTML page: https://stylexblocks.com/components/ui-sdk/splitter/

## Install

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

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

Then add the item as source you own:

```sh
npx stylexblocks add splitter
```

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

## Usage

```tsx
import { Splitter } from "#components/ui/ui-sdk/splitter.tsx";

export function Example() {
  return (
    // UI SDK's Resizable: pointer drag, arrow keys and Home/End come from
    // the primitive; ResizeTrigger renders its own separator line and handle
    <Splitter.Root defaultSize={[50, 50]}>
      <Splitter.Panel>{/* panel a */}</Splitter.Panel>
      <Splitter.ResizeTrigger aria-label="Resize panels" />
      <Splitter.Panel>{/* panel b */}</Splitter.Panel>
    </Splitter.Root>
  );
}
```

## Source

`components/ui/ui-sdk/splitter.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createContext, useContext } from "react";
import {
  Resizable as UiSdkResizable,
  ResizableHandle as UiSdkResizableHandle,
  ResizablePanel as UiSdkResizablePanel,
} from "@ui-sdk/react/resizable";
import { mergeProps } from "@ui-sdk/react/primitive";
import type { WithStyleOverrides } from "#lib/recipe-props.ts";
import { colorPalette } from '@stylexblocks/ui/color-palette.stylex.ts'
import { radii } from '@stylexblocks/ui/tokens/radii.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { semanticShadows } from '@stylexblocks/ui/semantic-tokens/shadows.stylex.ts'
import { sizes } from '@stylexblocks/ui/tokens/sizes.stylex.ts'

const splitterResizeTrigger = stylex.create({
  base: {
    '--splitter-border-color': {
      default: semanticColors.border,
      ':focus': semanticColors.borderEmphasized,
    },
    '--splitter-thumb-color': {
      default: semanticColors.bg,
      ':focus': colorPalette.subtle,
    },
    '--splitter-thumb-size': sizes._2,
    '--splitter-thumb-inset': 'calc(var(--splitter-thumb-size) * -0.5)',
    '--splitter-border-size': '1px',
    '--splitter-handle-size': sizes._6,
    outline: 'none',
    display: 'grid',
    placeItems: 'center',
    position: 'relative',
  },
})

const splitterResizeTriggerSeparator = stylex.create({
  base: {
    position: 'absolute',
    backgroundColor: 'var(--splitter-border-color)',
  },
})

const splitterResizeTriggerIndicator = stylex.create({
  base: {
    position: 'relative',
    borderRadius: radii.full,
    backgroundColor: 'var(--splitter-thumb-color)',
    boxShadow: semanticShadows.xs,
    borderWidth: '1px',
    zIndex: 1,
  },
})

// The generated recipe styles the trigger's colors and vars; the handle's
// orientation-dependent geometry (a horizontal splitter renders a vertical
// divider, and vice versa) lives with the component. UI SDK lays the group
// out as a flex row or column and sizes panels with an inline `flex`.
const splitterStatic = stylex.create({
  root: { width: "100%", height: "100%" },
  panel: { minWidth: 0, minHeight: 0 },
  trigger: { flexShrink: 0, zIndex: 2 },
  triggerVertical: { width: "9px", marginBlock: 0, marginInline: "-4px" },
  triggerHorizontal: { height: "9px", marginBlock: "-4px", marginInline: 0 },
  separatorVertical: {
    top: 0,
    bottom: 0,
    left: "calc(50% - 0.5px)",
    width: "var(--splitter-border-size)",
  },
  separatorHorizontal: {
    left: 0,
    right: 0,
    top: "calc(50% - 0.5px)",
    height: "var(--splitter-border-size)",
  },
  indicator: {
    borderStyle: "solid",
    borderColor: semanticColors.border,
  },
  indicatorVertical: {
    width: "var(--splitter-thumb-size)",
    height: "var(--splitter-handle-size)",
  },
  indicatorHorizontal: {
    height: "var(--splitter-thumb-size)",
    width: "var(--splitter-handle-size)",
  },
});

interface SplitterState {
  orientation: "horizontal" | "vertical";
  minSize: number;
}

const SplitterContext = createContext<SplitterState>({
  orientation: "horizontal",
  minSize: 20,
});

type ResizableProps = React.ComponentProps<typeof UiSdkResizable>;

/**
 * Splitter — UI SDK's Resizable wearing the generated recipe.
 * `<Splitter.Root>` holds percentage sizes (`size` / `defaultSize` /
 * `onSizeChange`) and the arrow-key `step`; `<Splitter.Panel>` takes its
 * share (order comes from the DOM, so `index` is optional);
 * `<Splitter.ResizeTrigger>` renders the divider. Pointer drag, arrow keys,
 * Home/End and double-click collapse are UI SDK's, and the handle carries
 * `data-dragging` / `data-hovering`. Composition per part via `render`.
 */
export type SplitterRootProps = WithStyleOverrides<
  Omit<ResizableProps, "layout" | "defaultLayout" | "onLayoutChange">
> & {
  orientation?: "horizontal" | "vertical";
  /** Controlled percentage sizes, one per panel. */
  size?: number[];
  /** Initial percentage sizes when uncontrolled. */
  defaultSize?: number[];
  onSizeChange?: (details: { size: number[] }) => void;
  /** Smallest percentage a panel may shrink to (default 20). */
  minSize?: number;
};

function Root(allProps: SplitterRootProps) {
  const {
    orientation = "horizontal",
    size,
    defaultSize,
    onSizeChange,
    minSize = 20,
    palette,
    style,
    ...rest
  } = allProps;
  return (
    <SplitterContext.Provider value={{ orientation, minSize }}>
      <UiSdkResizable
        {...mergeProps(stylex.props(palette, splitterStatic.root, style), rest)}
        orientation={orientation}
        layout={size}
        defaultLayout={defaultSize ?? (size ? undefined : [50, 50])}
        onLayoutChange={(layout) => onSizeChange?.({ size: layout })}
      />
    </SplitterContext.Provider>
  );
}
Root.displayName = "SplitterRoot";

export type SplitterPanelProps = WithStyleOverrides<
  React.ComponentProps<typeof UiSdkResizablePanel>
> & {
  /** Zero-based index of this panel. Kept for parity; UI SDK reads the order from the DOM. */
  index?: number;
};

function Panel(allProps: SplitterPanelProps) {
  const { index: _index, palette, style, ...rest } = allProps;
  const splitter = useContext(SplitterContext);
  return (
    <UiSdkResizablePanel
      minSize={splitter.minSize}
      {...mergeProps(stylex.props(palette, splitterStatic.panel, style), rest)}
    />
  );
}
Panel.displayName = "SplitterPanel";

export type SplitterResizeTriggerProps = WithStyleOverrides<
  Omit<React.ComponentProps<typeof UiSdkResizableHandle>, "children">
> & {
  /** Extra content inside the handle, after its separator line and grip. */
  children?: React.ReactNode;
  /** Index of the panel before this trigger. Kept for parity; UI SDK reads the order from the DOM. */
  index?: number;
};

function ResizeTrigger(allProps: SplitterResizeTriggerProps) {
  const { index: _index, palette, style, children, ...rest } = allProps;
  const splitter = useContext(SplitterContext);
  // a horizontal splitter lays panels in a row, so its divider is vertical
  const vertical = splitter.orientation === "horizontal";
  return (
    <UiSdkResizableHandle
      aria-label="Resize panels"
      {...mergeProps(
        stylex.props(
          palette,
          splitterStatic.trigger,
          splitterResizeTrigger.base,
          vertical ? splitterStatic.triggerVertical : splitterStatic.triggerHorizontal,
          style,
        ),
        rest,
      )}
    >
      <div
        {...stylex.props(
          splitterResizeTriggerSeparator.base,
          vertical
            ? splitterStatic.separatorVertical
            : splitterStatic.separatorHorizontal,
        )}
      />
      <div
        {...stylex.props(
          splitterResizeTriggerIndicator.base,
          splitterStatic.indicator,
          vertical
            ? splitterStatic.indicatorVertical
            : splitterStatic.indicatorHorizontal,
        )}
      />
      {children}
    </UiSdkResizableHandle>
  );
}
ResizeTrigger.displayName = "SplitterResizeTrigger";

export const Splitter = { Root, Panel, ResizeTrigger };
```
