Open In App

React Suite <Cascader> Props

React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application.

In this article, we’ll learn about React suite Cascader Props. A cascader is used for a single selection of data with a hierarchical relationship structure.



Syntax:

<Cascader size="md" appearance="default" 
 placeholder="Default" data={data} />

<Cascader> Props:



Creating React Application and Installing Module:

Step 1: Create a react application using the given command:

npm create-react-app projectname

Step 2: After creating your project, move to it using the given command:

cd projectname

Step 3: Now Install the rsuite node package using the given command:

npm install rsuite

Project Structure: Now your project structure should look like the following:

 

Example 1: Below example demonstrates the size, placement, and appearance props of Cascader.




import { Cascader } from "rsuite";
import "rsuite/dist/rsuite.min.css";  
  
export default function App() {
  const customData = [
    {
      label: "Data Structures",
      value: 1,
      children: [
        {
          label: "Queue",
          value: 2,
          children: [
            {
              label: "Priority Queue",
              value: 3,
            },
            {
              label: "FIFO Queue",
              value: 4,
            },
          ],
        },
        {
          label: "Linked List",
          value: 5,
          children: [
            {
              label: "Circular",
              value: 6,
            },
            {
              label: "Double",
              value: 7,
            },
            {
              label: "Single",
              value: 8,
            },
          ],
        },
      ],
    },
    {
      label: "Algorithms",
      value: 1,
      children: [
        {
          label: "Search",
          value: 2,
          children: [
            {
              label: "Binary Search",
              value: 3,
            },
            {
              label: "Linear Search",
              value: 4,
            },
          ],
        },
        {
          label: "Sorting",
          value: 5,
          children: [
            {
              label: "Bubble Sort",
              value: 6,
            },
            {
              label: "Selection Sort",
              value: 7,
            },
            {
              label: "Insertion Sort",
              value: 8,
            },
          ],
        },
      ],
    },
  ];
  
  return (
    <center>
      <div>
        <h2>GeeksforGeeks</h2>
        <h4 style={{ color: "green" }}>
          React Suite Cascader Props
        </h4>
        <div style={{ marginTop: 20, width: 800 }}>
          <Cascader
            data={customData}
            size="lg"
            appearance="subtle"
            placement="bottomStart"
          />
        </div>
      </div>
    </center>
  );
}

Output:

 

Example 2: Below example demonstrates the placeholder, inline, searchable, and disabledItemValues props of Cascader.




import { Cascader } from "rsuite";
import "rsuite/dist/rsuite.min.css";  
  
export default function App() {
  const customData = [
    {
      label: "Data Structures",
      value: 1,
      children: [
        {
          label: "Queue",
          value: 2,
          children: [
            {
              label: "Priority Queue",
              value: 3,
            },
            {
              label: "FIFO Queue",
              value: 4,
            },
          ],
        },
        {
          label: "Linked List",
          value: 5,
          children: [
            {
              label: "Circular",
              value: 6,
            },
            {
              label: "Double",
              value: 7,
            },
            {
              label: "Single",
              value: 8,
            },
          ],
        },
      ],
    },
    {
      label: "Algorithms",
      value: 1,
      children: [
        {
          label: "Search",
          value: 2,
          children: [
            {
              label: "Binary Search",
              value: 3,
            },
            {
              label: "Linear Search",
              value: 4,
            },
          ],
        },
        {
          label: "Sorting",
          value: 5,
          children: [
            {
              label: "Bubble Sort",
              value: 6,
            },
            {
              label: "Selection Sort",
              value: 7,
            },
            {
              label: "Insertion Sort",
              value: 8,
            },
          ],
        },
      ],
    },
  ];
  
  return (
    <center>
      <div>
        <h2>GeeksforGeeks</h2>
        <h4 style={{ color: "green" }}>
          React Suite Cascader Props
        </h4>
        <div style={{ marginTop: 20, width: 800 }}>
          <Cascader
            data={customData}
            size="lg"
            placeholder="Select a category"
            inline
            disabledItemValues={[6, 7]}
            searchable={false}
          />
        </div>
      </div>
    </center>
  );
}

Output:

 

Reference: https://rsuitejs.com/components/cascader/#code-lt-cascader-gt-code


Article Tags :