Dropdown

less than 1 minute read

References

TypeScript

import { Components } from "gd-sprest-bs";

// Create the dropdown
let el = document.querySelector("#dropdown");
let dropdown = Components.Dropdown({
    el: el,
    label: "Select a Choice",
    items: [
        { text: "Choice 1", value: "1" },
        { text: "Choice 2", value: "2" },
        { text: "Choice 3", value: "3" },
        { text: "Choice 4", value: "4" },
        { text: "Choice 5", value: "5" }
    ],
    onChange: (item, ev) => {
        console.log("The selected value is: " + item.text);
    }
});

React

import * as React from "react";
import { Dropdown } from "gd-sprest-bsx";

export class IDemo extends React.Component {
    // Render the component
    render() {
        return (
            <Dropdown
                label="Select a Choice"
                items={[
                    { text: "Choice 1", value: 1 },
                    { text: "Choice 2", value: 2 },
                    { text: "Choice 3", value: 3 },
                    { text: "Choice 4", value: 4 },
                    { text: "Choice 5", value: 5 }
                ]}
            />
        );
    }
}

Code Playground