Skip to main content

RankingFabric component

Component for rendering a ranking question type.

📝 Signature​

RankingFabric(props: {
styles: {
color: string;
outlineSize?: number;
roundness?: number;
scale?: number;
margin?: number;
options: IRankingOption[];
slots: Value[];
disabled?: boolean;
readOnly?: boolean;
ariaDescribedBy?: string;
tabIndex?: number;
onFocus?: (e: FocusEvent) => void;
onBlur?: (e: FocusEvent) => void;
onAutoFocus?: (el: HTMLInputElement | null) => void;
onSubmit?: () => void;
onCancel?: () => void;
}): JSX.Element

📇 Props​

stylesobjectNoSpecifies the styles for the options. Supports the following styles:
- color: Base color for the options;
- outlineSize: Optional outline size in pixels for the options;
- roundness: Optional roundness in pixels for the options;
- scale: Optional scale factor for the options (defaults to 1);
- margin: Optional margin in pixels in between the options.
optionsIRankingOption[]NoSpecifies the options (see IRankingOption).
slotsValue[]YesSpecifies the value slots. The number of supplied slots determines the number of possible ranking positions. Each position can hold one selected option.
disabledbooleanYesSpecifies if the component is disabled.
readOnlybooleanYesSpecifies if the component is read-only.
ariaDescribedBystringYesSpecifies the aria-describedby identifier of the element that describes the component.
tabIndexnumberYesSpecifies the tabindex for the component.
onFocus(e: FocusEvent) => voidYesInvoked when the component gets focus.
onBlur(e: FocusEvent) => voidYesInvoked when the component loses focus.
onAutoFocus(el: HTMLInputElement | null) => voidYesInvoked when the HTML element of the component is available for auto-focus.
onSubmit() => voidYesInvoked when the user presses the Shift + Enter key combination or the Tab key (this event is often used to go to the next input control in a form).
onCancel() => voidYesInvoked when the user presses the Shift + Tab key combination (this event is often used to go to the previous input control in a form).

↩ī¸ Return value​

Returns the JSX.Element for the component.

👩‍đŸ’ģ Example​

import { RankingFabric } from "@tripetto/runner-fabric/components/ranking";
import { useOverlay } from "@tripetto/runner-fabric/overlay";

const RankingExample = () => (
backgroundColor: "white",
borderColor: "black",
errorColor: "red"
id: "1",
name: "Option 1"
id: "2",
name: "Option 2"

⛓ī¸ Interfaces​

🔗 IRankingOption​

Describes the interface for an ranking option.

Type declaration​

interface IRankingOption {
/* Identifier for the option. */
id: string;

/* Name for the option. */
name: string;

/* Label for the option. */
label?: string | JSX.Element;

/* Description for the option. */
description?: string | JSX.Element;

/* Value for the option. */
value?: Value;