Hero Badge
Hero Badge component
Install
npx ui8kit add hero-badgePulls in: badge, compose, group, kit-box, kit-text, presets, text, utils
Preview
No static preview for this item: it needs content or a parent that this page cannot supply. The code is below.
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 hero-badge<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- A composite badge on a dark band: an optional small mark beside a label. -->
<script lang="ts" module>
import type { Snippet } from "svelte";
export type HeroBadgeProps = {
label: string;
mark?: string;
};
</script>
<script lang="ts">
import Badge from "../compose/Badge.svelte";
import Group from "../compose/Group.svelte";
import Text from "../compose/Text.svelte";
import { defaults } from "../presets/defaults";
import { cn } from "../utils";
let { label, mark }: HeroBadgeProps = $props();
</script>
<Group
gap="2"
align="center"
class={cn(
"h-8 justify-center rounded-full px-2 inset-ring inset-ring-background/30",
defaults.hero.badge
)}
data-slot="section-badge"
>
{#if mark}
<Badge variant="secondary" size="sm">
{mark}
</Badge>
{/if}
<Text size="xs" weight="bold" class="leading-5 text-background">
{label}
</Text>
</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 hero-badge// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** A composite badge on a dark band: an optional small mark beside a label. */
import { type ReactNode } from "react";
import { Badge, Group, Text } from "../compose";
import { defaults } from "../presets/defaults";
import { cn } from "../utils";
export type HeroBadgeProps = {
label: string;
mark?: string;
};
export function HeroBadge({ label, mark }: HeroBadgeProps) {
return (
<Group
gap="2"
align="center"
className={cn(
"h-8 justify-center rounded-full px-2 inset-ring inset-ring-background/30",
defaults.hero.badge
)}
data-slot="section-badge"
>
{mark ? (
<Badge variant="secondary" size="sm">
{mark}
</Badge>
) : null}
<Text size="xs" weight="bold" className="leading-5 text-background">
{label}
</Text>
</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 hero-badge<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- A composite badge on a dark band: an optional small mark beside a label. -->
<script lang="ts">
export type HeroBadgeProps = {
label: string;
mark?: string;
};
</script>
<script setup lang="ts">
import Badge from "../compose/Badge.vue";
import Group from "../compose/Group.vue";
import Text from "../compose/Text.vue";
import { defaults } from "../presets/defaults";
import { cn } from "../utils";
const { label, mark } = defineProps<HeroBadgeProps>();
</script>
<template>
<Group
gap="2"
align="center"
:class="cn(
'h-8 justify-center rounded-full px-2 inset-ring inset-ring-background/30',
defaults.hero.badge
)"
data-slot="section-badge"
>
<Badge v-if="mark" variant="secondary" size="sm">
{{ mark }}
</Badge>
<Text size="xs" weight="bold" class="leading-5 text-background">
{{ label }}
</Text>
</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 hero-badge// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** A composite badge on a dark band: an optional small mark beside a label. */
import { type JSX } from "solid-js";
import { Badge, Group, Text } from "../compose";
import { defaults } from "../presets/defaults";
import { cn } from "../utils";
export type HeroBadgeProps = {
label: string;
mark?: string;
};
export function HeroBadge({ label, mark }: HeroBadgeProps) {
return (
<Group
gap="2"
align="center"
class={cn(
"h-8 justify-center rounded-full px-2 inset-ring inset-ring-background/30",
defaults.hero.badge
)}
data-slot="section-badge"
>
{mark ? (
<Badge variant="secondary" size="sm">
{mark}
</Badge>
) : null}
<Text size="xs" weight="bold" class="leading-5 text-background">
{label}
</Text>
</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 hero-badge// 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/hero-badge.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// HeroBadgeProps are the props of HeroBadge; the values are the JSON shapes of the TypeScript props.
type HeroBadgeProps struct {
Label any `json:"label"`
Mark any `json:"mark"`
}
// A composite badge on a dark band: an optional small mark beside a label.
templ HeroBadge(p HeroBadgeProps) {
{{ vLabel := p.Label }}
{{ vMark := p.Mark }}
@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("h-8 justify-center rounded-full px-2 inset-ring inset-ring-background/30", uiutils.Get(presetDefaults, "hero", "badge"))), Attrs: uiutils.Attrs("data-slot", "section-badge")}}) {
if uiutils.T(vMark) {
@compose.Badge(compose.BadgeProps{Variant: "secondary", Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(vMark) }
}
}
@compose.Text(compose.TextProps{Size: "xs", Weight: "bold", TextProps: text.TextProps{Class: "leading-5 text-background"}}) {
{ uiutils.Text(vLabel) }
}
}
}
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 hero-badge{#- 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/hero-badge.json
A composite badge on a dark band: an optional small mark beside a label.
Props (p): label, mark. -#}
{%- set v_label = (p.label ?? null) -%}
{%- set v_mark = (p.mark ?? null) -%}
{%- set c_3 -%}
{%- if og_t(v_mark) %}
{%- set c_1 -%}
{{ og_text(v_mark) }}
{%- endset -%}
{{ include('compose/Badge.html.twig', {'variant': 'secondary', 'size': 'sm', 'children': c_1}, with_context = false) }}
{%- endif %}
{%- set c_2 -%}
{{ og_text(v_label) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'weight': 'bold', 'class': 'leading-5 text-background', 'children': c_2}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'class': og_s(og_cnv(['h-8 justify-center rounded-full px-2 inset-ring inset-ring-background/30', og_preset('blocks/presets/defaults.json', ['hero', 'badge'])])), 'attrs': og_attrs(['data-slot', 'section-badge']), '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 hero-badge{* 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/hero-badge.json
A composite badge on a dark band: an optional small mark beside a label.
Props (p): label, mark. *}
{var $v_label = ($p['label'] ?? null)}
{var $v_mark = ($p['mark'] ?? null)}
{capture $c_3}
{if og_t($v_mark)}
{capture $c_1}
{=og_text($v_mark)}
{/capture}
{=og_include('compose/Badge.latte', ['variant' => 'secondary', 'size' => 'sm', 'children' => (string) $c_1])|noescape}
{/if}
{capture $c_2}
{=og_text($v_label)}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'weight' => 'bold', 'class' => 'leading-5 text-background', 'children' => (string) $c_2])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'class' => og_s(og_cnv(['h-8 justify-center rounded-full px-2 inset-ring inset-ring-background/30', og_preset('blocks/presets/defaults.json', ['hero', 'badge'])])), 'attrs' => og_attrs(['data-slot', 'section-badge']), '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 hero-badge{#- 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/hero-badge.json
A composite badge on a dark band: an optional small mark beside a label.
Props (p): label, mark. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- set v_mark = og_def(p['mark'], none) -%}
{%- set c_3 -%}
{%- if og_t(v_mark) %}
{%- set c_1 -%}
{{ og_text(v_mark) }}
{%- endset -%}
{{ og_include('compose/badge.html.j2', {'p': {'Variant': 'secondary', 'Size': 'sm'}, 'children': c_1}) }}
{%- endif %}
{%- set c_2 -%}
{{ og_text(v_label) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Weight': 'bold', 'Class': 'leading-5 text-background'}, 'children': c_2}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center', 'Class': og_s(og_cnv(['h-8 justify-center rounded-full px-2 inset-ring inset-ring-background/30', og_preset('blocks/presets/defaults.json', ['hero', 'badge'])])), 'Attrs': og_attrs(['data-slot', 'section-badge'])}, '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.
A composite badge on a dark band: an optional small mark beside a label.
| Prop | Type | Default | Description |
|---|---|---|---|
| label (required) | string | - | |
| mark | string | - | small inner pill text (NEW) |