Skip to content
ui8kit

component / components

Add Icon

Add Icon component

Install

npx ui8kit add add-icon

Pulls in: button, compose, kit-button, lucide-icon, 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 add-icon
components/add-icon.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 small icon button that adds one dish: a plus, named after the dish. Static markup. -->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type AddIconProps = {
    label: string;
    variant?: "default" | "outline";
  };
</script>

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

  let { label, variant = "outline" }: AddIconProps = $props();
</script>

<Button variant={variant} size="sm" layout="icon" type="button" aria-label={label}>
  <LucideIcon name="plus" size={16} />
</Button>

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 add-icon
components/add-icon.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 small icon button that adds one dish: a plus, named after the dish. Static markup. */
import { type ReactNode } from "react";
import { Button } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";

export type AddIconProps = {
  label: string;
  variant?: "default" | "outline";
};

export function AddIcon({ label, variant = "outline" }: AddIconProps) {
  return (
    <Button variant={variant} size="sm" layout="icon" type="button" aria-label={label}>
      <LucideIcon name="plus" size={16} />
    </Button>
  );
}

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 add-icon
components/add-icon.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 small icon button that adds one dish: a plus, named after the dish. Static markup. -->
<script lang="ts">
export type AddIconProps = {
  label: string;
  variant?: "default" | "outline";
};
</script>

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

const { label, variant = "outline" } = defineProps<AddIconProps>();
</script>

<template>
  <Button :variant="variant" size="sm" layout="icon" type="button" :aria-label="label">
    <LucideIcon name="plus" :size="16" />
  </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 add-icon
components/add-icon.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 small icon button that adds one dish: a plus, named after the dish. Static markup. */
import { type JSX } from "solid-js";
import { Button } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";

export type AddIconProps = {
  label: string;
  variant?: "default" | "outline";
};

export function AddIcon({ label, variant = "outline" }: AddIconProps) {
  return (
    <Button variant={variant} size="sm" layout="icon" type="button" aria-label={label}>
      <LucideIcon name="plus" size={16} />
    </Button>
  );
}

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 add-icon
blocks/add-icon.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/add-icon.json

package blocks

import (
	"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"
)

// AddIconProps are the props of AddIcon; the values are the JSON shapes of the TypeScript props.
type AddIconProps struct {
	Label any `json:"label"`
	Variant any `json:"variant"`
}

// A small icon button that adds one dish: a plus, named after the dish. Static markup.
templ AddIcon(p AddIconProps) {
	{{ vLabel := p.Label }}
	{{ vVariant := uiutils.Def(p.Variant, "outline") }}
	@compose.Button(compose.ButtonProps{Variant: uiutils.S(vVariant), Size: "sm", Layout: "icon", ButtonProps: button.ButtonProps{Type: "button", AriaLabel: uiutils.S(vLabel)}}) {
		@icons.LucideIcon(icons.LucideIconProps{Name: "plus", 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 add-icon
blocks/add-icon.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/add-icon.json
    A small icon button that adds one dish: a plus, named after the dish. Static markup.
    Props (p): label, variant. -#}
{%- set v_label = (p.label ?? null) -%}
{%- set v_variant = (p.variant ?? 'outline') -%}
{%- set c_1 -%}
  {{ include('icons/LucideIcon.html.twig', {'name': 'plus', 'size': 16}, with_context = false) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': og_s(v_variant), 'size': 'sm', 'layout': 'icon', 'type': 'button', 'ariaLabel': og_s(v_label), '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 add-icon
blocks/add-icon.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/add-icon.json
    A small icon button that adds one dish: a plus, named after the dish. Static markup.
    Props (p): label, variant. *}
{var $v_label = ($p['label'] ?? null)}
{var $v_variant = ($p['variant'] ?? 'outline')}
{capture $c_1}
  {=og_include('icons/LucideIcon.latte', ['name' => 'plus', 'size' => 16])|noescape}
{/capture}
{=og_include('compose/Button.latte', ['variant' => og_s($v_variant), 'size' => 'sm', 'layout' => 'icon', 'type' => 'button', 'ariaLabel' => og_s($v_label), '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 add-icon
blocks/add-icon.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/add-icon.json
    A small icon button that adds one dish: a plus, named after the dish. Static markup.
    Props (p): label, variant. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- set v_variant = og_def(p['variant'], 'outline') -%}
{%- set c_1 -%}
  {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'plus', 'Size': 16}}) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': og_s(v_variant), 'Size': 'sm', 'Layout': 'icon', 'Type': 'button', 'AriaLabel': og_s(v_label)}, '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 small icon button that adds one dish: a plus, named after the dish. Static markup.

Props of AddIcon
PropTypeDefault Description
label (required)string-accessible name, with the dish in it
variant "default" | "outline""outline"

Used in