Skip to content
ui8kit

component / components

Badge Square

Badge Square component

Install

npx ui8kit add badge-square

Pulls in: compose, inline, kit-text, presets, utils

Preview

size.sm
size.default

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 badge-square
components/badge-square.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. -->
<!-- A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd). -->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import { variants } from "../utils";

  /** BadgeSquare: the classes of each value (shadcn/cva style). */
  export const badgeSquareVariants = variants({
    base:
      "inline-flex shrink-0 items-center justify-center bg-card text-xs font-medium whitespace-nowrap text-foreground " +
      "inset-ring inset-ring-border rounded",
    variants: {
      size: {
        sm: "h-4 min-w-4 px-1",
        default: "h-5 px-2",
      },
    },
    defaultVariants: { size: "default" },
  });

  export type BadgeSquareProps = {
    size?: "sm" | "default";
    class?: string;
    children?: Snippet;
  };
</script>

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

  let { size = "default", class: className, children }: BadgeSquareProps = $props();
</script>

<Inline class={cn(badgeSquareVariants({ size: size }), className)} data-slot="badge-square">
  {@render children?.()}
</Inline>

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 badge-square
components/badge-square.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.
/** A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd). */
import { type ReactNode } from "react";
import { Inline } from "../compose";
import { cn, variants } from "../utils";

/** BadgeSquare: the classes of each value (shadcn/cva style). */
export const badgeSquareVariants = variants({
  base:
    "inline-flex shrink-0 items-center justify-center bg-card text-xs font-medium whitespace-nowrap text-foreground " +
    "inset-ring inset-ring-border rounded",
  variants: {
    size: {
      sm: "h-4 min-w-4 px-1",
      default: "h-5 px-2",
    },
  },
  defaultVariants: { size: "default" },
});

export type BadgeSquareProps = {
  size?: "sm" | "default";
  className?: string;
  children?: ReactNode;
};

export function BadgeSquare({ size = "default", className, children }: BadgeSquareProps) {
  return (
    <Inline className={cn(badgeSquareVariants({ size: size }), className)} data-slot="badge-square">
      {children}
    </Inline>
  );
}

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 badge-square
components/badge-square.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. -->
<!-- A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd). -->
<script lang="ts">
import { variants } from "../utils";

/** BadgeSquare: the classes of each value (shadcn/cva style). */
export const badgeSquareVariants = variants({
  base:
    "inline-flex shrink-0 items-center justify-center bg-card text-xs font-medium whitespace-nowrap text-foreground " +
    "inset-ring inset-ring-border rounded",
  variants: {
    size: {
      sm: "h-4 min-w-4 px-1",
      default: "h-5 px-2",
    },
  },
  defaultVariants: { size: "default" },
});

export type BadgeSquareProps = {
  size?: "sm" | "default";
  class?: string;
};
</script>

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

const { size = "default", class: className } = defineProps<BadgeSquareProps>();
defineSlots<{ default?(): unknown }>();
</script>

<template>
  <Inline :class="cn(badgeSquareVariants({ size: size }), className)" data-slot="badge-square">
    <slot />
  </Inline>
</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 badge-square
components/badge-square.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.
/** A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd). */
import { type JSX } from "solid-js";
import { Inline } from "../compose";
import { cn, variants } from "../utils";

/** BadgeSquare: the classes of each value (shadcn/cva style). */
export const badgeSquareVariants = variants({
  base:
    "inline-flex shrink-0 items-center justify-center bg-card text-xs font-medium whitespace-nowrap text-foreground " +
    "inset-ring inset-ring-border rounded",
  variants: {
    size: {
      sm: "h-4 min-w-4 px-1",
      default: "h-5 px-2",
    },
  },
  defaultVariants: { size: "default" },
});

export type BadgeSquareProps = {
  size?: "sm" | "default";
  class?: string;
  children?: JSX.Element;
};

export function BadgeSquare({ size = "default", class: className, children }: BadgeSquareProps) {
  return (
    <Inline class={cn(badgeSquareVariants({ size: size }), className)} data-slot="badge-square">
      {children}
    </Inline>
  );
}

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 badge-square
blocks/badge-square.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/parts/badge-square.json

package blocks

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

// BadgeSquareProps are the props of BadgeSquare; the values are the JSON shapes of the TypeScript props.
type BadgeSquareProps struct {
	Size any `json:"size"`
	Class string `json:"className"`
}

// A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd).
templ BadgeSquare(p BadgeSquareProps) {
	{{ vSize := uiutils.Def(p.Size, "default") }}
	@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: uiutils.S(uiutils.Cnv(recipeBadgeSquare.Of(map[string]any{"size": vSize}), p.Class)), Attrs: uiutils.Attrs("data-slot", "badge-square")}}) {
		{ children... }
	}
}

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 badge-square
blocks/badge-square.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/parts/badge-square.json
    A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd).
    Props (p): size, className; children: markup. -#}
{%- set v_size = (p.size ?? 'default') -%}
{%- set c_1 -%}
  {{ og_slot((children ?? null))|raw }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': og_s(og_cnv([og_recipe('blocks/recipes/badge-square.variants.json', {'size': v_size}), (p.className ?? '')])), 'attrs': og_attrs(['data-slot', 'badge-square']), 'children': c_1}, with_context = false) }}

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 badge-square
blocks/badge-square.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/parts/badge-square.json
    A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd).
    Props (p): size, className; children: markup. *}
{var $v_size = ($p['size'] ?? 'default')}
{capture $c_1}
  {=og_slot(($children ?? null))|noescape}
{/capture}
{=og_include('compose/Inline.latte', ['class' => og_s(og_cnv([og_recipe('blocks/recipes/badge-square.variants.json', ['size' => $v_size]), ($p['className'] ?? '')])), 'attrs' => og_attrs(['data-slot', 'badge-square']), 'children' => (string) $c_1])|noescape}

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 badge-square
blocks/badge-square.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/parts/badge-square.json
    A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd).
    Props (p): size, className; children: markup. -#}
{%- set v_size = og_def(p['size'], 'default') -%}
{%- set c_1 -%}
  {{ og_slot(og_def(children, none))|safe }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': og_s(og_cnv([og_recipe('blocks/recipes/badge-square.variants.json', {'size': v_size}), og_def(p['className'], '')])), 'Attrs': og_attrs(['data-slot', 'badge-square'])}, 'children': c_1}) }}

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.

A keyboard hint or counter in a small pill. Colours come from the middle layer (.badge-kbd).

Props of BadgeSquare
PropTypeDefault Description
size "sm" | "default""default"height