NV Elements Catalog Starters Repo System Themes About Getting Started Changelog Metrics Support Accessibility Contributions Requests Migration Deprecations Integrations Installation MCP CLI Lint Angular Bundles Extensions Go Hugo Import Maps Lit NextJS Nuxt Preact React SolidJS Svelte TypeScript Vue Foundations Typography Iconography Themes Design Tokens Size & Space Objects Interactions Support Status Color Animation Fonts Layers Custom Layout Horizontal Vertical Grid Popovers i18n Visualization View Transitions Elements Accordion Alert Avatar Badge Breadcrumb Button Button Group Card Chat Message Checkbox Color Combobox Copy Button Datagrid Integrations Column Action Column Alignment Column Fixed Column width Container Card Display Settings Footer Heatmap Keynav Multi Select Pagination Panel Detail Panel Grid Performance Placeholder Row Action Row Groups Row Sort Scroll Height Single Select Stripe Date Datetime Dialog Divider Dot Drawer Dropdown Dropdown Group Dropzone File Forms Validation Actions Control Icon Icon Button Input Input Group Logo Menu Month Notification Page Page Header Page Loader Pagination Panel Progressive Filter Chip Progress Bar Progress Ring Password Preferences Input Pulse Radio Range Resize Handle Search Select Skeleton Sort Button Sparkline Star Rating Steps Switch Tabs Tag Textarea Time Toast Toggletip Toolbar Tooltip Tree Week Patterns Authentication Browse Dashboard Editor Empty States Heatmap Keyboard Shortcut Logging Media Onboarding Panel Responsive Search Subheader Trend Code Codeblock Monaco Input Diff Input Editor Diff Editor Problems Markdown Markdown CSS Utility Labs Responsive Layout Viewport Container Patterns Forms API Design Properties & Attributes Slots Registration CustomEvents Stateless Composition Styles Packaging Glossary Logs Internal Guidelines Agent Harness Documentation Examples TypeScript Testing Unit Testing Accessibility Testing Lighthouse Testing SSR Testing Visual Testing Troubleshooting Component Creation Internal Examples All Examples

Horizontal Layout

Horizontal layouts support common UI patterns like navigation bars and button groups. The Elements horizontal layout system uses CSS Flexbox to create one-dimensional layouts that adapt to content and container constraints.

Deep dive into flexbox with the MDN Flexbox guide and this visual Flexbox Froggy game.

Understanding Horizontal Layout

Horizontal flexbox layouts distribute space along a single axis while maintaining alignment control. Unlike grid layouts that manage both dimensions, horizontal layouts focus on arranging items in a row with configurable spacing and alignment.

When to Use Horizontal Layout

Choose horizontal layout (row) for:

  • Navigation bars: Logo left, menu items right
  • Button groups: Actions that belong together
  • Toolbars: Icon buttons with consistent spacing
  • Form controls: Label and input on the same line
  • Card layouts: Side-by-side content cards
  • Media objects: Image with text alongside
  • Split layouts: Content on one side, actions on the other
Note: horizontal layouts work well for components that need to respond to available space. Items can wrap, stretch, or maintain fixed sizes while the layout handles spacing automatically.

Basic Setup

Set nve-layout="row" on a container element to create a horizontal layout:


    

Alignment Options

Horizontal layouts support alignment along both axes:

Primary Axis (Horizontal)

  • align:left - Items start from the left (default)
  • align:horizontal-center - Items centered horizontally
  • align:right - Items aligned to the right
  • align:space-between - Items spread with space between
  • align:space-around - Items spread with space around
  • align:space-evenly - Items spread with even spacing

Cross Axis (Vertical)

  • align:top - Items aligned to top
  • align:vertical-center - Items centered vertically
  • align:bottom - Items aligned to bottom
  • align:vertical-stretch - Items stretch to container height

Combined Alignment

  • align:center - Center both horizontally and vertically
  • align:stretch - Stretch in both dimensions
  • You can combine many values: align:vertical-center align:right

Special Options

  • align:wrap - Allow items to wrap to many lines when needed
Alignment mental model: think of horizontal layouts as having a main axis (left-to-right) and a cross axis (top-to-bottom). This helps predict how alignment values behave.

Horizontal Layout Examples


    

Align Left

Align Horizontal Center

Align Right

Align Vertical Center

Align Center

Align Vertical Center & Right

Align Left & Bottom

Align Horizontal Center & Bottom

Align Right & Bottom

Align Space Around

Align Space Between

Align Space Evenly

Align Stretch Horizontal

Align Stretch Vertical

Align Full Stretch

Align Wrap

Best Practices

  1. Use semantic HTML: Apply layouts to meaningful elements (<nav>, <header>, <section>)
  2. Let flexbox do the work: Avoid fixed widths unless necessary
  3. Consider mobile: Horizontal layouts may need to stack vertically on small screens
  4. Use gap for spacing: More maintainable than margins on individual items
  5. Combine alignments thoughtfully: Test how items behave with different content lengths
Accessibility note: ensure logical tab order when using visual reordering with flexbox. Screen readers follow DOM order, not visual order.

Next Steps