# Value Pill

A plain value, such as a date or an amount, set off in text.

Inline value badge: a plain value (a date, a name, a count) set off in prose. Softer than a status pill (no dot) and not a mono token. Stays on one line while it fits; a value longer than its container wraps inside the pill and is never truncated. The value reads in its own direction (unicode-bidi: plaintext): a signed number stays "-4.41%" on a right-to-left page.

Kind: component · Category: Display · Status: stable · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add value-pill
```

It writes the folder `value-pill/` into the project's ui folder (`index.ts`, `value-pill.tsx`, `ValuePill.vue`, `ValuePill.svelte`, `value-pill.recipe.ts`). First time: [Installation](/installation.md).

## Usage

```tsx
import { ValuePill } from "@/components/ui/value-pill";
```

```vue
import { ValuePill } from "@/components/ui/value-pill";
```

```svelte
import { ValuePill } from "$lib/components/ui/value-pill";
```

## Parts

In the DOM the root carries `data-slot="value-pill"` and each part `data-slot="value-pill-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `span` | `value-pill` |  |  |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `tone` | `"neutral" \| "green" \| "orange" \| "red" \| "accent"` | `"neutral"` |  |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Slots

| Slot | Content |
| --- | --- |
| `default` | Value |

## Keyboard and accessibility

Notes:

- Plain text in a span; tone is decoration.
- unicode-bidi: plaintext on the pill: a value with no strong direction (a signed number, a date) is laid out left to right on either page, and a right-to-left value right to left.

## Tokens

`color.field`, `color.ink-2`, `color.green`, `color.green-tint`, `color.orange`, `color.orange-tint`, `color.red`, `color.red-tint`, `color.accent`, `color.accent-ink`, `color.accent-tint`, `shadow.hairline`, `radius.pill`, `text.xs`

## Examples

### Usage summary

React · `usage-summary.tsx`

```tsx
import { ValuePill } from "@/components/ui/value-pill";

export default function UsageSummary() {
  return (
    <p className="max-w-[300px] text-md text-ink">
      web-app has used <ValuePill tone="orange">4,920 of 6,000</ValuePill> build minutes this month. The count resets on <ValuePill>Dec 1, 2026</ValuePill>; the <ValuePill>Business</ValuePill> plan includes 20,000.
    </p>
  );
}
```

Vue · `usage-summary.vue`

```vue
<script setup lang="ts">
import { ValuePill } from "@/components/ui/value-pill";
</script>

<template>
  <p class="max-w-[300px] text-md text-ink">
    web-app has used <ValuePill tone="orange">4,920 of 6,000</ValuePill> build minutes this month. The count resets on <ValuePill>Dec 1, 2026</ValuePill>; the <ValuePill>Business</ValuePill> plan includes 20,000.
  </p>
</template>
```

Svelte · `usage-summary.svelte`

```svelte
<script lang="ts">
  import { ValuePill } from "$lib/components/ui/value-pill";
</script>

<p class="max-w-[300px] text-md text-ink">
  web-app has used <ValuePill tone="orange">4,920 of 6,000</ValuePill> build minutes this month. The count resets on <ValuePill>Dec 1, 2026</ValuePill>; the <ValuePill>Business</ValuePill> plan includes 20,000.
</p>
```

### Uptime report

React · `uptime.tsx`

```tsx
import { ValuePill } from "@/components/ui/value-pill";

export default function Uptime() {
  return (
    <p className="max-w-[300px] text-md text-ink">
      Production answered <ValuePill tone="green">99.98%</ValuePill> of requests in the last 30 days, with a median response of <ValuePill>142 ms</ValuePill>.
    </p>
  );
}
```

Vue · `uptime.vue`

```vue
<script setup lang="ts">
import { ValuePill } from "@/components/ui/value-pill";
</script>

<template>
  <p class="max-w-[300px] text-md text-ink">
    Production answered <ValuePill tone="green">99.98%</ValuePill> of requests in the last 30 days, with a median response of <ValuePill>142 ms</ValuePill>.
  </p>
</template>
```

Svelte · `uptime.svelte`

```svelte
<script lang="ts">
  import { ValuePill } from "$lib/components/ui/value-pill";
</script>

<p class="max-w-[300px] text-md text-ink">
  Production answered <ValuePill tone="green">99.98%</ValuePill> of requests in the last 30 days, with a median response of <ValuePill>142 ms</ValuePill>.
</p>
```

