Skip to content
ui8kit

component / components

Nav Actions

Nav Actions component

Install

npx ui8kit add nav-actions

Pulls in: button, compose, kit-button, utils

Preview

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add nav-actions
components/nav-actions.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the
  press). No wrapper: they sit in the row of the bar.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type NavActionsProps = {
    login?: string;
    loginHref?: string;
    cta?: string;
    ctaHref?: string;
    actions?: "none" | "cta";
    tone?: "default" | "inverse";
    themeLabel?: string;
    ontheme?: () => void;
  };
</script>

<script lang="ts">
  import Button from "../compose/Button.svelte";
  import { urlOf } from "../utils";

  let {
    login,
    loginHref,
    cta,
    ctaHref,
    actions = "cta",
    tone = "default",
    themeLabel,
    ontheme,
  }: NavActionsProps = $props();
</script>

{#if login}
  <Button
    variant="ghost"
    size="sm"
    href={urlOf(loginHref)}
    class={(((tone as string) === "inverse") ? "text-background hover:bg-background/10" : "")}
  >
    {login}
  </Button>
{/if}
{#if (((actions as string) === "cta") && cta)}
  <Button variant={(((tone as string) === "inverse") ? "secondary" : "default")} size="sm" href={urlOf(ctaHref)}>
    {cta}
  </Button>
{/if}
{#if themeLabel}
  <Button variant="outline" size="sm" onclick={() => ontheme?.()}>
    {themeLabel}
  </Button>
{/if}

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add nav-actions
components/nav-actions.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the
 * press). No wrapper: they sit in the row of the bar.
 */
import { type ReactNode } from "react";
import { Button } from "../compose";
import { urlOf } from "../utils";

export type NavActionsProps = {
  login?: string;
  loginHref?: string;
  cta?: string;
  ctaHref?: string;
  actions?: "none" | "cta";
  tone?: "default" | "inverse";
  themeLabel?: string;
  onTheme?: () => void;
};

export function NavActions({
  login,
  loginHref,
  cta,
  ctaHref,
  actions = "cta",
  tone = "default",
  themeLabel,
  onTheme,
}: NavActionsProps) {
  return (
    <>
      {login ? (
        <Button
          variant="ghost"
          size="sm"
          href={urlOf(loginHref)}
          className={(((tone as string) === "inverse") ? "text-background hover:bg-background/10" : "")}
        >
          {login}
        </Button>
      ) : null}
      {(((actions as string) === "cta") && cta) ? (
        <Button variant={(((tone as string) === "inverse") ? "secondary" : "default")} size="sm" href={urlOf(ctaHref)}>
          {cta}
        </Button>
      ) : null}
      {themeLabel ? (
        <Button variant="outline" size="sm" onClick={() => onTheme?.()}>
          {themeLabel}
        </Button>
      ) : null}
    </>
  );
}

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add nav-actions
components/nav-actions.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the
  press). No wrapper: they sit in the row of the bar.
-->
<script lang="ts">
export type NavActionsProps = {
  login?: string;
  loginHref?: string;
  cta?: string;
  ctaHref?: string;
  actions?: "none" | "cta";
  tone?: "default" | "inverse";
  themeLabel?: string;
};
</script>

<script setup lang="ts">
import Button from "../compose/Button.vue";
import { urlOf } from "../utils";

const {
  login,
  loginHref,
  cta,
  ctaHref,
  actions = "cta",
  tone = "default",
  themeLabel,
} = defineProps<NavActionsProps>();
const emit = defineEmits<{ theme: [] }>();
</script>

<template>
  <Button v-if="login"
    variant="ghost"
    size="sm"
    :href="urlOf(loginHref)"
    :class="(((tone as string) === 'inverse') ? 'text-background hover:bg-background/10' : '')"
  >
    {{ login }}
  </Button>
  <Button v-if="(((actions as string) === 'cta') && cta)"
    :variant="(((tone as string) === 'inverse') ? 'secondary' : 'default')"
    size="sm"
    :href="urlOf(ctaHref)"
  >
    {{ cta }}
  </Button>
  <Button v-if="themeLabel" variant="outline" size="sm" @click="() => emit('theme')">
    {{ themeLabel }}
  </Button>
</template>

Vue registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdn
npx ui8kit add nav-actions
components/nav-actions.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the
 * press). No wrapper: they sit in the row of the bar.
 */
import { type JSX } from "solid-js";
import { Button } from "../compose";
import { urlOf } from "../utils";

