Angular playground

Nova v3.38.0

Preview

Angular

Stack to Tailwind

Replacing the deprecated stack with Tailwind's flex utilities, property by property.

← nv-stack

The Stack component is being deprecated in favour of Tailwind CSS utility classes. This guide will help you migrate your existing Stack components to their Tailwind equivalents.

Why It’s Discontinued#

The decision to discontinue the nv-stack component is based on several factors:

  • Flexibility: Tailwind CSS offers a utility-first approach, allowing for more granular control over styling without the need for custom components.
  • Consistency: By using Tailwind CSS, we ensure a consistent styling approach across all elements, reducing the need for component-specific styles.
  • Maintenance: Reducing the number of custom components simplifies the codebase, making it easier to maintain and update.

Component Migrations#

Basic Stack with Fill#

html<NVStack Fill Gutter="2" Padding="4" Height="200px">
  <NVPanel>Panel</NVPanel>
  <NVPanel>Panel</NVPanel>
  <NVPanel>Panel</NVPanel>
</NVStack>
html<div class="flex h-full space-x-2 p-4" style="height:200px">
  <div class="h-full">Panel</div>
  <div class="h-full">Panel</div>
  <div class="h-full">Panel</div>
</div>

Vertical Stack with Fill#

html<NVStack Fill Vertical Gutter="2" Padding="4">
  <NVPanel>Panel</NVPanel>
  <NVPanel>Panel</NVPanel>
  <NVPanel>Panel</NVPanel>
</NVStack>
html<div class="flex flex-col w-full space-y-2 p-4">
  <div class="w-full">Panel</div>
  <div class="w-full">Panel</div>
  <div class="w-full">Panel</div>
</div>

Flex Stack#

html<NVStack Flex Gutter="2" Padding="4">
  <NVPanel>Panel</NVPanel>
  <NVPanel>Panel</NVPanel>
  <NVPanel>Panel</NVPanel>
</NVStack>
html<div class="flex space-x-2 p-4">
  <div class="flex-1">Panel</div>
  <div class="flex-1">Panel</div>
  <div class="flex-1">Panel</div>
</div>

Stack with Lead/Tail Items#

html<NVStack Gutter="2" Padding="3">
  <NVPanel StackItemLead>Panel</NVPanel>
  <NVStackItemFlex>
    <NVPanel>Panel</NVPanel>
  </NVStackItemFlex>
  <NVPanel StackItemTail>Panel</NVPanel>
</NVStack>
html<div class="flex items-center space-x-2 p-3">
  <div class="justify-start">Panel</div>
  <div class="flex-1">Panel</div>
  <div class="justify-end">Panel</div>
</div>

Property Mapping Table#

Nova V2 Stack PropertyTailwind CSS Class
Fillh-full (horizontal) or w-full (vertical)
Flexflex-1
Fullw-full
Verticalflex flex-col
Gutter="2"space-x-2 (horizontal) or space-y-2 (vertical)
StackItemLeadjustify-start
StackItemTailjustify-end
StackItemFlexflex-1

Important Notes#

  1. The Gutter property translates to:
  2. When using Fill:
  3. Stack container always needs flex as base class
  4. For vertical stacks, always add flex-col to the container

Migration Steps#

  1. Replace all NVStack components with div elements
  2. Add base flex class to all stack containers
  3. Convert properties using the mapping table above
  4. Replace all NVPanel components with appropriate elements
  5. Test layout and spacing after conversion

This migration guide provides direct mappings from the actual Nova Stack implementation to Tailwind CSS classes. For complex layouts, you may need to combine multiple Tailwind utilities to achieve the exact same behaviour.

  1. space-x-{size} for horizontal stacks
  2. space-y-{size} for vertical stacks
  3. In horizontal stacks, children get h-full
  4. In vertical stacks, children get w-full