### Payment declined

React · `payment-failed.tsx`

```tsx
import { ValuePill } from "@/components/ui/value-pill";

export default function PaymentFailed() {
  return (
    <p className="max-w-[300px] text-md text-ink">
      The charge of <ValuePill tone="red">$1,240.00</ValuePill> for <ValuePill>INV-2024-0117</ValuePill> was declined. We will try the card again on <ValuePill>Nov 18, 2026</ValuePill>.
    </p>
  );
}
```

Vue · `payment-failed.vue`

```vue
<script setup lang="ts">
import { ValuePill } from "@/components/ui/value-pill";
</script>

<template>
  <p class="max-w-[300px] text-md text-ink">
    The charge of <ValuePill tone="red">$1,240.00</ValuePill> for <ValuePill>INV-2024-0117</ValuePill> was declined. We will try the card again on <ValuePill>Nov 18, 2026</ValuePill>.
  </p>
</template>
```

Svelte · `payment-failed.svelte`

```svelte
<script lang="ts">
  import { ValuePill } from "$lib/components/ui/value-pill";
</script>

<p class="max-w-[300px] text-md text-ink">
  The charge of <ValuePill tone="red">$1,240.00</ValuePill> for <ValuePill>INV-2024-0117</ValuePill> was declined. We will try the card again on <ValuePill>Nov 18, 2026</ValuePill>.
</p>
```

### Seats left on the plan

React · `seats-left.tsx`

```tsx
import { ValuePill } from "@/components/ui/value-pill";

export default function SeatsLeft() {
  return (
    <p className="max-w-[300px] text-md text-ink">
      You have <ValuePill tone="accent">8 seats</ValuePill> left on the Team plan, enough for the <ValuePill>Platform team</ValuePill> invite.
    </p>
  );
}
```

Vue · `seats-left.vue`

```vue
<script setup lang="ts">
import { ValuePill } from "@/components/ui/value-pill";
</script>

<template>
  <p class="max-w-[300px] text-md text-ink">
    You have <ValuePill tone="accent">8 seats</ValuePill> left on the Team plan, enough for the <ValuePill>Platform team</ValuePill> invite.
  </p>
</template>
```

Svelte · `seats-left.svelte`

```svelte
<script lang="ts">
  import { ValuePill } from "$lib/components/ui/value-pill";
</script>

<p class="max-w-[300px] text-md text-ink">
  You have <ValuePill tone="accent">8 seats</ValuePill> left on the Team plan, enough for the <ValuePill>Platform team</ValuePill> invite.
</p>
```

## Recipe

`value-pill.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* value-pill — a plain value (a date, a name, a count) set off in prose.
 * No dot, no state; the ring is a 28% tint of the tone. It stays on one line while it fits its
 * container; a value longer than the container wraps inside the pill, never truncates.
 * The value reads in its own direction on either page: a signed number stays "-4.41%".
 *
 * No motion; one element, so the recipe is `base` only. */

export const valuePill = tv({
  base: [
    /* the inline margins stay inside the container */
    "inline-flex shrink-0 items-center max-w-[calc(100%-4px)] mx-0.5 px-1.5 rounded-pill align-middle",
    "bg-field text-ink-2 shadow-hairline",
    "text-xs font-medium tabular-nums leading-[1.5] wrap-anywhere [unicode-bidi:plaintext]",
  ],
  variants: {
    tone: {
      neutral: "",
      green: "bg-green-tint text-green shadow-[0_0_0_1px_color-mix(in_oklch,var(--fndn-green)_28%,transparent)]",
      orange: "bg-orange-tint text-orange shadow-[0_0_0_1px_color-mix(in_oklch,var(--fndn-orange)_28%,transparent)]",
      red: "bg-red-tint text-red shadow-[0_0_0_1px_color-mix(in_oklch,var(--fndn-red)_28%,transparent)]",
      accent: "bg-accent-tint text-accent-ink shadow-[0_0_0_1px_color-mix(in_oklch,var(--fndn-accent)_28%,transparent)]",
    },
  },
  defaultVariants: { tone: "neutral" },
});

export type ValuePillRecipeProps = VariantProps<typeof valuePill>;
```
