Skip to content
Star

Choose the right React component

Match the control to the decision your user needs to make.

What decision is the user making?

Start with the interaction, not the component name. Ask whether a person is choosing one value, several independent values, changing a setting immediately, or asking the application to do something. The matching component should make that contract visible.

An exclusive setting should not look like a set of independent checkboxes. A Switch is not a smaller Button: it represents a current setting, while a Button requests an action. If choosing an option requires a separate confirmation, keep the selection control and the commit action distinct.

Inspiration

First name the decision; the right control usually follows.

When should I use a different control?

Use a Radio Group when users benefit from seeing all alternatives at once. Use Select when space is limited or the choice list is long. A searchable list is useful when people know what they are looking for; search adds work when the list is already short. For navigation between a few peer views, Tabs may be clearer than a form control because changing tabs changes the displayed view rather than a saved setting.

Ghost component pages document the actual owner and its supported composition: Button, Checkbox, Radio Group, Select, Switch, Input, and Tabs. External libraries make different choices: React Aria Components provides accessible interaction primitives and components; Radix Primitives provides unstyled interaction primitives; shadcn/ui distributes editable component source. Base UI is the behavior foundation named by Ghost's installation guide where it is used. These references describe their own contracts; Ghost's source and component pages remain authoritative for Ghost APIs.

Who owns the selected value?

The component renders an interaction; the application decides whether and when a value is stored. For controlled use, pass the current value and update it in the matching callback. Keep the same owner responsible for validation, saving, failure recovery, and resetting related fields. An uncontrolled default is suitable when the component can own temporary local state; it does not persist data for the application.

This distinction matters for forms. A Switch may visually change immediately, but a server save can still fail. Keep a pending or error message where users can understand the result, and restore or retain a value according to the product's policy. Do not call a local state update a successful save.

How do I get the component into my app?

The ordinary Ghost workflow copies component source and its declared dependencies from the registry into your React project. Begin with Installation, then use the component page's current install command. Follow its CSS setup before adapting the example.

What if the component does not fit?

If a choice feels ambiguous, write the user's decision in a sentence and compare it to the table above. If labels or helper text are missing, add them at the form composition rather than changing the control's meaning. If styling is the only mismatch, start with Styling and change the narrowest owner. Avoid choosing by visual similarity alone: matching the state model prevents confusing selection with action.