Run the CLI
Use the CLI to add the component to your project.
npx @ngzard/ui add resizable
A resizable layout component that allows users to resize panels by dragging dividers between them.
import { Component } from '@angular/core';
import { ZardResizableHandleComponent } from '../resizable-handle.component';
import { ZardResizablePanelComponent } from '../resizable-panel.component';
import { ZardResizableComponent } from '../resizable.component';
@Component({
selector: 'z-demo-resizable-default',
standalone: true,
imports: [ZardResizableComponent, ZardResizablePanelComponent, ZardResizableHandleComponent],
template: `
<z-resizable class="max-w-md w-[500px] h-[200px] rounded-lg border">
<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 />
<z-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Two</span>
</div>
</z-resizable-panel>
</z-resizable>
`,
})
export class ZardDemoResizableDefaultComponent {}
Use the CLI to add the component to your project.
npx @ngzard/ui add resizable
Create the component directory structure and add the following files to your project.
import { Component } from '@angular/core';
import { ZardResizableHandleComponent } from '../resizable-handle.component';
import { ZardResizablePanelComponent } from '../resizable-panel.component';
import { ZardResizableComponent } from '../resizable.component';
@Component({
selector: 'z-demo-resizable-default',
standalone: true,
imports: [ZardResizableComponent, ZardResizablePanelComponent, ZardResizableHandleComponent],
template: `
<z-resizable class="max-w-md w-[500px] h-[200px] rounded-lg border">
<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 />
<z-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Two</span>
</div>
</z-resizable-panel>
</z-resizable>
`,
})
export class ZardDemoResizableDefaultComponent {}
import { Component } from '@angular/core';
import { ZardResizableHandleComponent } from '../resizable-handle.component';
import { ZardResizablePanelComponent } from '../resizable-panel.component';
import { ZardResizableComponent } from '../resizable.component';
@Component({
selector: 'z-demo-resizable-vertical',
standalone: true,
imports: [ZardResizableComponent, ZardResizablePanelComponent, ZardResizableHandleComponent],
template: `
<z-resizable zLayout="vertical" class="h-[400px] w-[500px] max-w-md rounded-lg border">
<z-resizable-panel [zDefaultSize]="25">
<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]="true" />
<z-resizable-panel [zDefaultSize]="75">
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Two</span>
</div>
</z-resizable-panel>
</z-resizable>
`,
})
export class ZardDemoResizableVerticalComponent {}
import { Component } from '@angular/core';
import { ZardResizableHandleComponent } from '../resizable-handle.component';
import { ZardResizablePanelComponent } from '../resizable-panel.component';
import { ZardResizableComponent } from '../resizable.component';
@Component({
selector: 'z-demo-resizable-with-min-max',
standalone: true,
imports: [ZardResizableComponent, ZardResizablePanelComponent, ZardResizableHandleComponent],
template: `
<div class="space-y-4">
<z-resizable class="max-w-md w-[500px] rounded-lg border">
<z-resizable-panel [zDefaultSize]="25" zMin="0" zMax="40%">
<div class="flex h-[200px] items-center justify-center p-6">
<span class="font-semibold">One</span>
</div>
</z-resizable-panel>
<z-resizable-handle zWithHandle />
<z-resizable-panel [zDefaultSize]="75" [zMin]="'100px'">
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Two</span>
</div>
</z-resizable-panel>
</z-resizable>
</div>
`,
})
export class ZardDemoResizableWithMinMaxComponent {}