Code

<script src="/pearl-segmented.free.js" defer></script>

<pearl-segmented
  size="56"
  theme="light"
  value="Day"
>
  <option>Day</option>
  <option>Week</option>
  <option>Month</option>
</pearl-segmented>

In context

Two months free on the yearly plan
Billing period
Inbox filter, Mint Pro
View switch, Sunset Pro

Install · Free Web Component

One file, no dependencies. Aurora preset, every other option included. Host it yourself so your visitors never load anything from our servers.

1. Install with one command — or download the file
shadcn CLI · React
npx shadcn@latest add https://www.ui-design.co/r/pearl-segmented.json
2. Load it and use the element
HTML
<script src="/pearl-segmented.free.js" defer></script>

<pearl-segmented
  size="48"
  theme="light"
  value="Day"
>
  <option>Day</option>
  <option>Week</option>
  <option>Month</option>
</pearl-segmented>
3. React + TypeScript (optional)

The shadcn command adds a typed React wrapper for you. Using the file directly? Custom elements work in React as-is; for type checking add:

TypeScript
// pearl-segmented.d.ts
declare namespace JSX {
  interface IntrinsicElements {
    'pearl-segmented': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
      size?: number | string;
      theme?: 'light' | 'dark';
      value?: string;
      equal?: boolean | '';
    };
  }
}

Pro · React + TypeScript Pro

One payment of $4.99, yours forever. Use it in unlimited personal and commercial projects; no resale.

  • React component (controlled or uncontrolled) with TypeScript types, the shared WebGL core and the GLSL source
  • Sunset, Mint and Mono tints, plus custom tints from Brand Fit
  • The vanilla Web Component with every tint, a demo page, README and license

Attributes & props

NameTypeDefaultDescription
sound booleanoffPlays a short synthesised porcelain tap (and a tap of vibration on phones) when used. Also on for everything inside an element with data-ui-sound="on".
options string[] | { value, label, disabled }[]—Two to five options. In HTML, put <option> elements inside.
value stringfirst optionThe selected option. Fires change when it moves.
size number (px)48Height; the text and padding scale with it.
theme 'light' | 'dark''light'White porcelain or a dark groove.
equal booleanfalseGives every option the same width.
tint Pro'aurora' | 'sunset' | 'mint' | 'mono' | object'aurora'Halo colours, or a custom tint. Free build ships Aurora only.

A radio group: one tab stop, arrow keys, Home and End move the selection, and every option is a real button. Press and slide across it and the pearl follows your finger. Reduced motion moves the pearl without the stretch. The groove and the pearl are CSS, so without WebGL only the halo is missing. All library components on a page share one WebGL context.

More components