resizable

A resizable layout component that allows users to resize panels by dragging dividers between them.

PreviousNext
One
Two
Three
import { Component, ViewEncapsulation } from '@angular/core';

import { ZardResizableImports } from '@/shared/components/resizable/resizable.imports';

@Component({
  selector: 'z-demo-resizable-preview',
  imports: [...ZardResizableImports],
  template: `
    <z-resizable class="h-60 w-80 rounded-lg border sm:w-96">
      <z-resizable-panel>
        <div class="flex h-full items-center justify-center p-6">
          <span class="font-semibold">One</span>
        </div>
      </z-resizable-panel>
      <z-resizable-handle zWithHandle />
      <z-resizable-panel>
        <z-resizable zLayout="vertical">
          <z-resizable-panel zDefaultSize="25">
            <div class="flex h-full items-center justify-center p-6">
              <span class="font-semibold">Two</span>
            </div>
          </z-resizable-panel>
          <z-resizable-handle zWithHandle />
          <z-resizable-panel zDefaultSize="75">
            <div class="flex h-full items-center justify-center p-6">
              <span class="font-semibold">Three</span>
            </div>
          </z-resizable-panel>
        </z-resizable>
      </z-resizable-panel>
    </z-resizable>
  `,
  encapsulation: ViewEncapsulation.None,
})
export class ZardDemoResizablePreviewComponent {}

Installation

Copy
npx zard-cli@latest add resizable

Usage

import { ZardResizableImports } from '@/shared/components/resizable/resizable.imports';
Copy
<z-resizable>
  <z-resizable-panel>Panel One</z-resizable-panel>
  <z-resizable-handle />
  <z-resizable-panel>Panel Two</z-resizable-panel>
</z-resizable>
Copy

Examples

vertical

Use zLayout="vertical" for vertical resizing.

Header
Content
import { Component } from '@angular/core';

import { ZardResizableImports } from '@/shared/components/resizable/resizable.imports';

@Component({
  selector: 'z-demo-resizable-vertical',
  imports: [...ZardResizableImports],
  template: `
    <z-resizable zLayout="vertical" class="h-60 w-80 rounded-lg border sm:w-96">
      <z-resizable-panel [zDefaultSize]="30">
        <div class="flex h-full items-center justify-center p-6">
          <span class="font-semibold">Header</span>
        </div>
      </z-resizable-panel>
      <z-resizable-handle />
      <z-resizable-panel [zDefaultSize]="70">
        <div class="flex h-full items-center justify-center p-6">
          <span class="font-semibold">Content</span>
        </div>
      </z-resizable-panel>
    </z-resizable>
  `,
})
export class ZardDemoResizableVerticalComponent {}

with handle

Use the zWithHandle input on z-resizable-handle to show a visible handle.

Sidebar
Content
import { Component } from '@angular/core';

import { ZardResizableImports } from '@/shared/components/resizable/resizable.imports';

@Component({
  selector: 'z-demo-resizable-with-handle',
  imports: [...ZardResizableImports],
  template: `
    <div class="space-y-4">
      <z-resizable class="h-60 w-80 rounded-lg border sm:w-96">
        <z-resizable-panel [zDefaultSize]="25">
          <div class="flex h-full items-center justify-center p-6">
            <span class="font-semibold">Sidebar</span>
          </div>
        </z-resizable-panel>
        <z-resizable-handle zWithHandle />
        <z-resizable-panel [zDefaultSize]="75">
          <div class="flex h-full items-center justify-center p-6">
            <span class="font-semibold">Content</span>
          </div>
        </z-resizable-panel>
      </z-resizable>
    </div>
  `,
})
export class ZardDemoResizableWithHandleComponent {}

API Reference

z-resizableComponent

The main container component that manages resizable panels.

PropertyDescriptionTypeDefault
zLayout Layout direction of the panels 'horizontal' | 'vertical' 'horizontal'
zLazy If true, panels only update after resize ends boolean false
class Additional CSS classes to apply ClassValue ''
zResizeStart Emitted when resize starts output<ZardResizeEvent> -
zResize Emitted during resize output<ZardResizeEvent> -
zResizeEnd Emitted when resize ends output<ZardResizeEvent> -

z-resizable-panelComponent

Individual panel component within a resizable container.

PropertyDescriptionTypeDefault
zDefaultSize Initial size as percentage number | string | undefined undefined
zMin Minimum size as percentage number 0
zMax Maximum size as percentage number 100
zCollapsible Whether panel can be collapsed boolean false
zResizable Whether panel can be resized boolean true
class Additional CSS classes to apply ClassValue ''

z-resizable-handleComponent

Draggable divider between panels.

PropertyDescriptionTypeDefault
zWithHandle Shows visual grip handle boolean false
zDisabled Disables resize functionality boolean false
zHandleIndex Index of the handle (auto-managed) number 0
class Additional CSS classes to apply ClassValue ''
github iconwhatsapp icondiscord iconX icon

Made with in Brazil. Open source and available on GitHub .