Skip to content

Controlled & Uncontrolled Components

Most components in our library are controlled, with the exception of Textfield and Textarea.

Controlled & Uncontrolled flow charts

Controlled Component

Controlled Component

Uncontrolled Component

Uncontrolled Component

FeatureControlled ComponentUncontrolled Component
State ManagementYour app manages the component’s stateThe DOM manages the componenet’s state
Data validationEasy to validate on each eventHarder to keep track of changes

Controlled Components

With & Without event handler

The Switch is a controlled component. When a user clicks it, the component emits a TpgChangeEvent, but it doesn’t manage its own state. It’s up to your application to listen to that event and explicitly update the checked value to reflect the new state.

  • Without an event handler and state update logic, the switch won’t visually toggle—it depends entirely on your code to control its behavior.

Uncontrolled Components

With & Without event handler

The Textfield in this case is an uncontrolled component. When the user types into the field, it updates immediately based on the browser’s default behavior. The component manages its own internal state, and no additional logic is required to handle the input.

  • You can still listen to events (like TpgInputEvent or TpgChangeEvent) if you need to react to user input, but you’re not responsible for managing the input’s state.