1 estrella en GitHub = 1 componente nuevo.

App y Dashboard appdashboardsaasbankfintechnavigationtab-barsidebarshell

Bank App Nav

Navegación del área de cliente: barra lateral con marca y medidor de reserva de impuestos en escritorio y barra de pestañas fija abajo en móvil. Sin JavaScript.

Vista Previa en Vivo

Uso

Copia y pega este código directamente en tu página de Astro:

astro
---
import { BankAppNav } from 'astro-component-kit/app';
---

<BankAppNav currentHref="/app" items={[{ label: 'Resumen', href: '/app', icon: 'home' }, { label: 'Tarjetas', href: '/app/tarjetas', icon: 'card' }]} />
--- import { BankAppNav } from 'astro-component-kit/app'; --- <BankAppNav currentHref="/app" items={[{ label: 'Resumen', href: '/app', icon: 'home' }, { label: 'Tarjetas', href: '/app/tarjetas', icon: 'card' }]} />

Ejemplos en contexto

Código real del kit: cómo se usa esta pieza dentro de plantillas, secciones y otros componentes.

Plantilla Cobre · Neobanco & Área de cliente BankAppLayout.astro
astro
<BankAppNav
  items={navItems}
  currentHref={routes[current] ?? routes.dashboard}
  brand="Cobre"
  homeHref={routes.home}
  goal={{ label: 'Reserva de impuestos', value: Math.round(reserve?.balance ?? 0), max: 4000 }}
/>
<BankAppNav items={navItems} currentHref={routes[current] ?? routes.dashboard} brand="Cobre" homeHref={routes.home} goal={{ label: 'Reserva de impuestos', value: Math.round(reserve?.balance ?? 0), max: 4000 }} />

Combina bien con

Instalación Manual

Si no estás usando el paquete npm, crea un archivo nuevo y pega el siguiente código: src/components/lib/BankAppNav.astro:

astro
---
/**
 * BankAppNav — Navigation for the account area: a vertical rail with the brand and a tax-reserve
 * meter on desktop, and a fixed bottom tab bar on phones. No JavaScript.
 *
 * @param {Array<{label: string, href: string, icon: string, badge?: string|number}>} items - Links (keep 3–5 for the tab bar).
 * @param {string} currentHref - Marks the matching link with aria-current="page".
 * @param {string} brand - Bank name (rail only).
 * @param {string} homeHref - Link for the brand.
 * @param {{label: string, value: number, max: number}} goal - Rail meter, e.g. tax reserve vs. target (EUR). Omit to hide.
 * @param {string} class - Extra class for the root.
 *
 * Accessibility: <nav> landmark with aria-label; aria-current on the active link; every tab
 * has a visible text label (icons aria-hidden); 56px tap targets on the tab bar; the goal
 * meter has a text alternative.
 */
import type { HTMLAttributes } from 'astro/types';
import '../templates/fintech/bank-theme.css';

interface Item { label: string; href: string; icon: string; badge?: string | number }

interface OwnProps {
  items?: Item[];
  currentHref?: string;
  brand?: string;
  homeHref?: string;
  goal?: { label: string; value: number; max: number };
}

type Props = OwnProps & Omit<HTMLAttributes<'nav'>, keyof OwnProps | 'class'> & { class?: string };

const {
  items = [
    { label: 'Resumen', href: '#', icon: 'home' },
    { label: 'Movimientos', href: '#movimientos', icon: 'list' },
    { label: 'Tarjetas', href: '#tarjetas', icon: 'card' },
  ],
  currentHref = '#',
  brand = 'Cobre',
  homeHref = '#',
  goal,
  class: classAttr,
  ...rest
} = Astro.props;

const icons: Record<string, string> = {
  home: '<path d="M3 11.5 12 4l9 7.5M5.5 10v9.5h13V10"/>',
  list: '<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/>',
  card: '<rect x="2" y="5" width="20" height="14" rx="3"/><path d="M2 10h20M6 15h4"/>',
  send: '<path d="m22 2-7 20-4-9-9-4z"/><path d="M22 2 11 13"/>',
  chart: '<path d="M4 20V10M10 20V4M16 20v-7M22 20H2"/>',
  mark: '<circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 1 0 18z" fill="currentColor"/>',
};
const isCurrent = (href: string) => href.replace(/\/$/, '') === currentHref.replace(/\/$/, '');
const pct = goal ? Math.min(100, Math.round((goal.value / goal.max) * 100)) : 0;
---

