Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Clera Docs
Clera Docs

Introduction

  • 🎯 What is Clera?
  • 🧭 The Clera Experience
  • 🎨 Design Philosophy
  • πŸ’‘ Why Clera?
  • πŸ”§ Runtime, Not Framework

Getting Started

  • πŸ“¦ Installation
  • πŸš€ Your First App
  • βš™οΈ How Clera Works
  • πŸ—‚οΈ Project Structure
  • πŸ–₯️ Running and Preview

Core Concepts

  • πŸ—οΈ The App Tag
  • πŸ“„ The Page Tag
  • 🧭 Navigation
  • ⚑ Actions
  • πŸ”„ Lifecycle
  • 🎯 context: The Action Object
  • πŸ“ Forms and Values
  • πŸ–₯️ Rendering Helpers
  • πŸ’Ύ Persist Page
  • πŸ—„οΈ Data System
  • ⚑ Async Helpers
  • 🧩 Reusable Blocks
  • πŸ“¦ Splitting Your App Across Files
  • 🧠 Memory
  • πŸ‘‚ Page Listeners
  • 🧭 Nav
  • πŸ“‚ Sidebar
  • πŸ“‘ Tab Bar
  • πŸ‘† Gestures

Styling

  • 🎨 Styling in Clera
  • 🏷️ Custom Tags and CSS
  • πŸ“ Layout Patterns
  • πŸ“± Responsive Behavior
  • 🎨 Baseline CSS

Runtime API

  • 🌐 CLERA Global
  • πŸš€ app.start(config?)
  • βš™οΈ app.config(config)
  • β™Ώ Accessibility
  • βš™οΈ app.page(name, config)
  • 🧭 app.navigate(name, params?)
  • πŸ“ app.currentPage() and app.layout()
  • πŸ“± app.hardware
  • βš™οΈ app.sw: Service Worker
  • 🌐 app.php(url, data?, options?): HTTP POST Helper
  • 🎯 app.diagnostics: Runtime Log Buffer
  • πŸ”Œ Plugins
  • 🧱 Components

Routing

  • 🧭 Built-in Routing
  • πŸ’Ύ Persisted Page Routing
  • 🧭 External Router Overview

Native Features

  • πŸŒ‰ Bridge Overview
  • πŸ“³ Vibration
  • πŸ“‹ Clipboard
  • πŸ“€ Share
  • πŸ“· Camera
  • πŸ“ Location
  • πŸ“ File Pick
  • πŸ’Ύ File Save

Clera Language

  • πŸ“ The Clera Language
  • πŸ“ Writing .clera Files
  • ⚠️ Clera Language Errors

Production

  • πŸš€ Production Readiness
  • ⚑ Performance Guidelines
  • πŸ” Debugging
  • ⚠️ Error Handling and Security
  • πŸš€ Deployment

Examples

  • πŸ‘‹ Hello World
  • πŸ”’ Counter
  • βœ… Task List
  • πŸ“‘ Tabs App
  • πŸ“ Notes App
  • πŸ“ Form Handling
  • πŸ“Š Dashboard
  • πŸ’¬ Chat UI
  • πŸ’‘ Example: Product List

AI

  • πŸ€– Clera and AI
  • πŸ€– Master Build Prompt
  • πŸ€– Rules for AI
  • πŸ€– Component Generation and App Scaffolding Prompts

Reference

  • πŸ“‹ HTML Attribute Reference
  • 🎯 context Reference
  • πŸ”„ Lifecycle and Action Resolution Reference
  • βš™οΈ Config Reference
  • ⚠️ Error Codes
  • πŸ“… Version History
Back to top
View this page

πŸ“‚ SidebarΒΆ

<sidebar> is a fixed panel that overlays the left or right edge of the app. It is independent of <nav> and does not reposition based on layout. Use it for drawers, menus, and secondary panels that slide in from the side.


πŸ“‹ Basic structureΒΆ

Place <sidebar> as a direct child of <app>, at the same level as your pages.

<app>
  <sidebar id="mainSidebar">
    <tab page="home">Home</tab>
    <tab page="settings">Settings</tab>
    <tab action="logout">Log out</tab>
  </sidebar>

  <page name="home">...</page>
  <page name="settings">...</page>
</app>

<sidebar> must be a direct child of <app>. It does not reposition at different layouts. Position it once using the position attribute.


πŸ“ PositionΒΆ

Attribute

Value

Result

position

"left" or absent

Fixed to the left edge

position

"right"

Fixed to the right edge

<!-- Left sidebar (default) -->
<sidebar>...</sidebar>

<!-- Right sidebar -->
<sidebar position="right">...</sidebar>

πŸ”— Navigation itemsΒΆ

Use <tab> elements inside <sidebar>. Tabs with a page attribute navigate to that page when clicked. Tabs with an action attribute fire an action.

<sidebar id="appDrawer">
  <tab page="home">Home</tab>
  <tab page="profile">My Profile</tab>
  <tab page="settings">Settings</tab>
  <tab action="openHelp">Help</tab>
</sidebar>

🎨 Styling sidebar¢

<sidebar> is positioned fixed by default, spanning the full height of the screen. Set a width and background to make it visible.

sidebar {
  width: 280px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  padding: 20px 0;
}

sidebar tab {
  padding: 12px 20px;
  font-size: 16px;
  cursor: pointer;
}

sidebar tab:hover {
  background: #f5f5f5;
}

For a right-positioned sidebar:

sidebar[position="right"] {
  border-right: none;
  border-left: 1px solid #e0e0e0;
}

↕️ Collapsed stateΒΆ

Like <nav>, <sidebar> supports a collapsed state. Use [collapsed] in CSS to control the collapsed appearance.

sidebar {
  width: 280px;
  transition: width 0.2s ease;
}

sidebar[collapsed] {
  width: 0;
  overflow: hidden;
}

Toggle the collapsed state using the same API methods used for nav:

app.expand("#appDrawer");    // removes [collapsed]
app.collapse("#appDrawer");  // adds [collapsed]
app.toggle("#appDrawer");    // flips between the two

A common pattern is to start the sidebar collapsed and open it on a button press:

<page name="home" id="home">
  <button action="openSidebar">Menu</button>
  ...
</page>
function openSidebar() {
  app.expand("#appDrawer");
}

πŸ” Using sidebar with layoutΒΆ

<sidebar> does not reposition automatically. Use app[media~="..."] or app[layout="..."] in CSS to control its visibility or size at different breakpoints.

/* Hidden on mobile, visible on tablet and up */
app[layout="mobile"] sidebar {
  display: none;
}

/* On desktop, always show it expanded */
app[layout="desktop"] sidebar {
  width: 260px;
}

NextΒΆ

01 Styling in Clera

Next
πŸ“‘ Tab Bar
Previous
🧭 Nav
Copyright © Clera
Made with Sphinx and @pradyunsg's Furo
On this page
  • πŸ“‚ Sidebar
    • πŸ“‹ Basic structure
    • πŸ“ Position
    • πŸ”— Navigation items
    • 🎨 Styling sidebar
    • ↕️ Collapsed state
    • πŸ” Using sidebar with layout
    • Next