Skip to content
ui8kit

component / components

Post Actions

Post Actions component

Install

npx ui8kit add post-actions

Pulls in: button, compose, group, kit-box, kit-button, lucide-icon, post-card, post-split, 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 post-actions
components/post-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 calls to action of a post header: share and save side by side, one wide read button, or a wide read button
  with share and save as icons.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Post } from "../blocks/post-card.types";
  import type { PostExtras, PostSplitLabels } from "../blocks/post-split.types";

  export type PostActionsProps = {
    labels: PostSplitLabels;
    mode?: "pair" | "wide" | "icons";
  };
</script>

<script lang="ts">
  import Button from "../compose/Button.svelte";
  import Group from "../compose/Group.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";

  let { labels, mode = "pair" }: PostActionsProps = $props();
</script>

{#if ((mode as string) === "pair")}
  <Group gap="2" class="flex-wrap" data-slot="post-actions">
    <Button variant="default" size="default" class="gap-2">
      <LucideIcon name="share-2" size={16} />
      {labels.share}
    </Button>
    <Button variant="outline" size="default" class="gap-2">
      <LucideIcon name="bookmark" size={16} />
      {labels.save}
    </Button>
  </Group>
{:else}
  <Group gap="2" data-slot="post-actions">
    <Button variant="default" size="default" class="gap-2 flex-1">
      <LucideIcon name="book-open" size={16} />
      {labels.read}
    </Button>
    {#if ((mode as string) === "icons")}
      <Button variant="outline" size="default" layout="icon" aria-label={labels.share}>
        <LucideIcon name="share-2" size={16} />
      </Button>
      <Button variant="outline" size="default" layout="icon" aria-label={labels.save}>
        <LucideIcon name="bookmark" size={16} />
      </Button>
    {/if}
  </Group>
{/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 post-actions
components/post-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 calls to action of a post header: share and save side by side, one wide read button, or a wide read button
 * with share and save as icons.
 */
import { type ReactNode } from "react";
import { Button, Group } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import type { Post } from "../blocks/post-card.types";
import type { PostExtras, PostSplitLabels } from "../blocks/post-split.types";

export type PostActionsProps = {
  labels: PostSplitLabels;
  mode?: "pair" | "wide" | "icons";
};

export function PostActions({ labels, mode = "pair" }: PostActionsProps) {
  return (
    <>
      {((mode as string) === "pair") ? (
        <Group gap="2" className="flex-wrap" data-slot="post-actions">
          <Button variant="default" size="default" className="gap-2">
            <LucideIcon name="share-2" size={16} />
            {labels.share}
          </Button>
          <Button variant="outline" size="default" className="gap-2">
            <LucideIcon name="bookmark" size={16} />
            {labels.save}
          </Button>
        </Group>
      ) : (
        <Group gap="2" data-slot="post-actions">
          <Button variant="default" size="default" className="gap-2 flex-1">
            <LucideIcon name="book-open" size={16} />
            {labels.read}
          </Button>
          {((mode as string) === "icons") ? (
            <>
              <Button variant="outline" size="default" layout="icon" aria-label={labels.share}>
                <LucideIcon name="share-2" size={16} />
              </Button>
              <Button variant="outline" size="default" layout="icon" aria-label={labels.save}>
                <LucideIcon name="bookmark" size={16} />
              </Button>
            </>
          ) : null}
        </Group>
      )}
    </>
  );
}

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 post-actions
components/post-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 calls to action of a post header: share and save side by side, one wide read button, or a wide read button
  with share and save as icons.
-->
<script lang="ts">
import type { Post } from "../blocks/post-card.types";
import type { PostExtras, PostSplitLabels } from "../blocks/post-split.types";

export type PostActionsProps = {
  labels: PostSplitLabels;
  mode?: "pair" | "wide" | "icons";
};
</script>

<script setup lang="ts">
import Button from "../compose/Button.vue";
import Group from "../compose/Group.vue";
import LucideIcon from "../icons/LucideIcon.vue";

const { labels, mode = "pair" } = defineProps<PostActionsProps>();
</script>

<template>
  <Group v-if="((mode as string) === 'pair')" gap="2" class="flex-wrap" data-slot="post-actions">
    <Button variant="default" size="default" class="gap-2">
      <LucideIcon name="share-2" :size="16" />
      {{ labels.share }}
    </Button>
    <Button variant="outline" size="default" class="gap-2">
      <LucideIcon name="bookmark" :size="16" />
      {{ labels.save }}
    </Button>
  </Group>
  <Group v-else gap="2" data-slot="post-actions">
    <Button variant="default" size="default" class="gap-2 flex-1">
      <LucideIcon name="book-open" :size="16" />
      {{ labels.read }}
    </Button>
    <template v-if="((mode as string) === 'icons')">
      <Button variant="outline" size="default" layout="icon" :aria-label="labels.share">
        <LucideIcon name="share-2" :size="16" />
      </Button>
      <Button variant="outline" size="default" layout="icon" :aria-label="labels.save">
        <LucideIcon name="bookmark" :size="16" />
      </Button>
    </template>
  </Group>
</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 post-actions
components/post-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 calls to action of a post header: share and save side by side, one wide read button, or a wide read button
 * with share and save as icons.
 */
import { type JSX } from "solid-js";
import { Button, Group } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import type { Post } from "../blocks/post-card.types";
import type { PostExtras, PostSplitLabels } from "../blocks/post-split.types";

export type PostActionsProps = {
  labels: PostSplitLabels;
  mode?: "pair" | "wide" | "icons";
};

export function PostActions({ labels, mode = "pair" }: PostActionsProps) {
  return (
    <>
      {((mode as string) === "pair") ? (
        <Group gap="2" class="flex-wrap" data-slot="post-actions">
          <Button variant="default" size="default" class="gap-2">
            <LucideIcon name="share-2" size={16} />
            {labels.share}
          </Button>
          <Button variant="outline" size="default" class="gap-2">
            <LucideIcon name="bookmark" size={16} />
            {labels.save}
          </Button>
        </Group>
      ) : (
        <Group gap="2" data-slot="post-actions">
          <Button variant="default" size="default" class="gap-2 flex-1">
            <LucideIcon name="book-open" size={16} />
            {labels.read}
          </Button>
          {((mode as string) === "icons") ? (
            <>
              <Button variant="outline" size="default" layout="icon" aria-label={labels.share}>
                <LucideIcon name="share-2" size={16} />
              </Button>
              <Button variant="outline" size="default" layout="icon" aria-label={labels.save}>
                <LucideIcon name="bookmark" size={16} />
              </Button>
            </>
          ) : null}
        </Group>
      )}
    </>
  );
}

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 post-actions
blocks/post-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/post-actions.json

package blocks

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

// PostActionsProps are the props of PostActions; the values are the JSON shapes of the TypeScript props.
type PostActionsProps struct {
	Labels any `json:"labels"`
	Mode any `json:"mode"`
}

// The calls to action of a post header: share and save side by side, one wide read button, or a wide read button with share and save as icons.
templ PostActions(p PostActionsProps) {
	{{ vLabels := p.Labels }}
	{{ vMode := uiutils.Def(p.Mode, "pair") }}
	if uiutils.Eq(vMode, "pair") {
		@compose.Group(compose.GroupProps{Gap: "2", BoxProps: box.BoxProps{Class: "flex-wrap", Attrs: uiutils.Attrs("data-slot", "post-actions")}}) {
			@compose.Button(compose.ButtonProps{Variant: "default", Size: "default", ButtonProps: button.ButtonProps{Class: "gap-2"}}) {
				@icons.LucideIcon(icons.LucideIconProps{Name: "share-2", Size: 16})
				{ uiutils.Text(uiutils.Get(vLabels, "share")) }
			}
			@compose.Button(compose.ButtonProps{Variant: "outline", Size: "default", ButtonProps: button.ButtonProps{Class: "gap-2"}}) {
				@icons.LucideIcon(icons.LucideIconProps{Name: "bookmark", Size: 16})
				{ uiutils.Text(uiutils.Get(vLabels, "save")) }
			}
		}
	} else {
		@compose.Group(compose.GroupProps{Gap: "2", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "post-actions")}}) {
			@compose.Button(compose.ButtonProps{Variant: "default", Size: "default", ButtonProps: button.ButtonProps{Class: "gap-2 flex-1"}}) {
				@icons.LucideIcon(icons.LucideIconProps{Name: "book-open", Size: 16})
				{ uiutils.Text(uiutils.Get(vLabels, "read")) }
			}
			if uiutils.Eq(vMode, "icons") {
				@compose.Button(compose.ButtonProps{Variant: "outline", Size: "default", Layout: "icon", ButtonProps: button.ButtonProps{AriaLabel: uiutils.S(uiutils.Get(vLabels, "share"))}}) {
					@icons.LucideIcon(icons.LucideIconProps{Name: "share-2", Size: 16})
				}
				@compose.Button(compose.ButtonProps{Variant: "outline", Size: "default", Layout: "icon", ButtonProps: button.ButtonProps{AriaLabel: uiutils.S(uiutils.Get(vLabels, "save"))}}) {
					@icons.LucideIcon(icons.LucideIconProps{Name: "bookmark", Size: 16})
				}
			}
		}
	}
}

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 post-actions
blocks/post-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/post-actions.json
    The calls to action of a post header: share and save side by side, one wide read button, or a wide read button with share and save as icons.
    Props (p): labels, mode. -#}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_mode = (p.mode ?? 'pair') -%}
{%- if og_t(og_eq(v_mode, 'pair')) %}
  {%- set c_3 -%}
    {%- set c_1 -%}
      {{ include('icons/LucideIcon.html.twig', {'name': 'share-2', 'size': 16}, with_context = false) }}
      {{ og_text(og_get(v_labels, ['share'])) }}
    {%- endset -%}
    {{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'default', 'class': 'gap-2', 'children': c_1}, with_context = false) }}
    {%- set c_2 -%}
      {{ include('icons/LucideIcon.html.twig', {'name': 'bookmark', 'size': 16}, with_context = false) }}
      {{ og_text(og_get(v_labels, ['save'])) }}
    {%- endset -%}
    {{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'default', 'class': 'gap-2', 'children': c_2}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Group.html.twig', {'gap': '2', 'class': 'flex-wrap', 'attrs': og_attrs(['data-slot', 'post-actions']), 'children': c_3}, with_context = false) }}
{%- else %}
  {%- set c_7 -%}
    {%- set c_4 -%}
      {{ include('icons/LucideIcon.html.twig', {'name': 'book-open', 'size': 16}, with_context = false) }}
      {{ og_text(og_get(v_labels, ['read'])) }}
    {%- endset -%}
    {{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'default', 'class': 'gap-2 flex-1', 'children': c_4}, with_context = false) }}
    {%- if og_t(og_eq(v_mode, 'icons')) %}
      {%- set c_5 -%}
        {{ include('icons/LucideIcon.html.twig', {'name': 'share-2', 'size': 16}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'default', 'layout': 'icon', 'ariaLabel': og_s(og_get(v_labels, ['share'])), 'children': c_5}, with_context = false) }}
      {%- set c_6 -%}
        {{ include('icons/LucideIcon.html.twig', {'name': 'bookmark', 'size': 16}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'default', 'layout': 'icon', 'ariaLabel': og_s(og_get(v_labels, ['save'])), 'children': c_6}, with_context = false) }}
    {%- endif %}
  {%- endset -%}
  {{ include('compose/Group.html.twig', {'gap': '2', 'attrs': og_attrs(['data-slot', 'post-actions']), 'children': c_7}, 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 post-actions
blocks/post-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/post-actions.json
    The calls to action of a post header: share and save side by side, one wide read button, or a wide read button with share and save as icons.
    Props (p): labels, mode. *}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_mode = ($p['mode'] ?? 'pair')}
{if og_t(og_eq($v_mode, 'pair'))}
  {capture $c_3}
    {capture $c_1}
      {=og_include('icons/LucideIcon.latte', ['name' => 'share-2', 'size' => 16])|noescape}
      {=og_text(og_get($v_labels, ['share']))}
    {/capture}
    {=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'default', 'class' => 'gap-2', 'children' => (string) $c_1])|noescape}
    {capture $c_2}
      {=og_include('icons/LucideIcon.latte', ['name' => 'bookmark', 'size' => 16])|noescape}
      {=og_text(og_get($v_labels, ['save']))}
    {/capture}
    {=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'default', 'class' => 'gap-2', 'children' => (string) $c_2])|noescape}
  {/capture}
  {=og_include('compose/Group.latte', ['gap' => '2', 'class' => 'flex-wrap', 'attrs' => og_attrs(['data-slot', 'post-actions']), 'children' => (string) $c_3])|noescape}
{else}
  {capture $c_7}
    {capture $c_4}
      {=og_include('icons/LucideIcon.latte', ['name' => 'book-open', 'size' => 16])|noescape}
      {=og_text(og_get($v_labels, ['read']))}
    {/capture}
    {=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'default', 'class' => 'gap-2 flex-1', 'children' => (string) $c_4])|noescape}
    {if og_t(og_eq($v_mode, 'icons'))}
      {capture $c_5}
        {=og_include('icons/LucideIcon.latte', ['name' => 'share-2', 'size' => 16])|noescape}
      {/capture}
      {=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'default', 'layout' => 'icon', 'ariaLabel' => og_s(og_get($v_labels, ['share'])), 'children' => (string) $c_5])|noescape}
      {capture $c_6}
        {=og_include('icons/LucideIcon.latte', ['name' => 'bookmark', 'size' => 16])|noescape}
      {/capture}
      {=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'default', 'layout' => 'icon', 'ariaLabel' => og_s(og_get($v_labels, ['save'])), 'children' => (string) $c_6])|noescape}
    {/if}
  {/capture}
  {=og_include('compose/Group.latte', ['gap' => '2', 'attrs' => og_attrs(['data-slot', 'post-actions']), 'children' => (string) $c_7])|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 post-actions
blocks/post-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/post-actions.json
    The calls to action of a post header: share and save side by side, one wide read button, or a wide read button with share and save as icons.
    Props (p): labels, mode. -#}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_mode = og_def(p['mode'], 'pair') -%}
{%- if og_t(og_eq(v_mode, 'pair')) %}
  {%- set c_3 -%}
    {%- set c_1 -%}
      {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'share-2', 'Size': 16}}) }}
      {{ og_text(og_get(v_labels, ['share'])) }}
    {%- endset -%}
    {{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Class': 'gap-2'}, 'children': c_1}) }}
    {%- set c_2 -%}
      {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'bookmark', 'Size': 16}}) }}
      {{ og_text(og_get(v_labels, ['save'])) }}
    {%- endset -%}
    {{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'default', 'Class': 'gap-2'}, 'children': c_2}) }}
  {%- endset -%}
  {{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Class': 'flex-wrap', 'Attrs': og_attrs(['data-slot', 'post-actions'])}, 'children': c_3}) }}
{%- else %}
  {%- set c_7 -%}
    {%- set c_4 -%}
      {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'book-open', 'Size': 16}}) }}
      {{ og_text(og_get(v_labels, ['read'])) }}
    {%- endset -%}
    {{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Class': 'gap-2 flex-1'}, 'children': c_4}) }}
    {%- if og_t(og_eq(v_mode, 'icons')) %}
      {%- set c_5 -%}
        {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'share-2', 'Size': 16}}) }}
      {%- endset -%}
      {{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'default', 'Layout': 'icon', 'AriaLabel': og_s(og_get(v_labels, ['share']))}, 'children': c_5}) }}
      {%- set c_6 -%}
        {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'bookmark', 'Size': 16}}) }}
      {%- endset -%}
      {{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'default', 'Layout': 'icon', 'AriaLabel': og_s(og_get(v_labels, ['save']))}, 'children': c_6}) }}
    {%- endif %}
  {%- endset -%}
  {{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Attrs': og_attrs(['data-slot', 'post-actions'])}, 'children': c_7}) }}
{%- 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 calls to action of a post header: share and save side by side, one wide read button, or a wide read button with share and save as icons.

Props of PostActions
PropTypeDefault Description
labels (required)PostSplitLabels-
mode "pair" | "wide" | "icons""pair"

Used in