@react-md/form
Version:
This package is for creating all the different form input types.
72 lines (71 loc) • 2.98 kB
TypeScript
import type { CSSProperties, ReactNode, Ref, SelectHTMLAttributes } from "react";
import type { TextFieldContainerOptions } from "../text-field/TextFieldContainer";
export interface NativeSelectProps extends SelectHTMLAttributes<HTMLSelectElement>, TextFieldContainerOptions {
/**
* The id for the select. This is required for accessibility.
*/
id: string;
/**
* An optional ref to apply to the text field's container div element. The
* default ref is forwarded on to the `input` element.
*/
containerRef?: Ref<HTMLDivElement>;
/**
* An optional icon to display to the right of the select. This should
* normally be a dropdown icon to replace the native select's dropdown icon.
* If this is set to `null`, the native select's dropdown icon will be
* displayed instead.
*
* This defaults to the `IconProvider`'s dropdown icon from the
* `@react-md/icon` package.
*/
icon?: ReactNode;
/**
* An optional floating label to use for the text field. This should really
* only be used when the `theme` prop is not set to `"none"`. This will be
* wrapped in the `<Label>` component itself and automatically apply the
* `htmlFor` prop for this text field.
*/
label?: ReactNode;
/**
* An optional style to apply to the label wrapper.
*/
labelStyle?: CSSProperties;
/**
* An optional className to apply to the label wrapper.
*/
labelClassName?: string;
/**
* An optional style to apply to the select itself. The `style` prop will be
* applied to the container `<div>` instead.
*/
selectStyle?: CSSProperties;
/**
* An optional className to apply to the select itself. The `className` prop
* will be applied to the container `<div>` instead.
*/
selectClassName?: string;
/**
* The value to use for the text field. This will make the component
* controlled and require the `onChange` prop to be provided as well otherwise
* this will act as a read only text field.
*
* If the `multiple` prop is enabled, this **must** be a list of strings.
*/
value?: string | readonly string[];
/**
* The default value for the text field which will make it uncontrolled. If
* you manually change the `defaultValue` prop, the input's value **will not
* change** unless you provide a different `key` as well. Use the `value` prop
* instead for a controlled input.
*
* If the `multiple` prop is enabled, this **must** be a list of strings.
*/
defaultValue?: string | readonly string[];
}
/**
* This component is used to render a native `<select>` element with the text
* field theme styles. This component is great to use for native behavior and
* full accessibility.
*/
export declare const NativeSelect: import("react").ForwardRefExoticComponent<NativeSelectProps & import("react").RefAttributes<HTMLSelectElement>>;