Malay Patel

Segmented Control

Component 2

About

A segmented control whose pill slides between options on a spring, squishes when pressed and can be dragged across the segments like the one on iOS. Free component from uibrik (uibrik.com).

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Segmented Control to your project and fits it to your theme.

Code

How Segmented Control is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { SegmentedControl } from "@/components/ui/segmented-control";
import { IconCalendar, IconLayoutGrid, IconLayoutKanban, IconLayoutList } from "@tabler/icons-react";

const PLAIN = ["Day", "Week", "Month", "Year"];

const WITH_ICONS = [
  { value: "grid", label: "Grid", icon: <IconLayoutGrid stroke={1.75} /> },
  { value: "list", label: "List", icon: <IconLayoutList stroke={1.75} /> },
  { value: "board", label: "Board", icon: <IconLayoutKanban stroke={1.75} /> },
  { value: "calendar", label: "Calendar", icon: <IconCalendar stroke={1.75} /> },
];

const { icons, ...props } = {
  size: "md" as "sm" | "md" | "lg",
  equalWidth: false,
  draggable: true,
  duration: 0.35,
  icons: false,
};

export default function Demo() {
  return (
    <div className="flex h-screen w-full items-center justify-center px-4">
      <SegmentedControl key={String(icons)} {...props} options={icons ? WITH_ICONS : PLAIN} defaultValue={icons ? "list" : "Week"} label={icons ? "Layout" : "Range"} />
    </div>
  );
}

Dependencies

More by Malay Patel

View all
  • Halftone

    Halftone

    48
  • Balloon Button

    Balloon Button

    33
  • Fold Toolbar

    Fold Toolbar

    31
  • Hold To Confirm

    Hold To Confirm

    14
  • Marquee

    Marquee

    9
  • Aurora

    Aurora

    6
  • Otp Input

    Otp Input

    5
  • Copy Button

    Copy Button

    4