export type NavActionsProps = {
  login?: string;
  loginHref?: string;
  cta?: string;
  ctaHref?: string;
  actions?: "none" | "cta";
  tone?: "default" | "inverse";
  themeLabel?: string;
  onTheme?: () => void;
};

export function NavActions({
  login,
  loginHref,
  cta,
  ctaHref,
  actions = "cta",
  tone = "default",
  themeLabel,
  onTheme,
}: NavActionsProps) {
  return (
    <>
      {login ? (
        <Button
          variant="ghost"
          size="sm"
          href={urlOf(loginHref)}
          class={(((tone as string) === "inverse") ? "text-background hover:bg-background/10" : "")}
        >
          {login}
        </Button>
      ) : null}
      {(((actions as string) === "cta") && cta) ? (
        <Button variant={(((tone as string) === "inverse") ? "secondary" : "default")} size="sm" href={urlOf(ctaHref)}>
          {cta}
        </Button>
      ) : null}
      {themeLabel ? (
        <Button variant="outline" size="sm" onClick={() => onTheme?.()}>
          {themeLabel}
        </Button>
      ) : null}
    </>
  );
}

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add nav-actions
blocks/nav-actions.templ
// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/organisms/nav-actions.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/button"
	"github.com/ui8kit/codegen/generated/templ/compose"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// NavActionsProps are the props of NavActions; the values are the JSON shapes of the TypeScript props.
type NavActionsProps struct {
	Login any `json:"login"`
	LoginHref any `json:"loginHref"`
	Cta any `json:"cta"`
	CtaHref any `json:"ctaHref"`
	Actions any `json:"actions"`
	Tone any `json:"tone"`
	ThemeLabel any `json:"themeLabel"`
}

// The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the press). No wrapper: they sit in the row of the bar.
templ NavActions(p NavActionsProps) {
	{{ vLogin := p.Login }}
	{{ vLoginHref := p.LoginHref }}
	{{ vCta := p.Cta }}
	{{ vCtaHref := p.CtaHref }}
	{{ vActions := uiutils.Def(p.Actions, "cta") }}
	{{ vTone := uiutils.Def(p.Tone, "default") }}
	{{ vThemeLabel := p.ThemeLabel }}
	if uiutils.T(vLogin) {
		@compose.Button(compose.ButtonProps{Variant: "ghost", Size: "sm", ButtonProps: button.ButtonProps{Href: uiutils.URL(vLoginHref, false), Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vTone, "inverse")), "text-background hover:bg-background/10", ""))}}) {
			{ uiutils.Text(vLogin) }
		}
	}
	if uiutils.T(uiutils.And(uiutils.Eq(vActions, "cta"), vCta)) {
		@compose.Button(compose.ButtonProps{Variant: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vTone, "inverse")), "secondary", "default")), Size: "sm", ButtonProps: button.ButtonProps{Href: uiutils.URL(vCtaHref, false)}}) {
			{ uiutils.Text(vCta) }
		}
	}
	if uiutils.T(vThemeLabel) {
		@compose.Button(compose.ButtonProps{Variant: "outline", Size: "sm", ButtonProps: button.ButtonProps{}}) {
			{ uiutils.Text(vThemeLabel) }
		}
	}
}

templ registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdn
npx ui8kit add nav-actions
blocks/nav-actions.html.twig
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/organisms/nav-actions.json
    The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the press). No wrapper: they sit in the row of the bar.
    Props (p): login, loginHref, cta, ctaHref, actions, tone, themeLabel. -#}
{%- set v_login = (p.login ?? null) -%}
{%- set v_loginHref = (p.loginHref ?? null) -%}
{%- set v_cta = (p.cta ?? null) -%}
{%- set v_ctaHref = (p.ctaHref ?? null) -%}
{%- set v_actions = (p.actions ?? 'cta') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_themeLabel = (p.themeLabel ?? null) -%}
{%- if og_t(v_login) %}
  {%- set c_1 -%}
    {{ og_text(v_login) }}
  {%- endset -%}
  {{ include('compose/Button.html.twig', {'variant': 'ghost', 'size': 'sm', 'href': og_url(og_s(v_loginHref)), 'class': og_s((og_t(og_eq(v_tone, 'inverse')) ? 'text-background hover:bg-background/10' : '')), 'children': c_1}, with_context = false) }}
{%- endif %}
{%- if og_t(og_and([og_eq(v_actions, 'cta'), v_cta])) %}
  {%- set c_2 -%}
    {{ og_text(v_cta) }}
  {%- endset -%}
  {{ include('compose/Button.html.twig', {'variant': og_s((og_t(og_eq(v_tone, 'inverse')) ? 'secondary' : 'default')), 'size': 'sm', 'href': og_url(og_s(v_ctaHref)), 'children': c_2}, with_context = false) }}
{%- endif %}
{%- if og_t(v_themeLabel) %}
  {%- set c_3 -%}
    {{ og_text(v_themeLabel) }}
  {%- endset -%}
  {{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'sm', 'children': c_3}, with_context = false) }}
{%- endif %}