<nav class:list={['bank-ui', 'bank-nav', classAttr]} aria-label="Área de cliente" {...rest}>
  <a href={homeHref} class="bank-nav__brand">
    <span class="bank-nav__mark" aria-hidden="true">
      <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" set:html={icons.mark} />
    </span>
    <span class="bank-nav__brand-name">{brand}</span>
  </a>

  <ul class="bank-nav__list" role="list">
    {items.map((it) => (
      <li>
        <a href={it.href} class="bank-nav__link" aria-current={isCurrent(it.href) ? 'page' : undefined}>
          <span class="bank-nav__icon" aria-hidden="true">
            <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" set:html={icons[it.icon] ?? icons.list} />
            {it.badge !== undefined && it.badge !== 0 && <span class="bank-nav__badge">{it.badge}</span>}
          </span>
          <span class="bank-nav__label">
            {it.label}
            {it.badge !== undefined && it.badge !== 0 && <span class="bk-sr"> ({it.badge})</span>}
          </span>
        </a>
      </li>
    ))}
  </ul>

  {goal && (
    <div class="bank-nav__goal">
      <p><span>{goal.label}</span><strong>{goal.value.toLocaleString('es-ES')} €</strong></p>
      <span class="bank-nav__meter" role="img" aria-label={`${goal.label}: ${goal.value} de ${goal.max} euros`}><i style={`width:${pct}%`}></i></span>
    </div>
  )}
</nav>

