PeakUI

Chip

A compact label for statuses, filters and attributes

Usage

import {Chip} from "@peakui/react";

Examples

Sizes

Colors

Variants

With Icons

Icons are plain children of the root; the label stays in Chip.Label.

Statuses

A small glyph before the label turns a chip into a status.

Customization

Tailwind CSS

<Chip className="rounded-full">Label</Chip>

Global CSS

@layer components {
  .chip {
    --chip-bg: var(--color-accent-soft);
    --chip-fg: var(--color-accent-soft-foreground);
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The Chip component uses these CSS classes (view source styles):

Base & Size Classes

  • .chip - Base chip styles; carries the md size
  • .chip--sm - Small size
  • .chip--md - Medium size; empty, the base class carries it
  • .chip--lg - Large size

Variant Classes

  • .chip--primary - Solid background, set per color by a compound class
  • .chip--secondary - Neutral background; no additional styles
  • .chip--tertiary - Transparent background
  • .chip--soft - Muted background, set per color by a compound class

Color Classes

  • .chip--accent
  • .chip--default
  • .chip--success
  • .chip--warning
  • .chip--danger

Element Classes

  • .chip__label - The label; adds horizontal padding

Slots

  • [data-slot="chip"] - The root element
  • [data-slot="chip-label"] - The label element

CSS Variables

VariablePurpose
--chip-bgChip background color
--chip-fgChip text color

API Reference

Chip

PropTypeDefaultDescription
childrenReactNode-Chip content; strings and numbers become the label (required)
color'accent' | 'danger' | 'default' | 'success' | 'warning''default'Chip color
size'sm' | 'md' | 'lg'-Chip size; the base class already carries md
variant'primary' | 'secondary' | 'soft' | 'tertiary''secondary'Chip variant
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element

Every other attribute of a <span> is accepted.

Chip.Label

PropTypeDefaultDescription
childrenReactNode-Label content
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element

Every other attribute of a <span> is accepted.

On this page