Skip to main content

Select

danger

This SDK is a Work In Progress! All features are subject to change.

A select represents a dropdown input element that allows users to choose from a predefined list of options. It supports properties such as name, label, options, and event handlers (onChange, onBlur, onFocus).

Usage

Example
import { Box, Select } from "@tiendanube/nube-sdk-jsx";

function MyComponent() {
return (
<Box>
<Select
id="my-select"
name="country"
label="Country"
value="br"
options={[
{ value: "us", label: "United States" },
{ value: "br", label: "Brazil" },
{ value: "ar", label: "Argentina" },
{ value: "mx", label: "Mexico" }
]}
onChange={(e) => {
console.log(`Selected value: ${e.value}`);
}}
/>
</Box>
);
}

Properties

PropertyTypeRequiredDescription
namestringYesThe name of the select, used to identify it in forms.
labelstringYesThe label text displayed above the select.
optionsSelectOption[]YesArray of options available for selection.
valuestringNoThe current selected value of the select.
disabledbooleanNoWhether the select is disabled and cannot be interacted with.
styleStyleSheetNoCustom styles for the select.
onChangeNubeComponentSelectEventHandlerNoFunction called when the selected value changes.

SelectOption Type

Each option in the options array should follow this structure:

type SelectOption = {
value: string; // The value that will be submitted with the form
label: string; // The text displayed to the user
}

Event Handlers

The select component supports three event handlers that receive an object with the following properties:

onChange: (data: {
type: "change"; // The type of event
state: NubeSDKState; // The current state of the SDK
value: string; // The new selected value
}) => void