Skip to content

TypeScript

The library is written in TypeScript and exports all prop types alongside their components. This enables full type safety when using components and makes it easy to extend or wrap them in your application.

All prop types follow the {ComponentName}Props naming convention:

import type { ButtonProps, CardProps, ModalProps } from "@f0rbit/ui";

For components with variants or sizes, those types are also exported:

import type { ButtonVariant, ButtonSize } from "@f0rbit/ui";
import type { BadgeVariant } from "@f0rbit/ui";
import type { StatusState } from "@f0rbit/ui";
import type { SpinnerSize } from "@f0rbit/ui";
import type { ChevronFacing } from "@f0rbit/ui";
import type { StepStatus } from "@f0rbit/ui";
import type { TimelineItemVariant } from "@f0rbit/ui";

Create wrapper components that accept all original props plus your additions:

import type { ButtonProps } from "@f0rbit/ui";
import { Button } from "@f0rbit/ui";
type SubmitButtonProps = ButtonProps & {
isSubmitting?: boolean;
};
const SubmitButton = (props: SubmitButtonProps) => (
<Button
{...props}
loading={props.isSubmitting}
disabled={props.disabled || props.isSubmitting}
>
{props.children}
</Button>
);

Use the variant types to ensure valid values:

import type { ButtonVariant } from "@f0rbit/ui";
const variantMap: Record<string, ButtonVariant> = {
save: "primary",
cancel: "outline",
delete: "danger",
};

When wrapping components with custom behavior:

import type { InputProps } from "@f0rbit/ui";
import { Input } from "@f0rbit/ui";
type CurrencyInputProps = Omit<InputProps, "type" | "value" | "onInput"> & {
value: number;
onValueChange: (value: number) => void;
};
TypeDescription
ButtonPropsButton component props including variant, size, loading state
BadgePropsBadge component props with variant options
CardPropsCard container props
CheckboxPropsCheckbox input with label and description
ChevronPropsDirectional chevron icon
ClampPropsText clamping component
CollapsiblePropsExpandable/collapsible container
DropdownPropsDropdown menu container
DropdownTriggerPropsDropdown trigger element
DropdownMenuPropsDropdown menu panel
DropdownItemPropsIndividual dropdown item
EmptyPropsEmpty state placeholder
FormFieldPropsForm field wrapper with label and error
InputPropsText input field
TextareaPropsMulti-line text input
SelectPropsSelect dropdown input
ModalPropsModal dialog container
SpinnerPropsLoading spinner
StatPropsStatistic display
StatusPropsStatus indicator dot
StepperPropsStep progress container
StepPropsIndividual step item
TabsPropsTabs container
TabListPropsTab button list
TabPropsIndividual tab button
TabPanelPropsTab content panel
TimelinePropsTimeline container
TogglePropsToggle switch input
TypeValues
ButtonVariant"primary" | "secondary" | "outline" | "ghost" | "danger"
ButtonSize"sm" | "md" | "lg"
BadgeVariant"default" | "secondary" | "success" | "warning" | "danger"
StatusState"success" | "warning" | "error" | "info" | "inactive"
SpinnerSize"sm" | "md" | "lg"
ChevronFacing"up" | "down" | "left" | "right"
StepStatus"complete" | "current" | "upcoming"
TimelineItemVariant"default" | "success" | "warning" | "error"
TimelineItemObject type for timeline entries