# Copy and modify a component

There are many use cases where you'd like to modify an original component from the Radix parent theme. The idea here is that if you are not able to modify the component using different available properties, variables, and utility classes, you can just copy the component to your own Sub-theme and modify the markup there.

For example, let's take the **Block** component as an example.

### Step 1: Copy the component over

You can go to `web/themes/contrib/radix/components` directory and copy and paste the theme into your own `SUBTHEME_NAME/components` directory, or you can use `drupal-radix-cli`

Within your Sub-theme directory, open up the CLI and run:

```bash
drupal-radix-cli add
```

<figure><img src="/files/f0EqUhu1U1ydiVoLgfLS" alt=""><figcaption></figcaption></figure>

And then select the component you'd like to copy over to your Sub-theme. Once that's done, you'd see a new `block` component directory under the `components`

Now go ahead and change whatever you'd like in that component.

{% hint style="info" %}
Note that simply copying it over doesn't make your theme read that specific component, but with `drupal-radix-cli:^1.0.8` and higher, the system would automatically update your templates to load from your sub-theme instead of the parent Radix.
{% endhint %}

Now, for our theme to read our new component instead of the default Radix one, we need to update our templates, in our use case, search within your Sub-theme to see where the `radix:block` is being used and changed that namespace to `SUBTHEME_NAME:block`

For example, several templates use the `block` component from Radix, but imagine if we only want the local tasks to behave differently, we can change the `block--local-tasks-block.html.twig` template namespace accordingly, and it will pick up the new component moving forward. But with the new `drupal-radix-cli` It will automatically update your template files as well as shown below:

<figure><img src="/files/LtGLAJdDtgOflxBx3J2w" alt=""><figcaption></figcaption></figure>

Note that within your new `block` directory, you can modify your `scss` file or create a `_block.js` file and do any JS work needed there, those assets will be loaded along with `block.twig` file thanks to SDC.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.trydrupal.com/radix/working-with-the-components/copy-and-modify-a-component.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
