Action Group
Action Group component
Install
npx ui8kit add action-groupPulls in: button, compose, group, kit-box, 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-cdnnpx ui8kit add action-group<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not
handlers: the page decides what they open.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
export type ActionGroupProps = {
primary: string;
primaryHref?: string;
secondary?: string;
secondaryHref?: string;
align?: "start" | "center";
};
</script>
<script lang="ts">
import Button from "../compose/Button.svelte";
import Group from "../compose/Group.svelte";
import { urlOf } from "../utils";
let { primary, primaryHref, secondary, secondaryHref, align = "start" }: ActionGroupProps = $props();
</script>
<Group
gap="4"
align="center"
justify={(((align as string) === "center") ? "center" : "start")}
class="flex-wrap"
data-slot="action-group"
>
<Button variant="default" size="default" href={urlOf(primaryHref)}>
{primary}
</Button>
{#if secondary}
<Button variant="outline" size="default" href={urlOf(secondaryHref)}>
{secondary}
</Button>
{/if}
</Group>
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-cdnnpx ui8kit add action-group// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not
* handlers: the page decides what they open.
*/
import { type ReactNode } from "react";
import { Button, Group } from "../compose";
import { urlOf } from "../utils";
export type ActionGroupProps = {
primary: string;
primaryHref?: string;
secondary?: string;
secondaryHref?: string;
align?: "start" | "center";
};
export function ActionGroup({
primary,
primaryHref,
secondary,
secondaryHref,
align = "start",
}: ActionGroupProps) {
return (
<Group
gap="4"
align="center"
justify={(((align as string) === "center") ? "center" : "start")}
className="flex-wrap"
data-slot="action-group"
>
<Button variant="default" size="default" href={urlOf(primaryHref)}>
{primary}
</Button>
{secondary ? (
<Button variant="outline" size="default" href={urlOf(secondaryHref)}>
{secondary}
</Button>
) : null}
</Group>
);
}
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-cdnnpx ui8kit add action-group<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not
handlers: the page decides what they open.
-->
<script lang="ts">
export type ActionGroupProps = {
primary: string;
primaryHref?: string;
secondary?: string;
secondaryHref?: string;
align?: "start" | "center";
};
</script>
<script setup lang="ts">
import Button from "../compose/Button.vue";
import Group from "../compose/Group.vue";
import { urlOf } from "../utils";
const { primary, primaryHref, secondary, secondaryHref, align = "start" } = defineProps<ActionGroupProps>();
</script>
<template>
<Group
gap="4"
align="center"
:justify="(((align as string) === 'center') ? 'center' : 'start')"
class="flex-wrap"
data-slot="action-group"
>
<Button variant="default" size="default" :href="urlOf(primaryHref)">
{{ primary }}
</Button>
<Button v-if="secondary" variant="outline" size="default" :href="urlOf(secondaryHref)">
{{ secondary }}
</Button>
</Group>
</template>
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-cdnnpx ui8kit add action-group// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not
* handlers: the page decides what they open.
*/
import { type JSX } from "solid-js";
import { Button, Group } from "../compose";
import { urlOf } from "../utils";
export type ActionGroupProps = {
primary: string;
primaryHref?: string;
secondary?: string;
secondaryHref?: string;
align?: "start" | "center";
};
export function ActionGroup({
primary,
primaryHref,
secondary,
secondaryHref,
align = "start",
}: ActionGroupProps) {
return (
<Group
gap="4"
align="center"
justify={(((align as string) === "center") ? "center" : "start")}
class="flex-wrap"
data-slot="action-group"
>
<Button variant="default" size="default" href={urlOf(primaryHref)}>
{primary}
</Button>
{secondary ? (
<Button variant="outline" size="default" href={urlOf(secondaryHref)}>
{secondary}
</Button>
) : null}
</Group>
);
}
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-cdnnpx ui8kit add action-group// 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/patterns/action-group.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"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// ActionGroupProps are the props of ActionGroup; the values are the JSON shapes of the TypeScript props.
type ActionGroupProps struct {
Primary any `json:"primary"`
PrimaryHref any `json:"primaryHref"`
Secondary any `json:"secondary"`
SecondaryHref any `json:"secondaryHref"`
Align any `json:"align"`
}
// One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not handlers: the page decides what they open.
templ ActionGroup(p ActionGroupProps) {
{{ vPrimary := p.Primary }}
{{ vPrimaryHref := p.PrimaryHref }}
{{ vSecondary := p.Secondary }}
{{ vSecondaryHref := p.SecondaryHref }}
{{ vAlign := uiutils.Def(p.Align, "start") }}
@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vAlign, "center")), "center", "start")), BoxProps: box.BoxProps{Class: "flex-wrap", Attrs: uiutils.Attrs("data-slot", "action-group")}}) {
@compose.Button(compose.ButtonProps{Variant: "default", Size: "default", ButtonProps: button.ButtonProps{Href: uiutils.URL(vPrimaryHref, false)}}) {
{ uiutils.Text(vPrimary) }
}
if uiutils.T(vSecondary) {
@compose.Button(compose.ButtonProps{Variant: "outline", Size: "default", ButtonProps: button.ButtonProps{Href: uiutils.URL(vSecondaryHref, false)}}) {
{ uiutils.Text(vSecondary) }
}
}
}
}
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-cdnnpx ui8kit add action-group{#- 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/patterns/action-group.json
One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not handlers: the page decides what they open.
Props (p): primary, primaryHref, secondary, secondaryHref, align. -#}
{%- set v_primary = (p.primary ?? null) -%}
{%- set v_primaryHref = (p.primaryHref ?? null) -%}
{%- set v_secondary = (p.secondary ?? null) -%}
{%- set v_secondaryHref = (p.secondaryHref ?? null) -%}
{%- set v_align = (p.align ?? 'start') -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(v_primary) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'default', 'href': og_url(og_s(v_primaryHref)), 'children': c_1}, with_context = false) }}
{%- if og_t(v_secondary) %}
{%- set c_2 -%}
{{ og_text(v_secondary) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'default', 'href': og_url(og_s(v_secondaryHref)), 'children': c_2}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': og_s((og_t(og_eq(v_align, 'center')) ? 'center' : 'start')), 'class': 'flex-wrap', 'attrs': og_attrs(['data-slot', 'action-group']), 'children': c_3}, with_context = false) }}
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-cdnnpx ui8kit add action-group{* 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/patterns/action-group.json
One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not handlers: the page decides what they open.
Props (p): primary, primaryHref, secondary, secondaryHref, align. *}
{var $v_primary = ($p['primary'] ?? null)}
{var $v_primaryHref = ($p['primaryHref'] ?? null)}
{var $v_secondary = ($p['secondary'] ?? null)}
{var $v_secondaryHref = ($p['secondaryHref'] ?? null)}
{var $v_align = ($p['align'] ?? 'start')}
{capture $c_3}
{capture $c_1}
{=og_text($v_primary)}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'default', 'href' => og_url(og_s($v_primaryHref)), 'children' => (string) $c_1])|noescape}
{if og_t($v_secondary)}
{capture $c_2}
{=og_text($v_secondary)}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'default', 'href' => og_url(og_s($v_secondaryHref)), 'children' => (string) $c_2])|noescape}
{/if}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => og_s((og_t(og_eq($v_align, 'center')) ? 'center' : 'start')), 'class' => 'flex-wrap', 'attrs' => og_attrs(['data-slot', 'action-group']), 'children' => (string) $c_3])|noescape}
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-cdnnpx ui8kit add action-group{#- 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/patterns/action-group.json
One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not handlers: the page decides what they open.
Props (p): primary, primaryHref, secondary, secondaryHref, align. -#}
{%- set v_primary = og_def(p['primary'], none) -%}
{%- set v_primaryHref = og_def(p['primaryHref'], none) -%}
{%- set v_secondary = og_def(p['secondary'], none) -%}
{%- set v_secondaryHref = og_def(p['secondaryHref'], none) -%}
{%- set v_align = og_def(p['align'], 'start') -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(v_primary) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Href': og_url(og_s(v_primaryHref))}, 'children': c_1}) }}
{%- if og_t(v_secondary) %}
{%- set c_2 -%}
{{ og_text(v_secondary) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'default', 'Href': og_url(og_s(v_secondaryHref))}, 'children': c_2}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': og_s(('center' if og_t(og_eq(v_align, 'center')) else 'start')), 'Class': 'flex-wrap', 'Attrs': og_attrs(['data-slot', 'action-group'])}, 'children': c_3}) }}
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.
One or two calls to action side by side: a filled primary button and an outline secondary one. Links, not handlers: the page decides what they open.
| Prop | Type | Default | Description |
|---|---|---|---|
| primary (required) | string | - | text of the primary action |
| primaryHref | string | - | |
| secondary | string | - | text of the secondary action; none: one action |
| secondaryHref | string | - | |
| align | "start" | "center" | "start" | where the group sits |