Micro

A pill holding one small reading or control: a count with its trend, a ring, a timecode, a stepper.

'use client';

import { useEffect, useState } from 'react';
import {
  Add01Icon,
  Bookmark01Icon,
  Clock01Icon,
  GoForward15SecIcon,
  PauseIcon,
  PlayIcon,
  GoBackward15SecIcon,
  Search01Icon,
  Share08Icon,
  Tick02Icon,
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';
import { Micro } from '@/components/panelui/micro';

const LENGTH = 52 * 60 + 10;

function clock(seconds: number) {
  const m = Math.floor(seconds / 60);
  const s = seconds % 60;
  return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`;
}

export default function MicroOverview() {
  const [playing, setPlaying] = useState(false);
  const [time, setTime] = useState(18 * 60 + 42);
  const [speed, setSpeed] = useState(1);
  const [part, setPart] = useState('interview');
  const [exporting, setExporting] = useState(true);
  const [exported, setExported] = useState(5);
  const [denoise, setDenoise] = useState(true);

  useEffect(() => {
    if (!playing) return;
    const timer = window.setInterval(() => setTime((value) => Math.min(LENGTH, value + 1)), 1000 / speed);
    return () => window.clearInterval(timer);
  }, [playing, speed]);

  useEffect(() => {
    if (!exporting || exported >= 12) return;
    const timer = window.setTimeout(() => setExported((value) => value + 1), 1500);
    return () => window.clearTimeout(timer);
  }, [exporting, exported]);

  return (
    <div className="flex w-full max-w-4xl flex-wrap items-center justify-center gap-3">
      <Micro>
        <Micro.Text value="12.4k" label="listens · 30 days" />
        <Micro.Spark values={[4, 5, 4, 6, 6, 7, 6, 8, 9, 11]} tone="info" />
        <Micro.Delta value={9} />
      </Micro>
      <Micro>
        <Micro.Text value="41:08" label="average listen" />
        <Micro.Spark values={[6, 6, 7, 6, 7, 8, 7, 8, 8, 9]} />
        <Micro.Delta value={4} />
      </Micro>
      <Micro>
        <Micro.Ring value={72} tone="info" label="Finish rate" />
        <Micro.Text value="72%" label="finish rate" />
      </Micro>

      <Micro>
        <Micro.Button aria-label={playing ? 'Pause' : 'Play'} onClick={() => setPlaying(!playing)}>
          {playing ? <HugeiconsIcon icon={PauseIcon} /> : <HugeiconsIcon icon={PlayIcon} />}
        </Micro.Button>
        <Micro.Button
          variant="ghost"
          aria-label="Back 15 seconds"
          onClick={() => setTime((value) => Math.max(0, value - 15))}
        >
          <HugeiconsIcon icon={GoBackward15SecIcon} />
        </Micro.Button>
        <Micro.Button
          variant="ghost"
          aria-label="Forward 15 seconds"
          onClick={() => setTime((value) => Math.min(LENGTH, value + 15))}
        >
          <HugeiconsIcon icon={GoForward15SecIcon} />
        </Micro.Button>
        <Micro.Separator />
        <span>
          <Micro.Mono>{clock(time)}</Micro.Mono> <Micro.Mono muted>/ {clock(LENGTH)}</Micro.Mono>
        </span>
      </Micro>
      <Micro>
        <Micro.Segments value={part} onValueChange={setPart} aria-label="Section">
          <Micro.Segment value="intro">Intro</Micro.Segment>
          <Micro.Segment value="interview">Interview</Micro.Segment>
          <Micro.Segment value="outro">Outro</Micro.Segment>
        </Micro.Segments>
        <Micro.Button variant="ghost" aria-label="Add a section">
          <HugeiconsIcon icon={Add01Icon} />
        </Micro.Button>
      </Micro>
      <Micro>
        <Micro.Label>Speed</Micro.Label>
        <Micro.Stepper
          value={speed}
          onValueChange={setSpeed}
          min={0.5}
          max={2}
          step={0.25}
          suffix="×"
          format={{ minimumFractionDigits: 1, maximumFractionDigits: 2 }}
          label="Playback speed"
        />
      </Micro>
      <Micro>
        <Micro.Button variant="ghost" aria-label="Bookmark">
          <HugeiconsIcon icon={Bookmark01Icon} />
        </Micro.Button>
        <Micro.Button variant="ghost" aria-label="Share">
          <HugeiconsIcon icon={Share08Icon} />
        </Micro.Button>
      </Micro>

      <Micro>
        <Micro.Pulse tone="success" />
        <Micro.Mono>−14</Micro.Mono>
        <Micro.Label>LUFS</Micro.Label>
      </Micro>
      <Micro className="w-64">
        <Micro.Progress
          label={exported >= 12 ? 'Exported' : 'Exporting'}
          value={exported}
          max={12}
          tone="info"
          className="flex-1"
        />
        <Micro.Button
          aria-label={exported >= 12 ? 'Export again' : exporting ? 'Pause export' : 'Resume export'}
          onClick={() => (exported >= 12 ? setExported(0) : setExporting(!exporting))}
        >
          {exported >= 12 ? (
            <HugeiconsIcon icon={Tick02Icon} />
          ) : exporting ? (
            <HugeiconsIcon icon={PauseIcon} />
          ) : (
            <HugeiconsIcon icon={PlayIcon} />
          )}
        </Micro.Button>
      </Micro>
      <Micro>
        <Micro.Faces
          people={[
            { name: 'Khalid Abdi', src: 'https://avatars.githubusercontent.com/u/127331761?v=4' },
            { name: 'Ines Duarte' },
            { name: 'Sam Whitlock' },
          ]}
        />
        <Micro.Label className="text-foreground">Approved</Micro.Label>
        <HugeiconsIcon icon={Tick02Icon} className="size-4 text-success-foreground" aria-hidden="true" />
      </Micro>

      <Micro className="w-80">
        <HugeiconsIcon icon={Search01Icon} className="size-4 shrink-0 text-muted-foreground" aria-hidden="true" />
        <Micro.Input placeholder="Find a word in this episode" aria-label="Find in episode" />
        <Micro.Kbd>⌘F</Micro.Kbd>
      </Micro>
      <Micro>
        <Micro.Text value="Remove noise" label="this episode only" />
        <Micro.Switch checked={denoise} onCheckedChange={setDenoise} label="Remove noise" color="info" />
      </Micro>
      <Micro>
        <HugeiconsIcon icon={Clock01Icon} className="size-4 shrink-0 text-muted-foreground" aria-hidden="true" />
        <Micro.Mono>3,180</Micro.Mono>
        <Micro.Label>minutes left</Micro.Label>
      </Micro>
    </div>
  );
}

Use it for the small readings and controls that sit around a piece of work rather than in a form: a count with its trend, a percentage, a timecode with play and skip, a speed, which section is showing, how far an export has got. Every pill has the same height and surface, so a row of them reads as one strip of instruments.

A pill is built from parts written in the order they read. Each pill in the board above has its own example further down this page. At an end that is a round button, a segmented choice or a ring, the pill pulls its padding in so the circle sits concentric with it.

For a single figure with a label and a badge, use Stat. For a status word, use Badge.

Installation

npx shadcn@latest add https://panelui.dev/r/web/micro.json

The source is copied into components/panelui/, where you can edit it.

Usage

import { Micro } from "@/components/panelui/micro"
<Micro>
  <Micro.Text value="12.4k" label="listens · 30 days" />
  <Micro.Spark values={[4, 5, 4, 6, 7, 8, 11]} tone="info" />
  <Micro.Delta value={9} />
</Micro>

Composition

<Micro>
  <Micro.Text />
  <Micro.Label />
  <Micro.Mono />
  <Micro.Spark />
  <Micro.Ring />
  <Micro.Delta />
  <Micro.Pulse />
  <Micro.Button />
  <Micro.Separator />
  <Micro.Segments>
    <Micro.Segment />
  </Micro.Segments>
  <Micro.Stepper />
  <Micro.Progress />
  <Micro.Switch />
  <Micro.Faces />
  <Micro.Input />
  <Micro.Kbd />
</Micro>
  • Micro.Text — A value over a muted line saying what it is.
  • Micro.Label — One muted word or phrase on a single line, such as "Speed".
  • Micro.Mono — A reading in mono figures, for times and counts that change in place. muted dims it, for the second half of a pair.
  • Micro.Spark — A run of thin bars, oldest first. The newest is drawn in tone. They rise when first shown.
  • Micro.Ring — A ring that sweeps to value, from 0 to 100. It is a meter, named by label.
  • Micro.Delta — A change with its sign and an arrow, green when up and red when down. inverted swaps them, for a reading where lower is better.
  • Micro.Pulse — A heartbeat line that beats while live, for a reading taken continuously.
  • Micro.Button — A round button. ghost shows its circle only when pointed at, and aria-pressed fills it.
  • Micro.Separator — A short upright rule between two groups.
  • Micro.Segments — A choice of a few, with a marker that slides to the chosen one. The arrow keys move it.
  • Micro.Segment — One choice, by its value.
  • Micro.Stepper — A number between a minus and a plus, with min, max and step. Its digits roll as it changes, and the arrow keys move it.
  • Micro.Progress — A label and a count over a row of ticks that fill as the work is done: one tick each, up to 16.
  • Micro.Switch — A switch sized for the pill. Put a Micro.Text before it for what it turns on.
  • Micro.Faces — Overlapping faces, with initials where there is no picture. Four show and the rest are counted.
  • Micro.Input — A bare field that takes the pill's remaining width.
  • Micro.Kbd — A key or a chord in a cap.

Examples

A count and its trend

Micro.Text gives the value and what it counts. Micro.Spark draws its recent values as bars, oldest first, with the newest in tone. Micro.Delta says how much it moved.

import { Micro } from '@/components/panelui/micro';

export default function MicroStat() {
  return (
    <Micro>
      <Micro.Text value="12.4k" label="listens · 30 days" />
      <Micro.Spark values={[4, 5, 4, 6, 6, 7, 6, 8, 9, 11]} tone="info" />
      <Micro.Delta value={9} />
    </Micro>
  );
}

A percentage

Micro.Ring sweeps to value, from 0 to 100. At the pill's start it is pulled in to sit concentric with the end. Give it a label, since it is read as a meter.

import { Micro } from '@/components/panelui/micro';

export default function MicroRingDemo() {
  return (
    <Micro>
      <Micro.Ring value={72} tone="info" label="Finish rate" />
      <Micro.Text value="72%" label="finish rate" />
    </Micro>
  );
}

Playback

A solid Micro.Button for the main action and variant="ghost" buttons for the rest. Micro.Separator sets the time apart, and Micro.Mono keeps its figures from shifting as they change. muted dims the total.

'use client';

import { useEffect, useState } from 'react';
import { GoBackward15SecIcon, GoForward15SecIcon, PauseIcon, PlayIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';
import { Micro } from '@/components/panelui/micro';

const LENGTH = 52 * 60 + 10;

function clock(seconds: number) {
  return `${String(Math.floor(seconds / 60)).padStart(2, '0')}:${String(seconds % 60).padStart(2, '0')}`;
}

export default function MicroTransport() {
  const [playing, setPlaying] = useState(false);
  const [time, setTime] = useState(18 * 60 + 42);

  useEffect(() => {
    if (!playing) return;
    const timer = window.setInterval(() => setTime((value) => Math.min(LENGTH, value + 1)), 1000);
    return () => window.clearInterval(timer);
  }, [playing]);

  return (
    <Micro>
      <Micro.Button aria-label={playing ? 'Pause' : 'Play'} onClick={() => setPlaying(!playing)}>
        <HugeiconsIcon icon={playing ? PauseIcon : PlayIcon} />
      </Micro.Button>
      <Micro.Button
        variant="ghost"
        aria-label="Back 15 seconds"
        onClick={() => setTime((value) => Math.max(0, value - 15))}
      >
        <HugeiconsIcon icon={GoBackward15SecIcon} />
      </Micro.Button>
      <Micro.Button
        variant="ghost"
        aria-label="Forward 15 seconds"
        onClick={() => setTime((value) => Math.min(LENGTH, value + 15))}
      >
        <HugeiconsIcon icon={GoForward15SecIcon} />
      </Micro.Button>
      <Micro.Separator />
      <span>
        <Micro.Mono>{clock(time)}</Micro.Mono> <Micro.Mono muted>/ {clock(LENGTH)}</Micro.Mono>
      </span>
    </Micro>
  );
}

A choice of a few

Micro.Segments holds Micro.Segments, with a marker that slides to the chosen one. The arrow keys move it. A ghost button after it adds to the choices.

'use client';

import { useState } from 'react';
import { Add01Icon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';
import { Micro } from '@/components/panelui/micro';

export default function MicroSegmentsDemo() {
  const [part, setPart] = useState('interview');
  return (
    <Micro>
      <Micro.Segments value={part} onValueChange={setPart} aria-label="Section">
        <Micro.Segment value="intro">Intro</Micro.Segment>
        <Micro.Segment value="interview">Interview</Micro.Segment>
        <Micro.Segment value="outro">Outro</Micro.Segment>
      </Micro.Segments>
      <Micro.Button variant="ghost" aria-label="Add a section">
        <HugeiconsIcon icon={Add01Icon} />
      </Micro.Button>
    </Micro>
  );
}

A number between bounds

Micro.Stepper sits between a minus and a plus, with min, max and step. Its digits roll as it changes, and the arrow keys, Home and End move it once it has focus. format and suffix set how it is written.

'use client';

import { useState } from 'react';
import { Micro } from '@/components/panelui/micro';

export default function MicroStepperDemo() {
  const [speed, setSpeed] = useState(1);
  return (
    <Micro>
      <Micro.Label>Speed</Micro.Label>
      <Micro.Stepper
        value={speed}
        onValueChange={setSpeed}
        min={0.5}
        max={2}
        step={0.25}
        suffix="×"
        format={{ minimumFractionDigits: 1, maximumFractionDigits: 2 }}
        label="Playback speed"
      />
    </Micro>
  );
}

A pair of actions

Ghost buttons on their own make a pill of icon actions. aria-pressed fills a button that stays on, such as a bookmark.

'use client';

import { useState } from 'react';
import { Bookmark01Icon, Share08Icon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';
import { Micro } from '@/components/panelui/micro';

export default function MicroActions() {
  const [saved, setSaved] = useState(false);
  return (
    <Micro>
      <Micro.Button variant="ghost" aria-label="Bookmark" aria-pressed={saved} onClick={() => setSaved(!saved)}>
        <HugeiconsIcon icon={Bookmark01Icon} />
      </Micro.Button>
      <Micro.Separator />
      <Micro.Button variant="ghost" aria-label="Share">
        <HugeiconsIcon icon={Share08Icon} />
      </Micro.Button>
    </Micro>
  );
}

A live reading

Micro.Pulse beats beside a reading taken continuously, in tone. Micro.Delta with inverted draws a rise in red, for a reading where lower is better.

import { Micro } from '@/components/panelui/micro';

export default function MicroLive() {
  return (
    <div className="flex flex-wrap items-center justify-center gap-3">
      <Micro>
        <Micro.Pulse tone="success" />
        <Micro.Mono>−14</Micro.Mono>
        <Micro.Label>LUFS</Micro.Label>
      </Micro>
      <Micro>
        <Micro.Pulse tone="warning" />
        <Micro.Mono>412 ms</Micro.Mono>
        <Micro.Delta value={9} unit=" ms" inverted />
      </Micro>
    </div>
  );
}

Progress

Micro.Progress puts a label and a count over a row of ticks, one per unit up to 16, that fill as work is done. The tick being worked on is drawn a little longer. A button at the end pauses it.

'use client';

import { useEffect, useState } from 'react';
import { PauseIcon, PlayIcon, Tick02Icon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';
import { Micro } from '@/components/panelui/micro';

export default function MicroProgressDemo() {
  const [running, setRunning] = useState(true);
  const [done, setDone] = useState(5);
  const finished = done >= 12;

  useEffect(() => {
    if (!running || finished) return;
    const timer = window.setTimeout(() => setDone((value) => value + 1), 1500);
    return () => window.clearTimeout(timer);
  }, [running, finished, done]);

  return (
    <Micro className="w-64">
      <Micro.Progress
        label={finished ? 'Exported' : 'Exporting'}
        value={done}
        max={12}
        tone="info"
        className="flex-1"
      />
      <Micro.Button
        aria-label={finished ? 'Export again' : running ? 'Pause export' : 'Resume export'}
        onClick={() => (finished ? setDone(0) : setRunning(!running))}
      >
        <HugeiconsIcon icon={finished ? Tick02Icon : running ? PauseIcon : PlayIcon} />
      </Micro.Button>
    </Micro>
  );
}

Who approved

Micro.Faces overlaps up to four faces, with initials where there is no picture, and counts the rest. A Micro.Label and a glyph say what they did.

import { Tick02Icon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';
import { Micro } from '@/components/panelui/micro';

const PEOPLE = [
  { name: 'Khalid Abdi', src: 'https://avatars.githubusercontent.com/u/127331761?v=4' },
  { name: 'Ines Duarte' },
  { name: 'Sam Whitlock' },
];

export default function MicroApproval() {
  return (
    <Micro>
      <Micro.Faces people={PEOPLE} />
      <Micro.Label className="text-foreground">Approved</Micro.Label>
      <HugeiconsIcon icon={Tick02Icon} className="size-4 text-success-foreground" aria-hidden="true" />
    </Micro>
  );
}

Micro.Input takes the pill's remaining width. Give the pill a width. Micro.Kbd shows the key that focuses it.

import { Search01Icon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';
import { Micro } from '@/components/panelui/micro';

export default function MicroSearch() {
  return (
    <Micro className="w-80">
      <HugeiconsIcon icon={Search01Icon} className="size-4 shrink-0 text-muted-foreground" aria-hidden="true" />
      <Micro.Input placeholder="Find a word in this episode" aria-label="Find in episode" />
      <Micro.Kbd>⌘F</Micro.Kbd>
    </Micro>
  );
}

A setting

Micro.Switch is a switch sized for the pill. Put a Micro.Text before it saying what it turns on and where.

'use client';

import { useState } from 'react';
import { Micro } from '@/components/panelui/micro';

export default function MicroToggle() {
  const [on, setOn] = useState(true);
  return (
    <Micro>
      <Micro.Text value="Remove noise" label="this episode only" />
      <Micro.Switch checked={on} onCheckedChange={setOn} label="Remove noise" color="info" />
    </Micro>
  );
}

A balance

A glyph, a Micro.Mono figure and a Micro.Label for its unit.

import { Clock01Icon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/react';
import { Micro } from '@/components/panelui/micro';

export default function MicroCounter() {
  return (
    <Micro>
      <HugeiconsIcon icon={Clock01Icon} className="size-4 shrink-0 text-muted-foreground" aria-hidden="true" />
      <Micro.Mono>3,180</Micro.Mono>
      <Micro.Label>minutes left</Micro.Label>
    </Micro>
  );
}

Sizes

size="sm" is 40px tall and md, the default, is 48px. The parts inside follow the pill's size.

import { Micro } from '@/components/panelui/micro';

export default function MicroSizes() {
  return (
    <div className="flex flex-wrap items-center justify-center gap-3">
      <Micro size="sm">
        <Micro.Ring value={64} label="Uploaded" />
        <Micro.Text value="64%" label="uploaded" />
      </Micro>
      <Micro>
        <Micro.Ring value={64} label="Uploaded" />
        <Micro.Text value="64%" label="uploaded" />
      </Micro>
    </div>
  );
}

API Reference

Micro

PropTypeDefaultDescription
sizeMicroSizemdsm is 40px tall, md 48px. Default md.

Micro.Text

PropTypeDefaultDescription
valueReactNode—The reading, on the first line: "48.2k", "68%".
labelReactNode—What it is, on the second line, muted: "views · 7 days".

Micro.Mono

PropTypeDefaultDescription
mutedboolean—muted for the second half of a pair, like a duration after the time played.

Micro.Spark

PropTypeDefaultDescription
valuesreadonly number[]—The values, oldest first. The last is drawn in the tone.
toneMicroTone—The colour of the last bar. Default default, the text's colour.
heightnumber—How tall the tallest bar is, in px. Default 20.

Micro.Ring

PropTypeDefaultDescription
valuenumber—How full it is, from 0 to 100.
toneMicroTone—The arc's colour. Default default.
diameternumber—Its diameter, in px. Default 32, or 26 in a small pill.
labelstring—What a screen reader says it is: "lip-sync". It is read with the value.

Micro.Delta

PropTypeDefaultDescription
valuenumber—The change, as a number: 12 for +12%.
unitstring—What follows the number. Default %.
toneMicroTone—Its colour. Default success when up, destructive when down, muted when flat.
invertedboolean—Draw a fall as good, as for latency or cost. Swaps the default tones.

Micro.Button

PropTypeDefaultDescription
variant'solid' | 'ghost'—solid sits on a filled circle; ghost shows its circle only when pointed at. Default solid.

Micro.Segments

PropTypeDefaultDescription
valuestring—The chosen segment's value, when the caller holds it.
defaultValuestring—The segment chosen first, when the caller does not hold it.
onValueChange(value: string) => void—Called with the new segment's value.

Micro.Segment

PropTypeDefaultDescription
valuestring—What choosing it sets.

Micro.Stepper

PropTypeDefaultDescription
valuenumber—The number, when the caller holds it.
defaultValuenumber—The number to start at, when the caller does not hold it. Default min.
onValueChange(value: number) => void—Called with the new number.
minnumber0The lowest it goes. Default 0.
maxnumber100The highest it goes. Default 100.
stepnumber1How far one press moves it. Default 1.
formatIntl.NumberFormatOptions—How it is written, passed to Intl.NumberFormat.
suffixstring—Written after the number: ×, px.
labelstring—What a screen reader calls it: "Playback speed".

Micro.Progress

PropTypeDefaultDescription
valuenumber—How many are done.
maxnumber100How many there are. One tick each, up to 16; past that the ticks stand for a share each.
labelReactNode—What is being done: "Rendering".
toneMicroTone—The ticks' colour when done. Default default.

Micro.Faces

PropTypeDefaultDescription
peoplereadonly MicroFace[]—The people, in order. Four show; the rest are counted.

Micro.Pulse

PropTypeDefaultDescription
toneMicroTone—Its colour. Default default.
liveboolean—Whether it beats. Default true.

Every part also takes the props of the element it renders, and a className.

Notes

Tones

Bars, rings, ticks and the pulse are drawn in the text's colour unless tone names a theme colour: info, success, warning or destructive. Use a tone for what a reading means, not to decorate it.

Motion

The spark's bars rise once when they first show, the ring sweeps whenever its value changes, the stepper's digits roll, the segment marker slides, and ticks fill as progress is made. With reduced motion each change happens at once and the pulse stops.

Screen readers

Micro.Ring is a meter and Micro.Progress a progress bar, both read with their values. Micro.Segments is a radio group and Micro.Stepper a spin button. A Micro.Button that holds only a glyph needs an aria-label, as does Micro.Input.

Server Components

Micro is a client component. In a file that starts with "use client", write its parts with a dot, as on this page. A Server Component cannot read Micro.Text off the import, so each part is also exported by name: MicroText is Micro.Text, and so on for the others.

import { Micro, MicroText, MicroLabel, MicroMono, MicroSpark, MicroRing, MicroDelta, MicroButton, MicroSeparator, MicroSegments, MicroSegment, MicroStepper, MicroProgress, MicroSwitch, MicroKbd, MicroFaces, MicroInput, MicroPulse } from "@/components/panelui/micro"

On this page