Skip to content
ui8kit

component / components

Pill

Pill component

Install

npx ui8kit add pill

Pulls in: box, compose, inline, kit-box, kit-text, lucide-icon, utils

Preview

Content

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 pill
components/pill.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 status pill: a tinted label with an icon (published, draft, role, comment state). -->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type PillProps = {
    tone?: "gray" | "blue" | "amber" | "green" | "red" | "violet" | "pink" | "orange" | "cyan";
    icon?: string;
    class?: string;
    children?: Snippet;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Inline from "../compose/Inline.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import { at, cn } from "../utils";

  const PILL: Record<string, string> = {
    "gray": "bg-muted text-muted-foreground inset-ring-border",
    "blue": "bg-blue-50 text-blue-700 inset-ring-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:inset-ring-blue-900",
    "amber": "bg-amber-50 text-amber-700 inset-ring-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:inset-ring-amber-900",
    "green": "bg-green-50 text-green-700 inset-ring-green-200 dark:bg-green-950 dark:text-green-300 dark:inset-ring-green-900",
    "red": "bg-red-50 text-red-700 inset-ring-red-200 dark:bg-red-950 dark:text-red-300 dark:inset-ring-red-900",
    "violet": "bg-violet-50 text-violet-700 inset-ring-violet-200 dark:bg-violet-950 dark:text-violet-300 dark:inset-ring-violet-900",
    "pink": "bg-pink-50 text-pink-700 inset-ring-pink-200 dark:bg-pink-950 dark:text-pink-300 dark:inset-ring-pink-900",
    "orange": "bg-orange-50 text-orange-700 inset-ring-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:inset-ring-orange-900",
    "cyan": "bg-cyan-50 text-cyan-700 inset-ring-cyan-200 dark:bg-cyan-950 dark:text-cyan-300 dark:inset-ring-cyan-900",
  };
  let { tone = "gray", icon, class: className, children }: PillProps = $props();
</script>

<Box class="contents">
  <Inline
    class={cn(
      "inline-flex h-6 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-medium whitespace-nowrap inset-ring",
      at(PILL, tone),
      className
    )}
    data-slot="pill"
  >
    {#if icon}
      <LucideIcon name={icon} size={12} />
    {/if}
    {@render children?.()}
  </Inline>
</Box>

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 pill
components/pill.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 status pill: a tinted label with an icon (published, draft, role, comment state). */
import { type ReactNode } from "react";
import { Box, Inline } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { at, cn } from "../utils";

const PILL: Record<string, string> = {
  "gray": "bg-muted text-muted-foreground inset-ring-border",
  "blue": "bg-blue-50 text-blue-700 inset-ring-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:inset-ring-blue-900",
  "amber": "bg-amber-50 text-amber-700 inset-ring-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:inset-ring-amber-900",
  "green": "bg-green-50 text-green-700 inset-ring-green-200 dark:bg-green-950 dark:text-green-300 dark:inset-ring-green-900",
  "red": "bg-red-50 text-red-700 inset-ring-red-200 dark:bg-red-950 dark:text-red-300 dark:inset-ring-red-900",
  "violet": "bg-violet-50 text-violet-700 inset-ring-violet-200 dark:bg-violet-950 dark:text-violet-300 dark:inset-ring-violet-900",
  "pink": "bg-pink-50 text-pink-700 inset-ring-pink-200 dark:bg-pink-950 dark:text-pink-300 dark:inset-ring-pink-900",
  "orange": "bg-orange-50 text-orange-700 inset-ring-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:inset-ring-orange-900",
  "cyan": "bg-cyan-50 text-cyan-700 inset-ring-cyan-200 dark:bg-cyan-950 dark:text-cyan-300 dark:inset-ring-cyan-900",
};

export type PillProps = {
  tone?: "gray" | "blue" | "amber" | "green" | "red" | "violet" | "pink" | "orange" | "cyan";
  icon?: string;
  className?: string;
  children?: ReactNode;
};

export function Pill({ tone = "gray", icon, className, children }: PillProps) {
  return (
    <Box className="contents">
      <Inline
        className={cn(
          "inline-flex h-6 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-medium whitespace-nowrap inset-ring",
          at(PILL, tone),
          className
        )}
        data-slot="pill"
      >
        {icon ? (
          <LucideIcon name={icon} size={12} />
        ) : null}
        {children}
      </Inline>
    </Box>
  );
}

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 pill
components/pill.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 status pill: a tinted label with an icon (published, draft, role, comment state). -->
<script lang="ts">
export type PillProps = {
  tone?: "gray" | "blue" | "amber" | "green" | "red" | "violet" | "pink" | "orange" | "cyan";
  icon?: string;
  class?: string;
};
</script>

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

const PILL: Record<string, string> = {
  "gray": "bg-muted text-muted-foreground inset-ring-border",
  "blue": "bg-blue-50 text-blue-700 inset-ring-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:inset-ring-blue-900",
  "amber": "bg-amber-50 text-amber-700 inset-ring-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:inset-ring-amber-900",
  "green": "bg-green-50 text-green-700 inset-ring-green-200 dark:bg-green-950 dark:text-green-300 dark:inset-ring-green-900",
  "red": "bg-red-50 text-red-700 inset-ring-red-200 dark:bg-red-950 dark:text-red-300 dark:inset-ring-red-900",
  "violet": "bg-violet-50 text-violet-700 inset-ring-violet-200 dark:bg-violet-950 dark:text-violet-300 dark:inset-ring-violet-900",
  "pink": "bg-pink-50 text-pink-700 inset-ring-pink-200 dark:bg-pink-950 dark:text-pink-300 dark:inset-ring-pink-900",
  "orange": "bg-orange-50 text-orange-700 inset-ring-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:inset-ring-orange-900",
  "cyan": "bg-cyan-50 text-cyan-700 inset-ring-cyan-200 dark:bg-cyan-950 dark:text-cyan-300 dark:inset-ring-cyan-900",
};
const { tone = "gray", icon, class: className } = defineProps<PillProps>();
defineSlots<{ default?(): unknown }>();
</script>

<template>
  <Box class="contents">
    <Inline
      :class="cn(
        'inline-flex h-6 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-medium whitespace-nowrap inset-ring',
        at(PILL, tone),
        className
      )"
      data-slot="pill"
    >
      <LucideIcon v-if="icon" :name="icon" :size="12" />
      <slot />
    </Inline>
  </Box>
</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 pill
components/pill.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 status pill: a tinted label with an icon (published, draft, role, comment state). */
import { type JSX } from "solid-js";
import { Box, Inline } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { at, cn } from "../utils";

const PILL: Record<string, string> = {
  "gray": "bg-muted text-muted-foreground inset-ring-border",
  "blue": "bg-blue-50 text-blue-700 inset-ring-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:inset-ring-blue-900",
  "amber": "bg-amber-50 text-amber-700 inset-ring-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:inset-ring-amber-900",
  "green": "bg-green-50 text-green-700 inset-ring-green-200 dark:bg-green-950 dark:text-green-300 dark:inset-ring-green-900",
  "red": "bg-red-50 text-red-700 inset-ring-red-200 dark:bg-red-950 dark:text-red-300 dark:inset-ring-red-900",
  "violet": "bg-violet-50 text-violet-700 inset-ring-violet-200 dark:bg-violet-950 dark:text-violet-300 dark:inset-ring-violet-900",
  "pink": "bg-pink-50 text-pink-700 inset-ring-pink-200 dark:bg-pink-950 dark:text-pink-300 dark:inset-ring-pink-900",
  "orange": "bg-orange-50 text-orange-700 inset-ring-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:inset-ring-orange-900",
  "cyan": "bg-cyan-50 text-cyan-700 inset-ring-cyan-200 dark:bg-cyan-950 dark:text-cyan-300 dark:inset-ring-cyan-900",
};

export type PillProps = {
  tone?: "gray" | "blue" | "amber" | "green" | "red" | "violet" | "pink" | "orange" | "cyan";
  icon?: string;
  class?: string;
  children?: JSX.Element;
};

export function Pill({ tone = "gray", icon, class: className, children }: PillProps) {
  return (
    <Box class="contents">
      <Inline
        class={cn(
          "inline-flex h-6 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-medium whitespace-nowrap inset-ring",
          at(PILL, tone),
          className
        )}
        data-slot="pill"
      >
        {icon ? (
          <LucideIcon name={icon} size={12} />
        ) : null}
        {children}
      </Inline>
    </Box>
  );
}

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 pill
blocks/pill.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/pill.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/icons"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// PillProps are the props of Pill; the values are the JSON shapes of the TypeScript props.
type PillProps struct {
	Tone any `json:"tone"`
	Icon any `json:"icon"`
	Class string `json:"className"`
}

var pillPill = map[string]any{
	"gray": "bg-muted text-muted-foreground inset-ring-border",
	"blue": "bg-blue-50 text-blue-700 inset-ring-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:inset-ring-blue-900",
	"amber": "bg-amber-50 text-amber-700 inset-ring-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:inset-ring-amber-900",
	"green": "bg-green-50 text-green-700 inset-ring-green-200 dark:bg-green-950 dark:text-green-300 dark:inset-ring-green-900",
	"red": "bg-red-50 text-red-700 inset-ring-red-200 dark:bg-red-950 dark:text-red-300 dark:inset-ring-red-900",
	"violet": "bg-violet-50 text-violet-700 inset-ring-violet-200 dark:bg-violet-950 dark:text-violet-300 dark:inset-ring-violet-900",
	"pink": "bg-pink-50 text-pink-700 inset-ring-pink-200 dark:bg-pink-950 dark:text-pink-300 dark:inset-ring-pink-900",
	"orange": "bg-orange-50 text-orange-700 inset-ring-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:inset-ring-orange-900",
	"cyan": "bg-cyan-50 text-cyan-700 inset-ring-cyan-200 dark:bg-cyan-950 dark:text-cyan-300 dark:inset-ring-cyan-900",
}

// A status pill: a tinted label with an icon (published, draft, role, comment state).
templ Pill(p PillProps) {
	{{ vTone := uiutils.Def(p.Tone, "gray") }}
	{{ vIcon := p.Icon }}
	@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "contents"}}) {
		@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: uiutils.S(uiutils.Cnv("inline-flex h-6 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-medium whitespace-nowrap inset-ring", uiutils.At(pillPill, vTone), p.Class)), Attrs: uiutils.Attrs("data-slot", "pill")}}) {
			if uiutils.T(vIcon) {
				@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(vIcon), Size: 12})
			}
			{ 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 pill
blocks/pill.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/pill.json
    A status pill: a tinted label with an icon (published, draft, role, comment state).
    Props (p): tone, icon, className; children: markup. -#}
{%- set k_PILL = {'gray': 'bg-muted text-muted-foreground inset-ring-border', 'blue': 'bg-blue-50 text-blue-700 inset-ring-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:inset-ring-blue-900', 'amber': 'bg-amber-50 text-amber-700 inset-ring-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:inset-ring-amber-900', 'green': 'bg-green-50 text-green-700 inset-ring-green-200 dark:bg-green-950 dark:text-green-300 dark:inset-ring-green-900', 'red': 'bg-red-50 text-red-700 inset-ring-red-200 dark:bg-red-950 dark:text-red-300 dark:inset-ring-red-900', 'violet': 'bg-violet-50 text-violet-700 inset-ring-violet-200 dark:bg-violet-950 dark:text-violet-300 dark:inset-ring-violet-900', 'pink': 'bg-pink-50 text-pink-700 inset-ring-pink-200 dark:bg-pink-950 dark:text-pink-300 dark:inset-ring-pink-900', 'orange': 'bg-orange-50 text-orange-700 inset-ring-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:inset-ring-orange-900', 'cyan': 'bg-cyan-50 text-cyan-700 inset-ring-cyan-200 dark:bg-cyan-950 dark:text-cyan-300 dark:inset-ring-cyan-900'} -%}
{%- set v_tone = (p.tone ?? 'gray') -%}
{%- set v_icon = (p.icon ?? null) -%}
{%- set c_2 -%}
  {%- set c_1 -%}
    {%- if og_t(v_icon) %}
      {{ include('icons/LucideIcon.html.twig', {'name': og_s(v_icon), 'size': 12}, with_context = false) }}
    {%- endif %}
    {{ og_slot((children ?? null))|raw }}
  {%- endset -%}
  {{ include('compose/Inline.html.twig', {'class': og_s(og_cnv(['inline-flex h-6 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-medium whitespace-nowrap inset-ring', og_at(k_PILL, v_tone), (p.className ?? '')])), 'attrs': og_attrs(['data-slot', 'pill']), 'children': c_1}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'contents', 'children': c_2}, 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 pill
blocks/pill.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/pill.json
    A status pill: a tinted label with an icon (published, draft, role, comment state).
    Props (p): tone, icon, className; children: markup. *}
{var $k_PILL = ['gray' => 'bg-muted text-muted-foreground inset-ring-border', 'blue' => 'bg-blue-50 text-blue-700 inset-ring-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:inset-ring-blue-900', 'amber' => 'bg-amber-50 text-amber-700 inset-ring-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:inset-ring-amber-900', 'green' => 'bg-green-50 text-green-700 inset-ring-green-200 dark:bg-green-950 dark:text-green-300 dark:inset-ring-green-900', 'red' => 'bg-red-50 text-red-700 inset-ring-red-200 dark:bg-red-950 dark:text-red-300 dark:inset-ring-red-900', 'violet' => 'bg-violet-50 text-violet-700 inset-ring-violet-200 dark:bg-violet-950 dark:text-violet-300 dark:inset-ring-violet-900', 'pink' => 'bg-pink-50 text-pink-700 inset-ring-pink-200 dark:bg-pink-950 dark:text-pink-300 dark:inset-ring-pink-900', 'orange' => 'bg-orange-50 text-orange-700 inset-ring-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:inset-ring-orange-900', 'cyan' => 'bg-cyan-50 text-cyan-700 inset-ring-cyan-200 dark:bg-cyan-950 dark:text-cyan-300 dark:inset-ring-cyan-900']}
{var $v_tone = ($p['tone'] ?? 'gray')}
{var $v_icon = ($p['icon'] ?? null)}
{capture $c_2}
  {capture $c_1}
    {if og_t($v_icon)}
      {=og_include('icons/LucideIcon.latte', ['name' => og_s($v_icon), 'size' => 12])|noescape}
    {/if}
    {=og_slot(($children ?? null))|noescape}
  {/capture}
  {=og_include('compose/Inline.latte', ['class' => og_s(og_cnv(['inline-flex h-6 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-medium whitespace-nowrap inset-ring', og_at($k_PILL, $v_tone), ($p['className'] ?? '')])), 'attrs' => og_attrs(['data-slot', 'pill']), 'children' => (string) $c_1])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'contents', 'children' => (string) $c_2])|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 pill
blocks/pill.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/pill.json
    A status pill: a tinted label with an icon (published, draft, role, comment state).
    Props (p): tone, icon, className; children: markup. -#}
{%- set k_PILL = {'gray': 'bg-muted text-muted-foreground inset-ring-border', 'blue': 'bg-blue-50 text-blue-700 inset-ring-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:inset-ring-blue-900', 'amber': 'bg-amber-50 text-amber-700 inset-ring-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:inset-ring-amber-900', 'green': 'bg-green-50 text-green-700 inset-ring-green-200 dark:bg-green-950 dark:text-green-300 dark:inset-ring-green-900', 'red': 'bg-red-50 text-red-700 inset-ring-red-200 dark:bg-red-950 dark:text-red-300 dark:inset-ring-red-900', 'violet': 'bg-violet-50 text-violet-700 inset-ring-violet-200 dark:bg-violet-950 dark:text-violet-300 dark:inset-ring-violet-900', 'pink': 'bg-pink-50 text-pink-700 inset-ring-pink-200 dark:bg-pink-950 dark:text-pink-300 dark:inset-ring-pink-900', 'orange': 'bg-orange-50 text-orange-700 inset-ring-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:inset-ring-orange-900', 'cyan': 'bg-cyan-50 text-cyan-700 inset-ring-cyan-200 dark:bg-cyan-950 dark:text-cyan-300 dark:inset-ring-cyan-900'} -%}
{%- set v_tone = og_def(p['tone'], 'gray') -%}
{%- set v_icon = og_def(p['icon'], none) -%}
{%- set c_2 -%}
  {%- set c_1 -%}
    {%- if og_t(v_icon) %}
      {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(v_icon), 'Size': 12}}) }}
    {%- endif %}
    {{ og_slot(og_def(children, none))|safe }}
  {%- endset -%}
  {{ og_include('compose/inline.html.j2', {'p': {'Class': og_s(og_cnv(['inline-flex h-6 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-medium whitespace-nowrap inset-ring', og_at(k_PILL, v_tone), og_def(p['className'], '')])), 'Attrs': og_attrs(['data-slot', 'pill'])}, 'children': c_1}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'contents'}, 'children': c_2}) }}

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 status pill: a tinted label with an icon (published, draft, role, comment state).

Props of Pill
PropTypeDefault Description
tone "gray" | "blue" | "amber" | "green" | "red" | "violet" | "pink" | "orange" | "cyan""gray"tint
icon string-Lucide name

Used in