<style>
  .bank-nav {
    color: var(--bk-text);
    font-family: var(--bk-font-body);
  }

  .bank-nav__list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .bank-nav__link {
    position: relative;
    display: flex;
    align-items: center;
    color: var(--bk-text-2);
    text-decoration: none;
    transition: color 0.2s ease, background 0.2s ease;
  }

  .bank-nav__link:hover {
    color: var(--bk-text);
  }

  .bank-nav__link:focus-visible,
  .bank-nav__brand:focus-visible {
    outline: 2px solid var(--bk-brand);
    outline-offset: 2px;
  }

  .bank-nav__icon {
    position: relative;
    display: grid;
    place-items: center;
  }

  .bank-nav__badge {
    position: absolute;
    top: -6px;
    right: -10px;
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--r-full, 999px);
    background: var(--bk-brand);
    color: var(--bk-on-brand);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
  }

  .bank-nav__brand {
    display: none;
    align-items: center;
    gap: var(--sp-2, 0.5rem);
    color: var(--bk-text);
    text-decoration: none;
  }

  .bank-nav__mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--bk-brand);
    color: var(--bk-on-brand);
  }

  .bank-nav__brand-name {
    font-family: var(--bk-font-display);
    font-size: 1.5rem;
    font-weight: 600;
  }

  .bank-nav__goal {
    display: none;
  }

  /* Phones & tablets: bottom tab bar */
  .bank-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    border-top: 1px solid var(--bk-border-strong);
    background: color-mix(in srgb, var(--bk-bg-raised) 94%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .bank-nav__list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
  }

  .bank-nav__link {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 60px;
    font-size: 0.72rem;
    font-weight: 600;
  }

  .bank-nav__link[aria-current='page'] {
    color: var(--bk-brand);
  }

  /* Desktop: vertical rail */
  @media (min-width: 960px) {
    .bank-nav {
      position: sticky;
      top: 0;
      inset: auto;
      display: flex;
      flex-direction: column;
      gap: var(--sp-6, 1.5rem);
      flex: none;
      width: 248px;
      height: 100vh;
      padding: var(--sp-6, 1.5rem) var(--sp-4, 1rem);
      border-top: 0;
      border-right: 1px solid var(--bk-border);
      background: var(--bk-bg-raised);
      backdrop-filter: none;
      box-sizing: border-box;
    }

    .bank-nav__brand {
      display: flex;
    }

    .bank-nav__list {
      display: grid;
      grid-auto-flow: row;
      grid-auto-columns: auto;
      gap: var(--sp-1, 0.25rem);
    }

    .bank-nav__link {
      flex-direction: row;
      justify-content: flex-start;
      gap: var(--sp-3, 0.75rem);
      min-height: 48px;
      padding: 0 var(--sp-3, 0.75rem);
      border-radius: var(--r-md, 12px);
      font-size: 0.95rem;
    }

    .bank-nav__link:hover {
      background: var(--bk-surface);
    }

    .bank-nav__link[aria-current='page'] {
      background: rgba(var(--bk-brand-rgb), 0.14);
      color: var(--bk-brand);
    }

    .bank-nav__goal {
      display: block;
      margin-top: auto;
      padding: var(--sp-4, 1rem);
      border: 1px solid var(--bk-border);
      border-radius: var(--r-lg, 20px);
      background: var(--bk-surface);
    }

    .bank-nav__goal p {
      display: flex;
      justify-content: space-between;
      gap: var(--sp-2, 0.5rem);
      margin: 0 0 var(--sp-2, 0.5rem);
      color: var(--bk-text-2);
      font-size: 0.82rem;
    }

    .bank-nav__goal strong {
      color: var(--bk-text);
    }

    .bank-nav__meter {
      display: block;
      height: 8px;
      overflow: hidden;
      border-radius: var(--r-full, 999px);
      background: var(--bk-surface-2);
    }

    .bank-nav__meter i {
      display: block;
      height: 100%;
      border-radius: inherit;
      background: linear-gradient(90deg, var(--bk-brand), var(--bk-violet));
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .bank-nav__link {
      transition: none;
    }
  }
</style>
--- /** * BankAppNav — Navigation for the account area: a vertical rail with the brand and a tax-reserve * meter on desktop, and a fixed bottom tab bar on phones. No JavaScript. * * @param {Array<{label: string, href: string, icon: string, badge?: string|number}>} items - Links (keep 3–5 for the tab bar). * @param {string} currentHref - Marks the matching link with aria-current="page". * @param {string} brand - Bank name (rail only). * @param {string} homeHref - Link for the brand. * @param {{label: string, value: number, max: number}} goal - Rail meter, e.g. tax reserve vs. target (EUR). Omit to hide. * @param {string} class - Extra class for the root. * * Accessibility: <nav> landmark with aria-label; aria-current on the active link; every tab * has a visible text label (icons aria-hidden); 56px tap targets on the tab bar; the goal * meter has a text alternative. */ import type { HTMLAttributes } from 'astro/types'; import '../templates/fintech/bank-theme.css'; interface Item { label: string; href: string; icon: string; badge?: string | number } interface OwnProps { items?: Item[]; currentHref?: string; brand?: string; homeHref?: string; goal?: { label: string; value: number; max: number }; } type Props = OwnProps & Omit<HTMLAttributes<'nav'>, keyof OwnProps | 'class'> & { class?: string }; const { items = [ { label: 'Resumen', href: '#', icon: 'home' }, { label: 'Movimientos', href: '#movimientos', icon: 'list' }, { label: 'Tarjetas', href: '#tarjetas', icon: 'card' }, ], currentHref = '#', brand = 'Cobre', homeHref = '#', goal, class: classAttr, ...rest } = Astro.props; const icons: Record<string, string> = { home: '<path d="M3 11.5 12 4l9 7.5M5.5 10v9.5h13V10"/>', list: '<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/>', card: '<rect x="2" y="5" width="20" height="14" rx="3"/><path d="M2 10h20M6 15h4"/>', send: '<path d="m22 2-7 20-4-9-9-4z"/><path d="M22 2 11 13"/>', chart: '<path d="M4 20V10M10 20V4M16 20v-7M22 20H2"/>', mark: '<circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 1 0 18z" fill="currentColor"/>', }; const isCurrent = (href: string) => href.replace(/\/$/, '') === currentHref.replace(/\/$/, ''); const pct = goal ? Math.min(100, Math.round((goal.value / goal.max) * 100)) : 0; --- <nav class:list={['bank-ui', 'bank-nav', classAttr]} aria-label="Área de cliente" {...rest}> <a href={homeHref} class="bank-nav__brand"> <span class="bank-nav__mark" aria-hidden="true"> <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" set:html={icons.mark} /> </span> <span class="bank-nav__brand-name">{brand}</span> </a> <ul class="bank-nav__list" role="list"> {items.map((it) => ( <li> <a href={it.href} class="bank-nav__link" aria-current={isCurrent(it.href) ? 'page' : undefined}> <span class="bank-nav__icon" aria-hidden="true"> <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" set:html={icons[it.icon] ?? icons.list} /> {it.badge !== undefined && it.badge !== 0 && <span class="bank-nav__badge">{it.badge}</span>} </span> <span class="bank-nav__label"> {it.label} {it.badge !== undefined && it.badge !== 0 && <span class="bk-sr"> ({it.badge})</span>} </span> </a> </li> ))} </ul> {goal && ( <div class="bank-nav__goal"> <p><span>{goal.label}</span><strong>{goal.value.toLocaleString('es-ES')} €</strong></p> <span class="bank-nav__meter" role="img" aria-label={`${goal.label}: ${goal.value} de ${goal.max} euros`}><i style={`width:${pct}%`}></i></span> </div> )} </nav> <style> .bank-nav { color: var(--bk-text); font-family: var(--bk-font-body); } .bank-nav__list { margin: 0; padding: 0; list-style: none; } .bank-nav__link { position: relative; display: flex; align-items: center; color: var(--bk-text-2); text-decoration: none; transition: color 0.2s ease, background 0.2s ease; } .bank-nav__link:hover { color: var(--bk-text); } .bank-nav__link:focus-visible, .bank-nav__brand:focus-visible { outline: 2px solid var(--bk-brand); outline-offset: 2px; } .bank-nav__icon { position: relative; display: grid; place-items: center; } .bank-nav__badge { position: absolute; top: -6px; right: -10px; min-width: 18px; padding: 0 5px; border-radius: var(--r-full, 999px); background: var(--bk-brand); color: var(--bk-on-brand); font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center; } .bank-nav__brand { display: none; align-items: center; gap: var(--sp-2, 0.5rem); color: var(--bk-text); text-decoration: none; } .bank-nav__mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--bk-brand); color: var(--bk-on-brand); } .bank-nav__brand-name { font-family: var(--bk-font-display); font-size: 1.5rem; font-weight: 600; } .bank-nav__goal { display: none; } /* Phones & tablets: bottom tab bar */ .bank-nav { position: fixed; inset: auto 0 0 0; z-index: 50; border-top: 1px solid var(--bk-border-strong); background: color-mix(in srgb, var(--bk-bg-raised) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding-bottom: env(safe-area-inset-bottom, 0); } .bank-nav__list { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; } .bank-nav__link { flex-direction: column; justify-content: center; gap: 2px; min-height: 60px; font-size: 0.72rem; font-weight: 600; } .bank-nav__link[aria-current='page'] { color: var(--bk-brand); } /* Desktop: vertical rail */ @media (min-width: 960px) { .bank-nav { position: sticky; top: 0; inset: auto; display: flex; flex-direction: column; gap: var(--sp-6, 1.5rem); flex: none; width: 248px; height: 100vh; padding: var(--sp-6, 1.5rem) var(--sp-4, 1rem); border-top: 0; border-right: 1px solid var(--bk-border); background: var(--bk-bg-raised); backdrop-filter: none; box-sizing: border-box; } .bank-nav__brand { display: flex; } .bank-nav__list { display: grid; grid-auto-flow: row; grid-auto-columns: auto; gap: var(--sp-1, 0.25rem); } .bank-nav__link { flex-direction: row; justify-content: flex-start; gap: var(--sp-3, 0.75rem); min-height: 48px; padding: 0 var(--sp-3, 0.75rem); border-radius: var(--r-md, 12px); font-size: 0.95rem; } .bank-nav__link:hover { background: var(--bk-surface); } .bank-nav__link[aria-current='page'] { background: rgba(var(--bk-brand-rgb), 0.14); color: var(--bk-brand); } .bank-nav__goal { display: block; margin-top: auto; padding: var(--sp-4, 1rem); border: 1px solid var(--bk-border); border-radius: var(--r-lg, 20px); background: var(--bk-surface); } .bank-nav__goal p { display: flex; justify-content: space-between; gap: var(--sp-2, 0.5rem); margin: 0 0 var(--sp-2, 0.5rem); color: var(--bk-text-2); font-size: 0.82rem; } .bank-nav__goal strong { color: var(--bk-text); } .bank-nav__meter { display: block; height: 8px; overflow: hidden; border-radius: var(--r-full, 999px); background: var(--bk-surface-2); } .bank-nav__meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--bk-brand), var(--bk-violet)); } } @media (prefers-reduced-motion: reduce) { .bank-nav__link { transition: none; } } </style>

Información Rápida

Categoría
App y Dashboard
Nombre de archivo
BankAppNav.astro
Dependencias
Ninguna — Astro nativo + CSS puro
Etiquetas
appdashboardsaasbankfintechnavigationtab-barsidebarshell