Skip to main content

Select

Select a country
import React from 'react';
import { Select } from 'chic-ui';

<Select
width="200px"
data={['India', 'Japan', 'Germany', 'Russia']}
placeholder="Select a country"
/>;

Disabled

Use the disabled prop to disable any select component.

Select a country
import React from 'react';
import { Select } from 'chic-ui';

<Select
disabled
width="200px"
data={['India', 'Japan', 'Germany', 'Russia']}
placeholder="Select a country"
/>;

Error

Use the error prop to display select with error.

Select a country
import React, { useState } from 'react';
import { Select } from 'chic-ui';

<Select
error
width="200px"
data={['India', 'Japan', 'Germany', 'Russia']}
placeholder="Select a country"
/>;

Simple Multi Select

Select multiple values using multiSelect prop.

Select a country
import React from 'react';
import { Select } from 'chic-ui';

<Select
multiSelect
width="300px"
data={['India', 'Japan', 'Germany', 'Russia']}
placeholder="Select a country"
/>;

Complex Object

Select a sport
import React from 'react';
import { Select } from 'chic-ui';

<Select
width="200px"
data={[
{ id: 1, game: 'Hockey' },
{ id: 2, game: 'Football' },
{ id: 3, game: 'Tennis' },
]}
dataKey="id"
dataName="game"
placeholder="Select a sport"
/>;

Complex Object Multi Select

Select a sport
import React from 'react';
import { Select } from 'chic-ui';

<Select
multiSelect
width="300px"
data={[
{ id: 1, game: 'Hockey' },
{ id: 2, game: 'Football' },
{ id: 3, game: 'Tennis' },
]}
dataKey="id"
dataName="game"
placeholder="Select a sport"
/>;

API

import { Select } from 'chic-ui';
NameTypeDefaultDescription
widthstring'100%'Width of Select
size'small' | 'default' | 'large''default'Size of Select
dataT[]Data for Select
datakeystringKey for complex objects
disabledbooleanfalseDisable Select
multiSelectbooleanfalseSelects multiple values
dataNamestringName for complex objects
errorbooleanfalseError Select
placeholderstringAdds placeholder
onChange(value: T | T[]) => voidHandles value changes
classNamestringProvide external classnames to the component
styleReact.CSSPropertiesOverride default styling of the component