> Markdown version of [Component Classes](https://vaadin.com/docs/next/tools/copilot/features/component-classes). Section index: [llms.txt](https://vaadin.com/docs/next/tools/llms.txt)

# Extract and Edit Component Classes

A part of a view that you want to reuse, such as a form, can become a component class of its own. Copilot extracts it, and edits inside it: the change goes into its class, and so into every view that uses it.

## <a id="extract-a-component"></a>Extract a Component

Extract the form into a class

1. Select the form: click a field, and press **←** for its parent. In its **⋮** menu, point at **Extract to Inner Component**.

   [![Your browser does not support the video tag.](../../../vaadin/videos/copilot/extract-component/01-extract.jpg)](../../../vaadin/videos/copilot/extract-component/01-extract.mp4)

2. Click it. Copilot moves the form and its fields into a class inside the view’s class, `MyComponent`, and selects it: its badge now has the **↳** button of a component class.

   [![Your browser does not support the video tag.](../../../vaadin/videos/copilot/extract-component/02-result.jpg)](../../../vaadin/videos/copilot/extract-component/02-result.mp4)

The new class is inside the view’s class. To use it in other views, move it to a file of its own with your IDE’s refactoring, such as **Move** in IntelliJ IDEA. Give it a name of its own, too.

## <a id="edit-inside-a-component-class"></a>Edit Inside a Component Class

Change the form’s own class

1. Here the form is a `ContactForm`, a class in a file of its own. Click a field in it, and the form is selected as a whole: its badge has a ↳ button that edits ContactForm.java instead of the view.

   [![Your browser does not support the video tag.](../../../vaadin/videos/copilot/component-classes/01-select.jpg)](../../../vaadin/videos/copilot/component-classes/01-select.mp4)

2. Click it, and select a field inside. The Editing tag names ContactForm.java, and everything outside the form is dimmed.

   [![Your browser does not support the video tag.](../../../vaadin/videos/copilot/component-classes/02-enter.jpg)](../../../vaadin/videos/copilot/component-classes/02-enter.mp4)

3. Changes now go into ContactForm.java, and so into every view that has the form. Here Phone gets a helper text in **Properties**.

   [![Your browser does not support the video tag.](../../../vaadin/videos/copilot/component-classes/03-change.jpg)](../../../vaadin/videos/copilot/component-classes/03-change.mp4)

4. Click **↰** in the Editing tag to go back up to the view’s file, ContactView\.java.

   [![Your browser does not support the video tag.](../../../vaadin/videos/copilot/component-classes/04-up.jpg)](../../../vaadin/videos/copilot/component-classes/04-up.mp4)

## <a id="which-file-copilot-changes"></a>Which File Copilot Changes

The **Editing** tag names the file that your changes go into. Outside a component class, that’s the view’s file: changing the component there changes it in that view only. Inside, it’s the component’s class, and the change shows in every view that uses the component.
