@porsche-design-system/components-react
Version:
Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.
149 lines (148 loc) • 6.19 kB
TypeScript
import type { BaseProps } from '../../BaseProps';
import type { BreakpointCustomizable, SegmentedControlColumns, SegmentedControlChangeEventDetail, SegmentedControlState } from '../types';
export type PSegmentedControlProps = BaseProps & {
/**
* Sets the number of equal-width columns for the item layout. Use `auto` to distribute items based on their content width. Supports responsive breakpoint values.
* @default 'auto'
*/
columns?: BreakpointCustomizable<SegmentedControlColumns>;
/**
* Reduces the item height and spacing for use in dense layouts where vertical space is limited.
* @default false
*/
compact?: boolean;
/**
* Sets a supplementary description displayed below the label to give users additional context about the segmented control.
* @default ''
*/
description?: string;
/**
* Prevents user interaction with all items in the segmented control and excludes the value from form submissions.
* @default false
*/
disabled?: boolean;
/**
* Associates the segmented control with a form element by its ID when it is not a direct descendant of that form.
*/
form?: string;
/**
* Hides the visible label while keeping it accessible to screen readers. Supports responsive breakpoint values.
* @default false
*/
hideLabel?: BreakpointCustomizable<boolean>;
/**
* Sets the visible label text displayed above the segmented control to describe the group of options.
* @default ''
*/
label?: string;
/**
* Sets the validation feedback message displayed below the segmented control when `state` is `success` or `error`.
* @default ''
*/
message?: string;
/**
* Sets the name of the control submitted with the form data to identify the selected value on the server.
*/
name?: string;
/**
* Prevents items from wrapping to new rows and renders them in a single horizontally scrollable row instead.
* @default false
*/
noWrap?: boolean;
/**
* Emitted when the segmented control loses focus, useful for triggering validation on blur.
*/
onBlur?: (event: CustomEvent<void>) => void;
/**
* Emitted when the user selects a different item, carrying the new value in the event detail.
*/
onChange?: (event: CustomEvent<SegmentedControlChangeEventDetail>) => void;
/**
* Marks the segmented control as required so the form cannot be submitted until one option is selected.
* @default false
*/
required?: boolean;
/**
* Sets the validation state of the segmented control, controlling its visual appearance and feedback message style (`none`, `success`, `error`).
* @default 'none'
*/
state?: SegmentedControlState;
/**
* Sets the currently selected item's value and pre-selects the matching option when the component renders.
*/
value?: string | number;
};
export declare const PSegmentedControl: import("react").ForwardRefExoticComponent<Omit<import("react").DOMAttributes<{}>, "onChange" | "onInput" | "onToggle"> & Pick<import("react").HTMLAttributes<{}>, "suppressHydrationWarning" | "autoFocus" | "className" | "dir" | "hidden" | "id" | "inert" | "inputMode" | "lang" | "slot" | "style" | "tabIndex" | "title" | "translate" | "role"> & {
/**
* Sets the number of equal-width columns for the item layout. Use `auto` to distribute items based on their content width. Supports responsive breakpoint values.
* @default 'auto'
*/
columns?: BreakpointCustomizable<SegmentedControlColumns>;
/**
* Reduces the item height and spacing for use in dense layouts where vertical space is limited.
* @default false
*/
compact?: boolean;
/**
* Sets a supplementary description displayed below the label to give users additional context about the segmented control.
* @default ''
*/
description?: string;
/**
* Prevents user interaction with all items in the segmented control and excludes the value from form submissions.
* @default false
*/
disabled?: boolean;
/**
* Associates the segmented control with a form element by its ID when it is not a direct descendant of that form.
*/
form?: string;
/**
* Hides the visible label while keeping it accessible to screen readers. Supports responsive breakpoint values.
* @default false
*/
hideLabel?: BreakpointCustomizable<boolean>;
/**
* Sets the visible label text displayed above the segmented control to describe the group of options.
* @default ''
*/
label?: string;
/**
* Sets the validation feedback message displayed below the segmented control when `state` is `success` or `error`.
* @default ''
*/
message?: string;
/**
* Sets the name of the control submitted with the form data to identify the selected value on the server.
*/
name?: string;
/**
* Prevents items from wrapping to new rows and renders them in a single horizontally scrollable row instead.
* @default false
*/
noWrap?: boolean;
/**
* Emitted when the segmented control loses focus, useful for triggering validation on blur.
*/
onBlur?: (event: CustomEvent<void>) => void;
/**
* Emitted when the user selects a different item, carrying the new value in the event detail.
*/
onChange?: (event: CustomEvent<SegmentedControlChangeEventDetail>) => void;
/**
* Marks the segmented control as required so the form cannot be submitted until one option is selected.
* @default false
*/
required?: boolean;
/**
* Sets the validation state of the segmented control, controlling its visual appearance and feedback message style (`none`, `success`, `error`).
* @default 'none'
*/
state?: SegmentedControlState;
/**
* Sets the currently selected item's value and pre-selects the matching option when the component renders.
*/
value?: string | number;
} & {
children?: import("react").ReactNode | undefined;
} & import("react").RefAttributes<HTMLElement>>;