Twig registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdn
npx ui8kit add nav-actions
blocks/nav-actions.latte
{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/organisms/nav-actions.json
    The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the press). No wrapper: they sit in the row of the bar.
    Props (p): login, loginHref, cta, ctaHref, actions, tone, themeLabel. *}
{var $v_login = ($p['login'] ?? null)}
{var $v_loginHref = ($p['loginHref'] ?? null)}
{var $v_cta = ($p['cta'] ?? null)}
{var $v_ctaHref = ($p['ctaHref'] ?? null)}
{var $v_actions = ($p['actions'] ?? 'cta')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_themeLabel = ($p['themeLabel'] ?? null)}
{if og_t($v_login)}
  {capture $c_1}
    {=og_text($v_login)}
  {/capture}
  {=og_include('compose/Button.latte', ['variant' => 'ghost', 'size' => 'sm', 'href' => og_url(og_s($v_loginHref)), 'class' => og_s((og_t(og_eq($v_tone, 'inverse')) ? 'text-background hover:bg-background/10' : '')), 'children' => (string) $c_1])|noescape}
{/if}
{if og_t(og_and([og_eq($v_actions, 'cta'), $v_cta]))}
  {capture $c_2}
    {=og_text($v_cta)}
  {/capture}
  {=og_include('compose/Button.latte', ['variant' => og_s((og_t(og_eq($v_tone, 'inverse')) ? 'secondary' : 'default')), 'size' => 'sm', 'href' => og_url(og_s($v_ctaHref)), 'children' => (string) $c_2])|noescape}
{/if}
{if og_t($v_themeLabel)}
  {capture $c_3}
    {=og_text($v_themeLabel)}
  {/capture}
  {=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'sm', 'children' => (string) $c_3])|noescape}
{/if}

Latte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdn
npx ui8kit add nav-actions
blocks/nav-actions.html.j2
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/organisms/nav-actions.json
    The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the press). No wrapper: they sit in the row of the bar.
    Props (p): login, loginHref, cta, ctaHref, actions, tone, themeLabel. -#}
{%- set v_login = og_def(p['login'], none) -%}
{%- set v_loginHref = og_def(p['loginHref'], none) -%}
{%- set v_cta = og_def(p['cta'], none) -%}
{%- set v_ctaHref = og_def(p['ctaHref'], none) -%}
{%- set v_actions = og_def(p['actions'], 'cta') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_themeLabel = og_def(p['themeLabel'], none) -%}
{%- if og_t(v_login) %}
  {%- set c_1 -%}
    {{ og_text(v_login) }}
  {%- endset -%}
  {{ og_include('compose/button.html.j2', {'p': {'Variant': 'ghost', 'Size': 'sm', 'Href': og_url(og_s(v_loginHref)), 'Class': og_s(('text-background hover:bg-background/10' if og_t(og_eq(v_tone, 'inverse')) else ''))}, 'children': c_1}) }}
{%- endif %}
{%- if og_t(og_and([og_eq(v_actions, 'cta'), v_cta])) %}
  {%- set c_2 -%}
    {{ og_text(v_cta) }}
  {%- endset -%}
  {{ og_include('compose/button.html.j2', {'p': {'Variant': og_s(('secondary' if og_t(og_eq(v_tone, 'inverse')) else 'default')), 'Size': 'sm', 'Href': og_url(og_s(v_ctaHref))}, 'children': c_2}) }}
{%- endif %}
{%- if og_t(v_themeLabel) %}
  {%- set c_3 -%}
    {{ og_text(v_themeLabel) }}
  {%- endset -%}
  {{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm'}, 'children': c_3}) }}
{%- endif %}

Jinja2 registry item (JSON)

Props

Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.

The buttons at the end of a top bar: login, the call to action and the theme button (it only reports the press). No wrapper: they sit in the row of the bar.

Props of NavActions
PropTypeDefault Description
login string-text of the login link; none: no login
loginHref string-the address of the login page; none: the login is a button with no address
cta string-
ctaHref string-
actions "none" | "cta""cta"
tone "default" | "inverse""default"
themeLabel string-text of the theme button; none: no button

Used in