SplitGrid
panes in columns and rows, with handles between them that move a whole column or row at a time.
usage
example
vultures
cavefish
rottwheelers
ben
maureen
suzi
polecats
darrel
code
import { SplitGrid } from 'charcell/react';
export function SplitGridExample() {
return (
<div style={{ display: 'grid', height: 'calc(var(--charcell-row) * 10)' }}>
<SplitGrid
columns={[{ id: 'gangs' }, { id: 'riders' }]}
rows={[{ id: 'free' }, { id: 'jailed' }]}
defaultColumnSize={[40, 60]}
defaultRowSize={[50, 50]}
>
{({ column, row }) => (
<>
{column === 'gangs' && (
<>
{row === 'free' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>
</>
)}
</>
)}
{column === 'riders' && (
<>
{row === 'free' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>
</>
)}
</>
)}
{column === 'gangs' && (
<>
{row === 'jailed' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>polecats</div>
</div>
</>
)}
</>
)}
{column === 'riders' && (
<>
{row === 'jailed' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>darrel</div>
</div>
</>
)}
</>
)}
</>
)}
</SplitGrid>
</div>
);
}▴
▾
<script setup lang="ts">
import { SplitGrid } from 'charcell/vue';
</script>
<template>
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<SplitGrid
:columns="[{ id: 'gangs' }, { id: 'riders' }]"
:rows="[{ id: 'free' }, { id: 'jailed' }]"
:defaultColumnSize="[40, 60]"
:defaultRowSize="[50, 50]"
>
<template #default="{ column, row }">
<template v-if="column === 'gangs'"
><template v-if="row === 'free'"
><div style="padding: 0 1ch">
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div></template
></template
><template v-if="column === 'riders'"
><template v-if="row === 'free'"
><div style="padding: 0 1ch">
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div></template
></template
><template v-if="column === 'gangs'"
><template v-if="row === 'jailed'"
><div style="padding: 0 1ch"><div>polecats</div></div></template
></template
><template v-if="column === 'riders'"
><template v-if="row === 'jailed'"
><div style="padding: 0 1ch"><div>darrel</div></div></template
></template
>
</template>
</SplitGrid>
</div>
</template>▴
▾
<script lang="ts">
import { SplitGrid } from 'charcell/svelte';
</script>
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<SplitGrid
columns={[{ id: 'gangs' }, { id: 'riders' }]}
rows={[{ id: 'free' }, { id: 'jailed' }]}
defaultColumnSize={[40, 60]}
defaultRowSize={[50, 50]}
>
{#snippet children({ column, row })}
{#if column === 'gangs'}{#if row === 'free'}<div style="padding: 0 1ch;">
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>{/if}{/if}{#if column === 'riders'}{#if row === 'free'}<div
style="padding: 0 1ch;"
>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>{/if}{/if}{#if column === 'gangs'}{#if row === 'jailed'}<div
style="padding: 0 1ch;"
>
<div>polecats</div>
</div>{/if}{/if}{#if column === 'riders'}{#if row === 'jailed'}<div
style="padding: 0 1ch;"
>
<div>darrel</div>
</div>{/if}{/if}
{/snippet}
</SplitGrid>
</div>▴
▾
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<!-- component: SplitGridDriver (behavior not included) -->
<div class="CharcellSplitGrid">
<div class="CharcellSplitGrid__grid">
<div class="CharcellSplitGrid__cell">
<div>
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>
</div>
<div class="CharcellSplitGrid__cell">
<div>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>
</div>
<div class="CharcellSplitGrid__cell">
<div><div>polecats</div></div>
</div>
<div class="CharcellSplitGrid__cell">
<div><div>darrel</div></div>
</div>
<button
class="CharcellSplitGrid__handle CharcellSplitGrid__handle--column"
type="button"
aria-label="resize columns"
></button
><button
class="CharcellSplitGrid__handle CharcellSplitGrid__handle--row"
type="button"
aria-label="resize rows"
>
<span class="CharcellSplitGrid__center-grip" aria-hidden="true"></span>
</button>
<div class="CharcellSplitGrid__handle-row">
<div class="CharcellSplitGrid__handle-start"></div>
<div class="CharcellSplitGrid__handle-end"></div>
</div>
</div>
</div>
<!-- /component -->
</div>▴
▾
import { SplitGrid } from 'charcell/react';
export function SplitGridExample() {
return (
<div style={{ display: 'grid', height: 'calc(var(--charcell-row) * 10)' }}>
<SplitGrid
columns={[{ id: 'gangs' }, { id: 'riders' }]}
rows={[{ id: 'free' }, { id: 'jailed' }]}
defaultColumnSize={[40, 60]}
defaultRowSize={[50, 50]}
rule
>
{({ column, row }) => (
<>
{column === 'gangs' && (
<>
{row === 'free' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>
</>
)}
</>
)}
{column === 'riders' && (
<>
{row === 'free' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>
</>
)}
</>
)}
{column === 'gangs' && (
<>
{row === 'jailed' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>polecats</div>
</div>
</>
)}
</>
)}
{column === 'riders' && (
<>
{row === 'jailed' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>darrel</div>
</div>
</>
)}
</>
)}
</>
)}
</SplitGrid>
</div>
);
}▴
▾
<script setup lang="ts">
import { SplitGrid } from 'charcell/vue';
</script>
<template>
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<SplitGrid
:columns="[{ id: 'gangs' }, { id: 'riders' }]"
:rows="[{ id: 'free' }, { id: 'jailed' }]"
:defaultColumnSize="[40, 60]"
:defaultRowSize="[50, 50]"
rule
>
<template #default="{ column, row }">
<template v-if="column === 'gangs'"
><template v-if="row === 'free'"
><div style="padding: 0 1ch">
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div></template
></template
><template v-if="column === 'riders'"
><template v-if="row === 'free'"
><div style="padding: 0 1ch">
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div></template
></template
><template v-if="column === 'gangs'"
><template v-if="row === 'jailed'"
><div style="padding: 0 1ch"><div>polecats</div></div></template
></template
><template v-if="column === 'riders'"
><template v-if="row === 'jailed'"
><div style="padding: 0 1ch"><div>darrel</div></div></template
></template
>
</template>
</SplitGrid>
</div>
</template>▴
▾
<script lang="ts">
import { SplitGrid } from 'charcell/svelte';
</script>
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<SplitGrid
columns={[{ id: 'gangs' }, { id: 'riders' }]}
rows={[{ id: 'free' }, { id: 'jailed' }]}
defaultColumnSize={[40, 60]}
defaultRowSize={[50, 50]}
rule
>
{#snippet children({ column, row })}
{#if column === 'gangs'}{#if row === 'free'}<div style="padding: 0 1ch;">
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>{/if}{/if}{#if column === 'riders'}{#if row === 'free'}<div
style="padding: 0 1ch;"
>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>{/if}{/if}{#if column === 'gangs'}{#if row === 'jailed'}<div
style="padding: 0 1ch;"
>
<div>polecats</div>
</div>{/if}{/if}{#if column === 'riders'}{#if row === 'jailed'}<div
style="padding: 0 1ch;"
>
<div>darrel</div>
</div>{/if}{/if}
{/snippet}
</SplitGrid>
</div>▴
▾
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<!-- component: SplitGridDriver (behavior not included) -->
<div class="CharcellSplitGrid CharcellSplitGrid--rule">
<div class="CharcellSplitGrid__grid">
<div class="CharcellSplitGrid__cell">
<div>
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>
</div>
<div class="CharcellSplitGrid__cell">
<div>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>
</div>
<div class="CharcellSplitGrid__cell">
<div><div>polecats</div></div>
</div>
<div class="CharcellSplitGrid__cell">
<div><div>darrel</div></div>
</div>
<button
class="CharcellSplitGrid__handle CharcellSplitGrid__handle--column"
type="button"
aria-label="resize columns"
></button
><button
class="CharcellSplitGrid__handle CharcellSplitGrid__handle--row"
type="button"
aria-label="resize rows"
>
<span class="CharcellSplitGrid__center-grip" aria-hidden="true"></span>
</button>
<div class="CharcellSplitGrid__handle-row">
<div class="CharcellSplitGrid__handle-start"></div>
<div class="CharcellSplitGrid__handle-end"></div>
</div>
</div>
</div>
<!-- /component -->
</div>▴
▾
import { SplitGrid } from 'charcell/react';
export function SplitGridExample() {
return (
<div style={{ display: 'grid', height: 'calc(var(--charcell-row) * 10)' }}>
<SplitGrid
columns={[{ id: 'gangs' }, { id: 'riders' }]}
rows={[{ id: 'free' }, { id: 'jailed' }]}
defaultColumnSize={[40, 60]}
defaultRowSize={[50, 50]}
rowGrips="one"
>
{({ column, row }) => (
<>
{column === 'gangs' && (
<>
{row === 'free' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>
</>
)}
</>
)}
{column === 'riders' && (
<>
{row === 'free' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>
</>
)}
</>
)}
{column === 'gangs' && (
<>
{row === 'jailed' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>polecats</div>
</div>
</>
)}
</>
)}
{column === 'riders' && (
<>
{row === 'jailed' && (
<>
<div style={{ padding: '0 1ch' }}>
<div>darrel</div>
</div>
</>
)}
</>
)}
</>
)}
</SplitGrid>
</div>
);
}▴
▾
<script setup lang="ts">
import { SplitGrid } from 'charcell/vue';
</script>
<template>
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<SplitGrid
:columns="[{ id: 'gangs' }, { id: 'riders' }]"
:rows="[{ id: 'free' }, { id: 'jailed' }]"
:defaultColumnSize="[40, 60]"
:defaultRowSize="[50, 50]"
rowGrips="one"
>
<template #default="{ column, row }">
<template v-if="column === 'gangs'"
><template v-if="row === 'free'"
><div style="padding: 0 1ch">
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div></template
></template
><template v-if="column === 'riders'"
><template v-if="row === 'free'"
><div style="padding: 0 1ch">
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div></template
></template
><template v-if="column === 'gangs'"
><template v-if="row === 'jailed'"
><div style="padding: 0 1ch"><div>polecats</div></div></template
></template
><template v-if="column === 'riders'"
><template v-if="row === 'jailed'"
><div style="padding: 0 1ch"><div>darrel</div></div></template
></template
>
</template>
</SplitGrid>
</div>
</template>▴
▾
<script lang="ts">
import { SplitGrid } from 'charcell/svelte';
</script>
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<SplitGrid
columns={[{ id: 'gangs' }, { id: 'riders' }]}
rows={[{ id: 'free' }, { id: 'jailed' }]}
defaultColumnSize={[40, 60]}
defaultRowSize={[50, 50]}
rowGrips="one"
>
{#snippet children({ column, row })}
{#if column === 'gangs'}{#if row === 'free'}<div style="padding: 0 1ch;">
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>{/if}{/if}{#if column === 'riders'}{#if row === 'free'}<div
style="padding: 0 1ch;"
>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>{/if}{/if}{#if column === 'gangs'}{#if row === 'jailed'}<div
style="padding: 0 1ch;"
>
<div>polecats</div>
</div>{/if}{/if}{#if column === 'riders'}{#if row === 'jailed'}<div
style="padding: 0 1ch;"
>
<div>darrel</div>
</div>{/if}{/if}
{/snippet}
</SplitGrid>
</div>▴
▾
<div style="display: grid; height: calc(var(--charcell-row) * 10)">
<!-- component: SplitGridDriver (behavior not included) -->
<div class="CharcellSplitGrid CharcellSplitGrid--one-row-grip">
<div class="CharcellSplitGrid__grid">
<div class="CharcellSplitGrid__cell">
<div>
<div>vultures</div>
<div>cavefish</div>
<div>rottwheelers</div>
</div>
</div>
<div class="CharcellSplitGrid__cell">
<div>
<div>ben</div>
<div>maureen</div>
<div>suzi</div>
</div>
</div>
<div class="CharcellSplitGrid__cell">
<div><div>polecats</div></div>
</div>
<div class="CharcellSplitGrid__cell">
<div><div>darrel</div></div>
</div>
<button
class="CharcellSplitGrid__handle CharcellSplitGrid__handle--column"
type="button"
aria-label="resize columns"
></button
><button
class="CharcellSplitGrid__handle CharcellSplitGrid__handle--row"
type="button"
aria-label="resize rows"
>
<span class="CharcellSplitGrid__center-grip" aria-hidden="true"></span>
</button>
<div class="CharcellSplitGrid__handle-row">
<div class="CharcellSplitGrid__handle-start"></div>
<div class="CharcellSplitGrid__handle-end"></div>
</div>
</div>
</div>
<!-- /component -->
</div>▴
▾
as text
gangs ⠿ riders ⠶⠶ ⠶⠶ jailed ⠿ darrel
gangs ⠿ riders ⠶⠶ ⠶⠶ jailed ⠿ darrel
gangs ⠿ riders ⠶⠶ ⠶⠶ jailed ⠿ darrel
gangs ⠿ riders ⠶⠶ ⠶⠶ jailed ⠿ darrel
gangs ⠿ riders │ ───⠶⠶────┼────⠶⠶──── jailed ⠿ darrel │
gangs ⠿ riders ───⠶⠶──── ────⠶⠶──── jailed ⠿ darrel
gangs ⠿ riders ───⠶⠶─────────⠶⠶──── jailed ⠿ darrel
gangs ⠿ riders ───⠶⠶─────────⠶⠶──── jailed ⠿ darrel
gangs ⠿ riders ⠶⠶ jailed ⠿ darrel
gangs ⠿ riders ⠶⠶ jailed ⠿ darrel
gangs ⠿ riders ⠶⠶ jailed ⠿ darrel
gangs ⠿ riders ⠶⠶ jailed ⠿ darrel
gangs ⠿ riders │ jailed ─┼⠶⠶───── + jailed ⠿ darrel │
props
SplitGrid
- direction'ltr' | 'rtl'
- The reading direction its keys and placement follow (
'rtl'mirrors the arrow keys); the page's, once mounted, when unset. - columnsSplitGridTrack[]
- The columns, left to right: an id each, and, snapping,
minimumCells,keepCellsanddefaultCells(a count, or'content'). - rowsSplitGridTrack[]
- The rows, top to bottom.
- defaultColumnSizenumber[]
- The columns' starting sizes in percent, e.g.
[25, 75]. - defaultRowSizenumber[]
- The rows' starting sizes in percent.
- snap'character' | 'none'= 'character'
- Boundaries snap to whole columns and rows;
'none'opts out. - redistribute'neighbor' | 'proportional'= 'neighbor'
- How the cells are shared when the columns or rows change: a leaving track's to its neighbor (
'neighbor'), or to every track that stays, by its length ('proportional'), a joining one taking its cells from all of them. - ruleboolean
- Draws the handles as lines through their cells, a grip in each pane.
- rowGrips'each' | 'one'= 'each'
- A row's handle's grips:
each, one in every pane it passes;one, one at its middle. - join'start' | 'end' | 'both'
- Runs ruled handles' ends on past the grid to meet the lines beyond: a frame's ring when the grid sits directly in its body, or else the line in the next cell (
┬ ┴ ├ ┤). - fillboolean
- Takes the container's box: grows in a flex or grid layout, and takes the full height of a block that has one.
- translationsSplitGridTranslations
- What the grid says: its handles' names, between two columns (
columnHandleLabel) and two rows (rowHandleLabel).
SplitGridCell
it takes any attribute of its <div>.
SplitGridHandle
- axis'column' | 'row'= 'column'
columnruns down between two columns,rowacross between two rows.- crossesstring[]
- The tracks it runs across: the rows for a column's handle, the columns for a row's.
- labelstring
- The handle's accessible name.
it also takes any other attribute of its <button>.
SplitGridHandleRow
it takes any attribute of its <div>.
slots
in react, the default slot is children and each named slot a prop of its name, a function where the slot hands values; in vue, a slot; in svelte, a snippet.
SplitGrid
- default{ column: string; row: string }
- A cell, given its
columnandrowids. - rowHandleStart{ before: string; after: string }
- Content on the handle between two rows, at its start, given the rows
beforeandafterit. - rowHandleEnd{ before: string; after: string }
- Content on the handle between two rows, at its end, given the rows
beforeandafterit.
SplitGridCell
- default
SplitGridHandleRow
- start
- Content at the row's start, before the grip.
- end
- Content at the row's end, after the grip.
▴
▾