UNPKG

@base-ui/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

40 lines 1.32 kB
import * as React from 'react'; import type { BaseUIComponentProps } from "../../utils/types.js"; /** * A text label of the currently selected item. * Renders a `<span>` element. * * Documentation: [Base UI Select](https://base-ui.com/react/components/select) */ export declare const SelectValue: React.ForwardRefExoticComponent<Omit<SelectValueProps, "ref"> & React.RefAttributes<HTMLSpanElement>>; export interface SelectValueState { /** * The value of the currently selected item. */ value: any; /** * Whether the placeholder is being displayed. */ placeholder: boolean; } export interface SelectValueProps extends Omit<BaseUIComponentProps<'span', SelectValue.State>, 'children'> { /** * Accepts a function that returns a `ReactNode` to format the selected value. * @example * ```tsx * <Select.Value> * {(value: string | null) => value ? labels[value] : 'No value'} * </Select.Value> * ``` */ children?: React.ReactNode | ((value: any) => React.ReactNode); /** * The placeholder value to display when no value is selected. * This is overridden by `children` if specified, or by a null item's label in `items`. */ placeholder?: React.ReactNode; } export declare namespace SelectValue { type State = SelectValueState; type Props = SelectValueProps; }