When Vue renders a component, it looks for any custom directives in the template. For example, if an input has a v-focus directive, Vue detects it during compilation. Then Vue calls the directive's mounted hook once the input element is created in the DOM. Inside this hook, the directive runs code like el.focus() to focus the input automatically. This updates the element's state so the user sees the cursor blinking inside the input, ready to type. Custom directives matter because they let you add reusable, direct DOM behavior without cluttering your component logic. They run at specific lifecycle moments, like when elements mount, update, or unmount, giving you control over element behavior. This visual trace shows how the directive hook runs after rendering and changes the element state, making the input focused for the user.