astralyxdev

Cascader

Forms 2

About

A multi-level select for picking one path through a hierarchy (like country → region → city) using side-by-side columns instead of a nested dropdown tree.

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

Code

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

Usage.tsx

"use client";

import { Cascader, type CascaderOption } from "@/components/ui/cascader";

const REGIONS: CascaderOption[] = [
  {
    value: "eu",
    label: "Europe",
    children: [
      {
        value: "de",
        label: "Germany",
        children: [
          { value: "ber", label: "Berlin" },
          { value: "muc", label: "Munich" },
        ],
      },
      {
        value: "fr",
        label: "France",
        children: [
          { value: "par", label: "Paris" },
          { value: "lyo", label: "Lyon" },
        ],
      },
      {
        value: "pl",
        label: "Poland",
        children: [
          { value: "waw", label: "Warsaw" },
          { value: "krk", label: "Kraków" },
        ],
      },
    ],
  },
  {
    value: "na",
    label: "North America",
    children: [
      {
        value: "us",
        label: "United States",
        children: [
          { value: "nyc", label: "New York" },
          { value: "sfo", label: "San Francisco" },
        ],
      },
      {
        value: "ca",
        label: "Canada",
        children: [
          { value: "yyz", label: "Toronto" },
          { value: "yvr", label: "Vancouver" },
        ],
      },
    ],
  },
  {
    value: "apac",
    label: "Asia Pacific",
    children: [
      {
        value: "jp",
        label: "Japan",
        children: [{ value: "tyo", label: "Tokyo" }],
      },
      {
        value: "sg",
        label: "Singapore",
        children: [{ value: "sin", label: "Singapore" }],
      },
      {
        value: "au",
        label: "Australia",
        children: [{ value: "syd", label: "Sydney" }],
      },
    ],
  },
];

export default function Demo() {
  return (
    <div className="flex min-h-screen w-full items-center justify-center bg-background p-10 text-foreground">
      <Cascader
        className="w-64"
        options={REGIONS}
        defaultValue={["eu", "de", "ber"]}
        label="Region"
      />
    </div>
  );
}

Dependencies

More by astralyxdev

View all
  • Rate Limit Meter

    Rate Limit Meter

    18
  • Note Graph

    Note Graph

    14
  • Prompt Versions

    Prompt Versions

    7
  • Migration List

    Migration List

    7
  • IP Cluster

    IP Cluster

    7
  • Checkout Summary

    Checkout Summary

    7
  • Odds Display

    Odds Display

    5
  • Health Checks

    Health Checks

    5

More in Forms

View all
  • Premium Auth

    Premium Auth

    500
  • Login 1

    Login 1

    52
  • Book A Demo 3

    Book A Demo 3

    83
  • Authentication Card

    Authentication Card

    47
  • Book A Demo 1

    Book A Demo 1

    69
  • Contact Card

    Contact Card

    1K
  • Login Card

    Login Card

    32
  • Login 2

    Login 2

    7