---
title: "Splitter · Ark UI — StyleX Blocks"
description: "Resizable panel dividers with a separator line and a raised drag handle."
url: "https://stylexblocks.com/components/ark-ui/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: Ark UI
- Also available for: [Base UI](https://stylexblocks.com/components/base-ui/splitter.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/splitter.md)
- Category: Layout
- HTML page: https://stylexblocks.com/components/ark-ui/splitter/

## Install

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

```sh
npx stylexblocks init
```

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/ark-ui/splitter.json

## Usage

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

export function Example() {
  return (
    // panel sizing, pointer drag, and arrow-key resize come from the
    // machine; ResizeTrigger renders its own separator line and drag handle
    <Splitter.Root panels={[{ id: "a" }, { id: "b" }]} defaultSize={[50, 50]}>
      <Splitter.Panel id="a">{/* panel a */}</Splitter.Panel>
      <Splitter.ResizeTrigger id="a:b" />
      <Splitter.Panel id="b">{/* panel b */}</Splitter.Panel>
    </Splitter.Root>
  );
}
```

## Source

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

```tsx
import * as stylex from "@stylexjs/stylex";
import {
  Splitter as ArkSplitter,
  useSplitterContext,
} from "@ark-ui/react/splitter";
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 trigger's
// browser-button reset and the orientation-dependent geometry (a horizontal
// splitter renders a vertical divider, and vice versa) live with the
// component. State (drag, keyboard resize) is the machine's.
const splitterStatic = stylex.create({
  root: { display: "flex", width: "100%", height: "100%" },
  panel: { minWidth: 0, minHeight: 0 },
  trigger: {
    appearance: "none",
    borderWidth: 0,
    borderStyle: "none",
    backgroundColor: "transparent",
    padding: 0,
    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)",
  },
});

function mergeClassName(base: string | undefined, extra: unknown) {
  return typeof extra === "string" && extra.length > 0
    ? [base, extra].filter(Boolean).join(" ")
    : base;
}

/**
 * Splitter — Ark UI's splitter machine wearing the generated recipe.
 * `<Splitter.Root panels>` drives panel sizing; `ResizeTrigger` renders the
 * separator line and drag handle itself (pointer drag and arrow-key resize
 * are the machine's). Composition per part via `asChild`.
 */
type RootProps = WithStyleOverrides<React.ComponentProps<typeof ArkSplitter.Root>>;

function Root(allProps: RootProps) {
  const { palette, style, className, ...rest } = allProps;
  const p = stylex.props(palette, splitterStatic.root, style);
  return (
    <ArkSplitter.Root
      {...rest}
      className={mergeClassName(p.className, className)}
      style={p.style}
    />
  );
}
Root.displayName = "SplitterRoot";

type PanelProps = WithStyleOverrides<React.ComponentProps<typeof ArkSplitter.Panel>>;

function Panel(allProps: PanelProps) {
  const { palette, style, className, ...rest } = allProps;
  const p = stylex.props(palette, splitterStatic.panel, style);
  return (
    <ArkSplitter.Panel
      {...rest}
      className={mergeClassName(p.className, className)}
      style={p.style}
    />
  );
}
Panel.displayName = "SplitterPanel";

type ResizeTriggerProps = WithStyleOverrides<
  React.ComponentProps<typeof ArkSplitter.ResizeTrigger>
>;

function ResizeTrigger(allProps: ResizeTriggerProps) {
  const { palette, style, className, children, ...rest } = allProps;
  // a horizontal splitter lays panels in a row, so its divider is vertical
  const vertical = useSplitterContext().orientation === "horizontal";
  const p = stylex.props(
    palette,
    splitterStatic.trigger,
    splitterResizeTrigger.base,
    vertical ? splitterStatic.triggerVertical : splitterStatic.triggerHorizontal,
    style,
  );
  return (
    <ArkSplitter.ResizeTrigger
      {...rest}
      className={mergeClassName(p.className, className)}
      style={p.style}
    >
      <div
        {...stylex.props(
          splitterResizeTriggerSeparator.base,
          vertical
            ? splitterStatic.separatorVertical
            : splitterStatic.separatorHorizontal,
        )}
      />
      <div
        {...stylex.props(
          splitterResizeTriggerIndicator.base,
          splitterStatic.indicator,
          vertical
            ? splitterStatic.indicatorVertical
            : splitterStatic.indicatorHorizontal,
        )}
      />
      {children}
    </ArkSplitter.ResizeTrigger>
  );
}
ResizeTrigger.displayName = "SplitterResizeTrigger";

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